Changeset 90be0cf for src/Validate
- Timestamp:
- Oct 24, 2024, 12:50:14 PM (8 weeks ago)
- Branches:
- master
- Children:
- d031f7f
- Parents:
- 12c4a5f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Validate/ImplementEnumFunc.cpp
r12c4a5f r90be0cf 78 78 std::vector<ast::ptr<ast::Init>> genValueInit() const; 79 79 ast::ObjectDecl* genAttrArrayProto( 80 const ast::EnumAttribute attr, const CodeLocation& location,81 std::vector<ast::ptr<ast::Init>>& inits) const;80 const CodeLocation& location, const std::string& prefix, 81 const ast::Type * type, std::vector<ast::ptr<ast::Init>>& inits ) const; 82 82 }; 83 83 … … 351 351 352 352 ast::ObjectDecl* EnumAttrFuncGenerator::genAttrArrayProto( 353 const ast::EnumAttribute attr, const CodeLocation& location,354 std::vector<ast::ptr<ast::Init>>& inits) const {353 const CodeLocation& location, const std::string& prefix, 354 const ast::Type * type, std::vector<ast::ptr<ast::Init>>& inits ) const { 355 355 ast::ArrayType* arrT = new ast::ArrayType( 356 attr == ast::EnumAttribute::Value 357 ? decl->base 358 : new ast::PointerType( 359 new ast::BasicType(ast::BasicKind::Char, ast::CV::Const)), 356 type, 360 357 ast::ConstantExpr::from_int(decl->location, decl->members.size()), 361 358 ast::LengthFlag::FixedLen, ast::DimensionFlag::DynamicDim); … … 363 360 ast::ObjectDecl* objDecl = 364 361 new ast::ObjectDecl( 365 decl->location, decl->getUnmangeldArrayName( attr ),362 decl->location, prefix + decl->name, 366 363 arrT, new ast::ListInit( location, std::move( inits ) ), 367 364 ast::Storage::Static, ast::Linkage::AutoGen ); … … 417 414 void EnumAttrFuncGenerator::genTypedEnumFunction(const ast::EnumAttribute attr) { 418 415 if (attr == ast::EnumAttribute::Value) { 419 if (decl->isTyped()) { 420 // TypedEnum's backing arrays 421 std::vector<ast::ptr<ast::Init>> inits = genValueInit(); 422 ast::ObjectDecl* arrayProto = 423 genAttrArrayProto(attr, getLocation(), inits); 424 forwards.push_back(arrayProto); 425 426 ast::FunctionDecl* funcProto = genValueProto(); 427 produceForwardDecl(funcProto); 428 genValueOrLabelBody(funcProto, arrayProto); 429 produceDecl(funcProto); 430 } 431 // else { 432 // ast::FunctionDecl* funcProto = genQuasiValueProto(); 433 // produceForwardDecl(funcProto); 434 // // genQuasiValueBody(funcProto); 435 // produceDecl(funcProto); 436 // } 416 if ( !decl->isTyped() ) return; 417 std::vector<ast::ptr<ast::Init>> inits = genValueInit(); 418 ast::ObjectDecl* arrayProto = 419 genAttrArrayProto( getLocation(), "values_", decl->base, inits ); 420 forwards.push_back(arrayProto); 421 422 ast::FunctionDecl* funcProto = genValueProto(); 423 produceForwardDecl(funcProto); 424 genValueOrLabelBody(funcProto, arrayProto); 425 produceDecl(funcProto); 437 426 } else if (attr == ast::EnumAttribute::Label) { 438 427 std::vector<ast::ptr<ast::Init>> inits = genLabelInit(); 428 const ast::Type * type = new ast::PointerType( 429 new ast::BasicType( ast::BasicKind::Char, ast::CV::Const ) ); 439 430 ast::ObjectDecl* arrayProto = 440 genAttrArrayProto( attr, getLocation(), inits);431 genAttrArrayProto( getLocation(), "labels_", type, inits ); 441 432 forwards.push_back(arrayProto); 442 433 ast::FunctionDecl* funcProto = genLabelProto(); … … 445 436 produceDecl(funcProto); 446 437 } else { 438 assert( attr == ast::EnumAttribute::Posn ); 447 439 ast::FunctionDecl* funcProto = genPosnProto(); 448 440 produceForwardDecl(funcProto);
Note: See TracChangeset
for help on using the changeset viewer.