- File:
-
- 1 edited
-
src/ResolvExpr/CandidateFinder.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/CandidateFinder.cpp
r954c954 r4ef08f7 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], *param, symtab, cand->env, convCost ) );195 convCost.decSpec( specCost( *param) );194 args[i], paramType, symtab, cand->env, convCost ) ); 195 convCost.decSpec( specCost( paramType ) ); 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() ;700 const ast::Type * returnType = funcType->returns.front()->get_type(); 701 701 if ( ! unify( 702 702 returnType, targetType, funcEnv, funcNeed, funcHave, funcOpen, symtab ) … … 712 712 std::size_t genStart = 0; 713 713 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 ) { 714 for ( const ast::DeclWithType * param : funcType->params ) { 715 auto obj = strict_dynamic_cast< const ast::ObjectDecl * >( param ); 730 716 // Try adding the arguments corresponding to the current parameter to the existing 731 717 // matches 732 // no default args for indirect calls733 718 if ( ! instantiateArgument( 734 param, nullptr, args, results, genStart, symtab ) ) return; 735 } 736 737 endMatch: 719 obj->type, obj->init, args, results, genStart, symtab ) ) return; 720 } 721 738 722 if ( funcType->isVarArgs ) { 739 723 // append any unused arguments to vararg pack … … 832 816 /// Adds aggregate member interpretations 833 817 void addAggMembers( 834 const ast:: BaseInstType * aggrInst, const ast::Expr * expr,818 const ast::ReferenceToType * aggrInst, const ast::Expr * expr, 835 819 const Candidate & cand, const Cost & addedCost, const std::string & name 836 820 ) { … … 1279 1263 1280 1264 void postvisit( const ast::UntypedOffsetofExpr * offsetofExpr ) { 1281 const ast:: BaseInstType * aggInst;1265 const ast::ReferenceToType * aggInst; 1282 1266 if (( aggInst = offsetofExpr->type.as< ast::StructInstType >() )) ; 1283 1267 else if (( aggInst = offsetofExpr->type.as< ast::UnionInstType >() )) ;
Note:
See TracChangeset
for help on using the changeset viewer.