- File:
-
- 1 edited
-
src/Validate/ImplementEnumFunc.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Validate/ImplementEnumFunc.cpp
r90be0cf r63d5b9c8 78 78 std::vector<ast::ptr<ast::Init>> genValueInit() const; 79 79 ast::ObjectDecl* genAttrArrayProto( 80 const CodeLocation& location, const std::string& prefix,81 const ast::Type * type, std::vector<ast::ptr<ast::Init>>& inits) const;80 const ast::EnumAttribute attr, const CodeLocation& location, 81 std::vector<ast::ptr<ast::Init>>& inits) const; 82 82 }; 83 83 … … 351 351 352 352 ast::ObjectDecl* EnumAttrFuncGenerator::genAttrArrayProto( 353 const CodeLocation& location, const std::string& prefix,354 const ast::Type * type, std::vector<ast::ptr<ast::Init>>& inits) const {353 const ast::EnumAttribute attr, const CodeLocation& location, 354 std::vector<ast::ptr<ast::Init>>& inits) const { 355 355 ast::ArrayType* arrT = new ast::ArrayType( 356 type, 356 attr == ast::EnumAttribute::Value 357 ? decl->base 358 : new ast::PointerType( 359 new ast::BasicType(ast::BasicKind::Char, ast::CV::Const)), 357 360 ast::ConstantExpr::from_int(decl->location, decl->members.size()), 358 361 ast::LengthFlag::FixedLen, ast::DimensionFlag::DynamicDim); … … 360 363 ast::ObjectDecl* objDecl = 361 364 new ast::ObjectDecl( 362 decl->location, prefix + decl->name,365 decl->location, decl->getUnmangeldArrayName( attr ), 363 366 arrT, new ast::ListInit( location, std::move( inits ) ), 364 367 ast::Storage::Static, ast::Linkage::AutoGen ); … … 414 417 void EnumAttrFuncGenerator::genTypedEnumFunction(const ast::EnumAttribute attr) { 415 418 if (attr == ast::EnumAttribute::Value) { 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); 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 // } 426 437 } else if (attr == ast::EnumAttribute::Label) { 427 438 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 ) );430 439 ast::ObjectDecl* arrayProto = 431 genAttrArrayProto( getLocation(), "labels_", type, inits);440 genAttrArrayProto(attr, getLocation(), inits); 432 441 forwards.push_back(arrayProto); 433 442 ast::FunctionDecl* funcProto = genLabelProto(); … … 436 445 produceDecl(funcProto); 437 446 } else { 438 assert( attr == ast::EnumAttribute::Posn );439 447 ast::FunctionDecl* funcProto = genPosnProto(); 440 448 produceForwardDecl(funcProto);
Note:
See TracChangeset
for help on using the changeset viewer.