Changeset 9d5eacb for src/Validate
- Timestamp:
- Jul 10, 2024, 6:55:54 PM (6 months ago)
- Branches:
- master
- Children:
- 236f133, 3be81a4
- Parents:
- 725f777f
- Location:
- src/Validate
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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.