Changeset 954c954 for src/ResolvExpr/CandidateFinder.cpp
- Timestamp:
- Sep 24, 2020, 3:56:16 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 6cc913e
- Parents:
- eccb14d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/CandidateFinder.cpp
reccb14d r954c954 188 188 189 189 // mark conversion cost and also specialization cost of param type 190 const ast::Type * paramType = (*param)->get_type();190 // const ast::Type * paramType = (*param)->get_type(); 191 191 cand->expr = ast::mutate_field_index( 192 192 appExpr, &ast::ApplicationExpr::args, i, 193 193 computeExpressionConversionCost( 194 args[i], paramType, symtab, cand->env, convCost ) );195 convCost.decSpec( specCost( paramType) );194 args[i], *param, symtab, cand->env, convCost ) ); 195 convCost.decSpec( specCost( *param ) ); 196 196 ++param; // can't be in for-loop update because of the continue 197 197 } … … 698 698 if ( targetType && ! targetType->isVoid() && ! funcType->returns.empty() ) { 699 699 // attempt to narrow based on expected target type 700 const ast::Type * returnType = funcType->returns.front() ->get_type();700 const ast::Type * returnType = funcType->returns.front(); 701 701 if ( ! unify( 702 702 returnType, targetType, funcEnv, funcNeed, funcHave, funcOpen, symtab ) … … 712 712 std::size_t genStart = 0; 713 713 714 for ( const ast::DeclWithType * param : funcType->params ) { 715 auto obj = strict_dynamic_cast< const ast::ObjectDecl * >( param ); 714 // xxx - how to handle default arg after change to ftype representation? 715 if (const ast::VariableExpr * varExpr = func->expr.as<ast::VariableExpr>()) { 716 if (const ast::FunctionDecl * funcDecl = varExpr->var.as<ast::FunctionDecl>()) { 717 // function may have default args only if directly calling by name 718 // must use types on candidate however, due to RenameVars substitution 719 auto nParams = funcType->params.size(); 720 721 for (size_t i=0; i<nParams; ++i) { 722 auto obj = funcDecl->params[i].strict_as<ast::ObjectDecl>(); 723 if (!instantiateArgument( 724 funcType->params[i], obj->init, args, results, genStart, symtab)) return; 725 } 726 goto endMatch; 727 } 728 } 729 for ( const auto & param : funcType->params ) { 716 730 // Try adding the arguments corresponding to the current parameter to the existing 717 731 // matches 732 // no default args for indirect calls 718 733 if ( ! instantiateArgument( 719 obj->type, obj->init, args, results, genStart, symtab ) ) return; 720 } 721 734 param, nullptr, args, results, genStart, symtab ) ) return; 735 } 736 737 endMatch: 722 738 if ( funcType->isVarArgs ) { 723 739 // append any unused arguments to vararg pack
Note: See TracChangeset
for help on using the changeset viewer.