Changeset d60ccbf for src/SymTab/Validate.cc
- Timestamp:
- Aug 12, 2015, 2:27:31 PM (10 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- f32c7f4
- Parents:
- e45215c (diff), e869d663 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Validate.cc
re45215c rd60ccbf 10 10 // Created On : Sun May 17 21:50:04 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Tue Jul 14 12:27:54 201513 // Update Count : 1 8612 // Last Modified On : Wed Aug 05 14:00:24 2015 13 // Update Count : 195 14 14 // 15 15 … … 60 60 class HoistStruct : public Visitor { 61 61 public: 62 /// Flattens nested struct types 62 63 static void hoistStruct( std::list< Declaration * > &translationUnit ); 63 64 … … 84 85 }; 85 86 87 /// Replaces enum types by int, and function or array types in function parameter and return lists by appropriate pointers 86 88 class Pass1 : public Visitor { 87 89 typedef Visitor Parent; … … 89 91 virtual void visit( FunctionType *func ); 90 92 }; 91 93 94 /// Associates forward declarations of aggregates with their definitions 92 95 class Pass2 : public Indexer { 93 96 typedef Indexer Parent; … … 110 113 }; 111 114 115 /// Replaces array and function types in forall lists by appropriate pointer type 112 116 class Pass3 : public Indexer { 113 117 typedef Indexer Parent; … … 123 127 class AddStructAssignment : public Visitor { 124 128 public: 129 /// Generates assignment operators for aggregate types as required 125 130 static void addStructAssignment( std::list< Declaration * > &translationUnit ); 126 131 … … 158 163 public: 159 164 EliminateTypedef() : scopeLevel( 0 ) {} 165 /// Replaces typedefs by forward declarations 160 166 static void eliminateTypedef( std::list< Declaration * > &translationUnit ); 161 167 private: … … 163 169 virtual TypeDecl *mutate( TypeDecl *typeDecl ); 164 170 virtual DeclarationWithType *mutate( FunctionDecl *funcDecl ); 165 virtual ObjectDecl*mutate( ObjectDecl *objDecl );171 virtual DeclarationWithType *mutate( ObjectDecl *objDecl ); 166 172 virtual CompoundStmt *mutate( CompoundStmt *compoundStmt ); 167 173 virtual Type *mutate( TypeInstType *aggregateUseType ); … … 399 405 } // for 400 406 } // for 407 408 if ( ctx->get_parameters().size() != contextInst->get_parameters().size() ) { 409 throw SemanticError( "incorrect number of context parameters: ", contextInst ); 410 } // if 411 401 412 applySubstitution( ctx->get_parameters().begin(), ctx->get_parameters().end(), contextInst->get_parameters().begin(), ctx->get_members().begin(), ctx->get_members().end(), back_inserter( contextInst->get_members() ) ); 402 413 } … … 444 455 } 445 456 457 /// Fix up assertions 446 458 void forallFixer( Type *func ) { 447 // Fix up assertions448 459 for ( std::list< TypeDecl * >::iterator type = func->get_forall().begin(); type != func->get_forall().end(); ++type ) { 449 460 std::list< DeclarationWithType * > toBeDone, nextRound; … … 532 543 std::list<Statement *> initList; 533 544 initList.push_back( initStmt ); 534 545 535 546 UntypedExpr *cond = new UntypedExpr( new NameExpr( "?<?" ) ); 536 547 cond->get_args().push_back( new VariableExpr( index ) ); … … 610 621 delete assigns.front(); 611 622 assigns.pop_front(); 612 } 623 } // for 613 624 614 625 declsToAdd.insert( declsToAdd.begin(), assigns.begin(), assigns.end() ); … … 817 828 Type *ret = def->second.first->get_base()->clone(); 818 829 ret->get_qualifiers() += typeInst->get_qualifiers(); 830 // place instance parameters on the typedef'd type 831 if ( ! typeInst->get_parameters().empty() ) { 832 ReferenceToType *rtt = dynamic_cast<ReferenceToType*>(ret); 833 if ( ! rtt ) { 834 throw SemanticError("cannot apply type parameters to base type of " + typeInst->get_name()); 835 } 836 rtt->get_parameters().clear(); 837 cloneAll(typeInst->get_parameters(), rtt->get_parameters()); 838 } // if 819 839 delete typeInst; 820 840 return ret; … … 870 890 } 871 891 872 ObjectDecl*EliminateTypedef::mutate( ObjectDecl * objDecl ) {892 DeclarationWithType *EliminateTypedef::mutate( ObjectDecl * objDecl ) { 873 893 TypedefMap oldNames = typedefNames; 874 ObjectDecl*ret = Mutator::mutate( objDecl );894 DeclarationWithType *ret = Mutator::mutate( objDecl ); 875 895 typedefNames = oldNames; 896 if ( FunctionType *funtype = dynamic_cast<FunctionType *>( ret->get_type() ) ) { 897 return new FunctionDecl( ret->get_name(), ret->get_storageClass(), ret->get_linkage(), funtype, 0, ret->get_isInline(), ret->get_isNoreturn() ); 898 } else if ( objDecl->get_isInline() || objDecl->get_isNoreturn() ) { 899 throw SemanticError( "invalid inline or _Noreturn specification in declaration of ", objDecl ); 900 } // if 876 901 return ret; 877 902 }
Note:
See TracChangeset
for help on using the changeset viewer.