Changeset 907eccb for src/ResolvExpr
- Timestamp:
- Dec 22, 2016, 3:23:49 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:
- 4c8621ac
- Parents:
- 0c286cf
- Location:
- src/ResolvExpr
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativeFinder.cc
r0c286cf r907eccb 351 351 if ( TupleType * tupleType = dynamic_cast< TupleType * >( formalType ) ) { 352 352 // formalType is a TupleType - group actuals into a TupleExpr whose type unifies with the TupleType 353 TupleExpr * tupleExpr = new TupleExpr();353 std::list< Expression * > exprs; 354 354 for ( Type * type : *tupleType ) { 355 if ( ! instantiateArgument( type, defaultValue, actualIt, actualEnd, openVars, resultEnv, resultNeed, resultHave, indexer, cost, back_inserter( tupleExpr->get_exprs()) ) ) {356 delete tupleExpr;355 if ( ! instantiateArgument( type, defaultValue, actualIt, actualEnd, openVars, resultEnv, resultNeed, resultHave, indexer, cost, back_inserter( exprs ) ) ) { 356 deleteAll( exprs ); 357 357 return false; 358 358 } 359 359 } 360 tupleExpr->set_result( Tuples::makeTupleType( tupleExpr->get_exprs() ) ); 361 *out++ = tupleExpr; 360 *out++ = new TupleExpr( exprs ); 362 361 } else if ( actualIt != actualEnd ) { 363 362 if ( TypeInstType * ttype = Tuples::isTtype( formalType ) ) { … … 1058 1057 } 1059 1058 1060 void AlternativeFinder::visit( TupleExpr *tupleExpr ) {1059 void AlternativeFinder::visit( UntypedTupleExpr *tupleExpr ) { 1061 1060 std::list< AlternativeFinder > subExprAlternatives; 1062 1061 findSubExprs( tupleExpr->get_exprs().begin(), tupleExpr->get_exprs().end(), back_inserter( subExprAlternatives ) ); … … 1064 1063 combos( subExprAlternatives.begin(), subExprAlternatives.end(), back_inserter( possibilities ) ); 1065 1064 for ( std::list< AltList >::const_iterator i = possibilities.begin(); i != possibilities.end(); ++i ) { 1066 TupleExpr *newExpr = new TupleExpr; 1067 makeExprList( *i, newExpr->get_exprs() ); 1068 newExpr->set_result( Tuples::makeTupleType( newExpr->get_exprs() ) ); 1065 std::list< Expression * > exprs; 1066 makeExprList( *i, exprs ); 1069 1067 1070 1068 TypeEnvironment compositeEnv; 1071 1069 simpleCombineEnvironments( i->begin(), i->end(), compositeEnv ); 1072 alternatives.push_back( Alternative( new Expr, compositeEnv, sumCost( *i ) ) );1070 alternatives.push_back( Alternative( new TupleExpr( exprs ) , compositeEnv, sumCost( *i ) ) ); 1073 1071 } // for 1072 } 1073 1074 void AlternativeFinder::visit( TupleExpr *tupleExpr ) { 1075 alternatives.push_back( Alternative( tupleExpr->clone(), env, Cost::zero ) ); 1074 1076 } 1075 1077 -
src/ResolvExpr/AlternativeFinder.h
r0c286cf r907eccb 64 64 virtual void visit( ConditionalExpr *conditionalExpr ); 65 65 virtual void visit( CommaExpr *commaExpr ); 66 virtual void visit( TupleExpr *tupleExpr );67 66 virtual void visit( ImplicitCopyCtorExpr * impCpCtorExpr ); 68 67 virtual void visit( ConstructorExpr * ctorExpr ); 68 virtual void visit( UntypedTupleExpr *tupleExpr ); 69 virtual void visit( TupleExpr *tupleExpr ); 69 70 virtual void visit( TupleIndexExpr *tupleExpr ); 70 71 virtual void visit( TupleAssignExpr *tupleExpr );
Note: See TracChangeset
for help on using the changeset viewer.