- Timestamp:
- Jul 10, 2024, 6:55:54 PM (5 months ago)
- Branches:
- master
- Children:
- 236f133, 3be81a4
- Parents:
- 725f777f
- Location:
- src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.hpp
r725f777f r9d5eacb 27 27 static DeclarationNode * newFunction( const std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body ); 28 28 static DeclarationNode * newAggregate( ast::AggregateDecl::Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ); 29 static DeclarationNode * newEnum( const std::string * name, DeclarationNode * constants, bool body, bool typed, DeclarationNode * base = nullptr, EnumHiding hiding = EnumHiding::Visible );29 static DeclarationNode * newEnum( const std::string * name, DeclarationNode * constants, bool body, bool isCfa = false, DeclarationNode * base = nullptr, EnumHiding hiding = EnumHiding::Visible ); 30 30 static DeclarationNode * newEnumConstant( const std::string * name, ExpressionNode * constant ); 31 31 static DeclarationNode * newEnumValueGeneric( const std::string * name, InitializerNode * init ); -
src/ResolvExpr/ResolveTypeof.cpp
r725f777f r9d5eacb 61 61 if ( typeofType->kind == ast::TypeofType::Basetypeof ) { 62 62 // replace basetypeof(<enum>) by int 63 // if ( newType.as< ast::EnumInstType >() ) { 64 // newType = new ast::BasicType( 65 // ast::BasicKind::SignedInt, newType->qualifiers, copy(newType->attributes) ); 66 // } 63 auto enumInst = newType.as< ast::EnumInstType >(); 64 if ( enumInst && (!enumInst->base || !enumInst->base->isCfa) ) { 65 newType = new ast::BasicType( 66 ast::BasicKind::SignedInt, newType->qualifiers, copy(newType->attributes) ); 67 } 67 68 reset_qualifiers( 68 69 newType, -
src/Validate/Autogen.cpp
r725f777f r9d5eacb 245 245 ast::EnumInstType enumInst( enumDecl->name ); 246 246 enumInst.base = enumDecl; 247 EnumFuncGenerator gen( enumDecl, &enumInst, functionNesting ); 248 gen.generateAndPrependDecls( declsToAddBefore ); 247 if ( enumDecl->isCfa ) { 248 EnumFuncGenerator gen( enumDecl, &enumInst, functionNesting ); 249 gen.generateAndPrependDecls( declsToAddBefore ); 250 } 249 251 250 252 EnumFuncGenerator gen2( enumDecl, &enumInst, functionNesting ); … … 742 744 for ( auto & generator : standardProtos ) { 743 745 ast::FunctionDecl * decl = (this->*generator)(); 744 // produceForwardDecl( decl ); Done in genForwards746 produceForwardDecl( decl ); 745 747 genFuncBody( decl ); 746 748 if ( CodeGen::isAssignment( decl->name ) ) { -
src/Validate/ImplementEnumFunc.cpp
r725f777f r9d5eacb 105 105 assert(memAsObjectDecl); 106 106 if (auto& init = memAsObjectDecl->init) { 107 auto singleInit = init.strict_as<ast::SingleInit>(); 108 auto nameExpr = singleInit->value.as<ast::NameExpr>(); 109 if (nameExpr) { 110 auto name = nameExpr->name; 111 if (auto it = std::find_if(decl->members.begin(), decl->members.end(), 112 [name](ast::ptr<ast::Decl> mem_decl) { 113 return (mem_decl->name == name); 114 }); it != std::end(decl->members) 115 ) { 116 // ast::SingleInit* newInit = new ast::SingleInit( 117 // init->location, new ast::CastExpr( nameExpr->location, 118 // nameExpr, new ast::BasicType( ast::BasicKind::UnsignedInt ), ast::ExplicitCast ) 119 // ); 120 // auto targetInit = (*it).strict_as<ast::ObjectDecl>()->init; 121 // inits.emplace_back( targetInit ); 122 auto index = std::distance( decl->members.begin(), it ); 123 auto targetInit = inits.at(index).strict_as<ast::SingleInit>(); 124 auto targetExpr = targetInit->value; 125 inits.push_back( new ast::SingleInit( targetExpr->location, targetExpr ) ); 126 continue; 107 if ( auto singleInit = init.as<ast::SingleInit>() ) { 108 if ( auto nameExpr = singleInit->value.as<ast::NameExpr>() ) { 109 auto name = nameExpr->name; 110 if (auto it = std::find_if(decl->members.begin(), decl->members.end(), 111 [name](ast::ptr<ast::Decl> mem_decl) { 112 return (mem_decl->name == name); 113 }); it != std::end(decl->members) 114 ) { 115 auto index = std::distance( decl->members.begin(), it ); 116 auto targetInit = inits.at(index).strict_as<ast::SingleInit>(); 117 auto targetExpr = targetInit->value; 118 inits.push_back( new ast::SingleInit( targetExpr->location, targetExpr ) ); 119 continue; 120 } 127 121 } 128 122 } 129 130 123 inits.emplace_back(memAsObjectDecl->init); 131 124 } else {
Note: See TracChangeset
for help on using the changeset viewer.