Changeset 77971f6 for src/ResolvExpr/AlternativeFinder.cc
- Timestamp:
- Oct 27, 2016, 3:24:02 PM (7 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)
- File:
-
- 1 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 }
Note: See TracChangeset
for help on using the changeset viewer.