Changeset 4c8621ac for src/ResolvExpr/AlternativeFinder.cc
- Timestamp:
- Dec 22, 2016, 4:07:58 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:
- 1e3d5b6
- Parents:
- 907eccb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativeFinder.cc
r907eccb r4c8621ac 359 359 } 360 360 *out++ = new TupleExpr( exprs ); 361 } else if ( TypeInstType * ttype = Tuples::isTtype( formalType ) ) { 362 // xxx - mixing default arguments with variadic?? 363 std::list< Expression * > exprs; 364 for ( ; actualIt != actualEnd; ++actualIt ) { 365 exprs.push_back( actualIt->expr->clone() ); 366 cost += actualIt->cost; 367 } 368 Expression * arg = nullptr; 369 if ( exprs.size() == 1 && Tuples::isTtype( exprs.front()->get_result() ) ) { 370 // the case where a ttype value is passed directly is special, e.g. for argument forwarding purposes 371 // xxx - what if passing multiple arguments, last of which is ttype? 372 // xxx - what would happen if unify was changed so that unifying tuple types flattened both before unifying lists? then pass in TupleType(ttype) below. 373 arg = exprs.front(); 374 } else { 375 arg = new TupleExpr( exprs ); 376 } 377 assert( arg && arg->get_result() ); 378 if ( ! unify( ttype, arg->get_result(), resultEnv, resultNeed, resultHave, openVars, indexer ) ) { 379 return false; 380 } 381 *out++ = arg; 382 return true; 361 383 } else if ( actualIt != actualEnd ) { 362 if ( TypeInstType * ttype = Tuples::isTtype( formalType ) ) {363 // xxx - mixing default arguments with variadic??364 if ( ! Tuples::isTtype( actualIt->expr->get_result() ) ) {365 // xxx - what if passing multiple arguments, last of which is ttype?366 367 // consume all remaining arguments, variadic style368 std::list< Expression * > exprs;369 for ( ; actualIt != actualEnd; ++actualIt ) {370 exprs.push_back( actualIt->expr->clone() );371 cost += actualIt->cost;372 }373 TupleExpr * arg = new TupleExpr( exprs );374 assert( arg->get_result() );375 // unification run for side effects376 bool unifyResult = unify( ttype, arg->get_result(), resultEnv, resultNeed, resultHave, openVars, indexer );377 assertf( unifyResult, "Somehow unifying ttype failed..." );378 *out++ = arg;379 return true;380 }381 }382 384 // both actualType and formalType are atomic (non-tuple) types - if they unify 383 385 // then accept actual as an argument, otherwise return false (fail to instantiate argument)
Note: See TracChangeset
for help on using the changeset viewer.