Changeset 4c8621ac for src/ResolvExpr
- Timestamp:
- Dec 22, 2016, 4:07:58 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:
- 1e3d5b6
- Parents:
- 907eccb
- Location:
- src/ResolvExpr
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified 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) -
TabularUnified src/ResolvExpr/Unify.cc ¶
r907eccb r4c8621ac 517 517 } // if 518 518 } // for 519 if ( list1Begin != list1End || list2Begin != list2End ) { 520 return false; 519 // if ( list1Begin != list1End || list2Begin != list2End ) { 520 // return false; 521 if ( list1Begin != list1End ) { 522 // try unifying empty tuple type with ttype 523 Type * t1 = (*list1Begin)->get_type(); 524 if ( Tuples::isTtype( t1 ) ) { 525 Type * combinedType = combineTypes( list2Begin, list2End ); 526 return unifyExact( t1, combinedType, env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer ); 527 } else return false; 528 } else if ( list2Begin != list2End ) { 529 // try unifying empty tuple type with ttype 530 Type * t2 = (*list2Begin)->get_type(); 531 if ( Tuples::isTtype( t2 ) ) { 532 Type * combinedType = combineTypes( list1Begin, list1End ); 533 return unifyExact( combinedType, t2, env, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer ); 534 } else return false; 521 535 } else { 522 536 return true;
Note: See TracChangeset
for help on using the changeset viewer.