Changeset bb336a6 for src/Validate/Autogen.cpp
- Timestamp:
- Jul 10, 2024, 3:39:26 AM (6 weeks ago)
- Branches:
- master
- Children:
- dbff8ec
- Parents:
- 550afde2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Validate/Autogen.cpp
r550afde2 rbb336a6 88 88 89 89 // Internal helpers: 90 v oid genStandardFuncs();90 virtual void genStandardFuncs(); 91 91 void produceDecl( const ast::FunctionDecl * decl ); 92 92 void produceForwardDecl( const ast::FunctionDecl * decl ); … … 196 196 197 197 bool shouldAutogen() const final { return true; } 198 void generateAndPrependDecls( std::list<ast::ptr<ast::Decl>> & ); 199 void genForwards(); 198 200 private: 199 201 void genFuncBody( ast::FunctionDecl * decl ) final; 200 202 void genFieldCtors() final; 201 203 const ast::Decl * getDecl() const final { return decl; } 204 protected: 205 void genStandardFuncs() override; 202 206 }; 203 207 … … 242 246 enumInst.base = enumDecl; 243 247 EnumFuncGenerator gen( enumDecl, &enumInst, functionNesting ); 244 gen.generateAndAppendFunctions( declsToAddAfter ); 248 gen.generateAndPrependDecls( declsToAddBefore ); 249 250 EnumFuncGenerator gen2( enumDecl, &enumInst, functionNesting ); 251 gen2.generateAndAppendFunctions( declsToAddAfter ); 245 252 } 246 253 … … 709 716 } 710 717 718 void EnumFuncGenerator::generateAndPrependDecls( std::list<ast::ptr<ast::Decl>> & decls ) { 719 genForwards(); 720 decls.splice( decls.end(), forwards ); 721 } 722 723 void EnumFuncGenerator::genForwards() { 724 forwards.push_back( ast::asForward(decl) ); 725 726 ast::FunctionDecl *(FuncGenerator::*standardProtos[4])() const = { 727 &EnumFuncGenerator::genCtorProto, &EnumFuncGenerator::genCopyProto, 728 &EnumFuncGenerator::genDtorProto, &EnumFuncGenerator::genAssignProto }; 729 730 for ( auto & generator: standardProtos) { 731 ast::FunctionDecl * decl = (this->*generator)(); 732 produceForwardDecl( decl ); 733 } 734 } 735 736 void EnumFuncGenerator::genStandardFuncs() { 737 // do everything FuncGenerator does except not make ForwardDecls 738 ast::FunctionDecl *(FuncGenerator::*standardProtos[4])() const = { 739 &EnumFuncGenerator::genCtorProto, &EnumFuncGenerator::genCopyProto, 740 &EnumFuncGenerator::genDtorProto, &EnumFuncGenerator::genAssignProto }; 741 742 for ( auto & generator : standardProtos ) { 743 ast::FunctionDecl * decl = (this->*generator)(); 744 // produceForwardDecl( decl ); Done in genForwards 745 genFuncBody( decl ); 746 if ( CodeGen::isAssignment( decl->name ) ) { 747 appendReturnThis( decl ); 748 } 749 produceDecl( decl ); 750 } 751 } 752 711 753 void EnumFuncGenerator::genFieldCtors() { 712 754 // Enumerations to not have field constructors.
Note: See TracChangeset
for help on using the changeset viewer.