Changeset bb336a6 for src/Validate/ImplementEnumFunc.cpp
- Timestamp:
- Jul 10, 2024, 3:39:26 AM (4 months ago)
- Branches:
- master
- Children:
- dbff8ec
- Parents:
- 550afde2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Validate/ImplementEnumFunc.cpp
r550afde2 rbb336a6 104 104 auto memAsObjectDecl = mem.as<ast::ObjectDecl>(); 105 105 assert(memAsObjectDecl); 106 if (memAsObjectDecl->init) { 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; 127 } 128 } 129 107 130 inits.emplace_back(memAsObjectDecl->init); 108 131 } else { … … 406 429 void EnumAttrFuncGenerator::genTypedEnumFunction(const ast::EnumAttribute attr) { 407 430 if (attr == ast::EnumAttribute::Value) { 408 if (decl-> base) {431 if (decl->isTyped()) { 409 432 // TypedEnum's backing arrays 410 433 std::vector<ast::ptr<ast::Init>> inits = genValueInit(); … … 441 464 442 465 void EnumAttrFuncGenerator::genTypedEnumFuncs() { 443 genTypedEnumFunction(ast::EnumAttribute::Value);444 genTypedEnumFunction(ast::EnumAttribute::Label);445 genTypedEnumFunction(ast::EnumAttribute::Posn);466 // genTypedEnumFunction(ast::EnumAttribute::Value); 467 // genTypedEnumFunction(ast::EnumAttribute::Label); 468 // genTypedEnumFunction(ast::EnumAttribute::Posn); 446 469 } 447 470 … … 456 479 std::list<ast::ptr<ast::Decl>>& decls) { 457 480 // Generate the functions (they go into forwards and definitions). 458 genTypeNameFunc();481 // genTypeNameFunc(); 459 482 genTypedEnumFuncs(); 460 genSerialTraitFuncs();461 genBoundedFunctions();483 // genSerialTraitFuncs(); 484 // genBoundedFunctions(); 462 485 // Now export the lists contents. 463 486 decls.splice(decls.end(), forwards); … … 483 506 enumInst.base = enumDecl; 484 507 EnumAttrFuncGenerator gen(enumDecl, &enumInst, functionNesting); 485 gen.generateAndAppendFunctions(declsToAddAfter);508 // gen.generateAndAppendFunctions(declsToAddAfter); 486 509 } 487 510
Note: See TracChangeset
for help on using the changeset viewer.