Changeset 141b786 for src/ResolvExpr
- Timestamp:
- Nov 9, 2016, 2:21:05 PM (8 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:
- b726084
- Parents:
- 23bb1b9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/ResolvExpr/AlternativeFinder.cc ¶
r23bb1b9 r141b786 39 39 #include "SymTab/Validate.h" 40 40 #include "Tuples/Tuples.h" 41 #include "Tuples/Explode.h" 41 42 #include "Common/utility.h" 42 43 #include "InitTweak/InitTweak.h" … … 240 241 } // if 241 242 } // if 243 } else if ( NameExpr * nameExpr = dynamic_cast< NameExpr * >( member ) ) { 244 // xxx - temporary hack until 0/1 are int constants 245 if ( nameExpr->get_name() == "0" || nameExpr->get_name() == "1" ) { 246 std::stringstream ss( nameExpr->get_name() ); 247 int val; 248 ss >> val; 249 alternatives.push_back( Alternative( new TupleIndexExpr( expr->clone(), val ), env, newCost ) ); 250 } 242 251 } // if 243 252 } … … 1057 1066 1058 1067 void AlternativeFinder::visit( UniqueExpr *unqExpr ) { 1059 // this won't work because the unqExprs wont share an expression anymore...1060 1068 AlternativeFinder finder( indexer, env ); 1061 1069 finder.findWithAdjustment( unqExpr->get_expr() ); 1062 1070 for ( Alternative & alt : finder.alternatives ) { 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 1071 // ensure that the id is passed on to the UniqueExpr alternative so that the expressions are "linked" 1070 1072 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 ) ); 1073 alternatives.push_back( Alternative( newUnqExpr, alt.env, alt.cost ) ); 1076 1074 } 1077 1075 }
Note: See TracChangeset
for help on using the changeset viewer.