Changeset 77971f6 for src/ResolvExpr
- Timestamp:
- Oct 27, 2016, 3:24:02 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 3f0c6a5
- Parents:
- a1e67dd
- git-author:
- Rob Schluntz <rschlunt@…> (10/27/16 15:11:00)
- git-committer:
- Rob Schluntz <rschlunt@…> (10/27/16 15:24:02)
- Location:
- src/ResolvExpr
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativeFinder.cc
ra1e67dd r77971f6 41 41 #include "Common/utility.h" 42 42 #include "InitTweak/InitTweak.h" 43 #include "InitTweak/GenInit.h" 43 44 #include "ResolveTypeof.h" 44 45 … … 207 208 } 208 209 210 // std::unordered_map< Expression *, UniqueExpr * > ; 211 209 212 template< typename StructOrUnionType > 210 213 void AlternativeFinder::addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member ) { 211 212 214 // by this point, member must be a name expr 213 215 NameExpr * nameExpr = safe_dynamic_cast< NameExpr * >( member ); … … 434 436 // flatten actuals so that each actual has an atomic (non-tuple) type 435 437 AltList exploded; 436 Tuples::explode( actuals, back_inserter( exploded ) );438 Tuples::explode( actuals, indexer, back_inserter( exploded ) ); 437 439 438 440 AltList::iterator actualExpr = exploded.begin(); … … 1055 1057 1056 1058 void AlternativeFinder::visit( UniqueExpr *unqExpr ) { 1059 // this won't work because the unqExprs wont share an expression anymore... 1057 1060 AlternativeFinder finder( indexer, env ); 1058 1061 finder.findWithAdjustment( unqExpr->get_expr() ); 1059 1062 for ( Alternative & alt : finder.alternatives ) { 1060 // xxx - it's possible that this won't always do the right thing, i.e. two UniqueExprs 1061 // with the same ID may resolve to different expressions. If this ever happens, it might be necessary 1062 // to try to select an alternative here (i.e. error is there is not a unique min-cost expression). 1063 // One other thought is to to resolve each ID once and map the IDs to resolved expressions, 1064 // but this isn't as simple as it sounds since the alternative is not selected here, meaning it might 1065 // require complicated tracking throughout the system. 1066 1067 // brand the new UniqueExprs with the same id so that they are recognized as the same expression by the expansion pass 1068 alternatives.push_back( Alternative( new UniqueExpr( alt.expr->clone(), unqExpr->get_id() ), env, Cost::zero ) ); 1063 // xxx - attach a resolved ConstructorInit node? 1064 // xxx - is it possible to make the objDecl's type const? 1065 static UniqueName tempNamer( "_unq_expr_" ); 1066 ObjectDecl * objDecl = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, alt.expr->get_result()->clone(), nullptr ); 1067 // must be done on two lines because genCtorInit accesses objDecl's fields 1068 objDecl->set_init( InitTweak::genCtorInit( objDecl ) ); 1069 1070 UniqueExpr * newUnqExpr = new UniqueExpr( alt.expr->clone(), unqExpr->get_id() ); 1071 newUnqExpr->set_object( objDecl ); 1072 1073 resolveObject( indexer, objDecl ); 1074 1075 alternatives.push_back( Alternative( newUnqExpr, env, Cost::zero ) ); 1069 1076 } 1070 1077 } -
src/ResolvExpr/AlternativeFinder.h
ra1e67dd r77971f6 95 95 Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer, TypeEnvironment &env ); 96 96 97 void resolveObject( const SymTab::Indexer & indexer, ObjectDecl * objectDecl ); 98 97 99 template< typename InputIterator, typename OutputIterator > 98 100 void findMinCost( InputIterator begin, InputIterator end, OutputIterator out ) { -
src/ResolvExpr/Resolver.cc
ra1e67dd r77971f6 35 35 class Resolver : public SymTab::Indexer { 36 36 public: 37 Resolver() : SymTab::Indexer( false ), switchType( 0 ) {} 37 Resolver() : SymTab::Indexer( false ) {} 38 Resolver( const SymTab::Indexer & indexer ) : SymTab::Indexer( indexer ) {} 38 39 39 40 virtual void visit( FunctionDecl *functionDecl ); … … 68 69 void resolveSingleAggrInit( Declaration *, InitIterator &, InitIterator & ); 69 70 void fallbackInit( ConstructorInit * ctorInit ); 70 Type * functionReturn ;71 Type *initContext ;72 Type *switchType ;71 Type * functionReturn = nullptr; 72 Type *initContext = nullptr; 73 Type *switchType = nullptr; 73 74 bool inEnumDecl = false; 74 75 }; … … 532 533 } 533 534 535 void resolveObject( const SymTab::Indexer & indexer, ObjectDecl * objectDecl ) { 536 Resolver resolver( indexer ); 537 objectDecl->accept( resolver ); 538 } 539 534 540 void Resolver::visit( ConstructorInit *ctorInit ) { 535 541 // xxx - fallback init has been removed => remove fallbackInit function and remove complexity from FixInit and remove C-init from ConstructorInit
Note:
See TracChangeset
for help on using the changeset viewer.