- File:
-
- 1 edited
-
src/ResolvExpr/AlternativeFinder.cc (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativeFinder.cc
r0f79853 r00ac42e 176 176 selected[ mangleName ] = current; 177 177 } else if ( candidate->cost == mapPlace->second.candidate->cost ) { 178 // if one of the candidates contains a deleted identifier, can pick the other, since 179 // deleted expressions should not be ambiguous if there is another option that is at least as good 180 if ( findDeletedExpr( candidate->expr ) ) { 181 // do nothing 182 PRINT( std::cerr << "candidate is deleted" << std::endl; ) 183 } else if ( findDeletedExpr( mapPlace->second.candidate->expr ) ) { 184 PRINT( std::cerr << "current is deleted" << std::endl; ) 185 selected[ mangleName ] = current; 186 } else { 187 PRINT( 188 std::cerr << "marking ambiguous" << std::endl; 189 ) 190 mapPlace->second.isAmbiguous = true; 191 } 178 PRINT( 179 std::cerr << "marking ambiguous" << std::endl; 180 ) 181 mapPlace->second.isAmbiguous = true; 192 182 } else { 193 183 PRINT( … … 345 335 if ( ConstantExpr * constantExpr = dynamic_cast< ConstantExpr * >( member ) ) { 346 336 // get the value of the constant expression as an int, must be between 0 and the length of the tuple type to have meaning 347 auto val = constantExpr->intValue(); 337 // xxx - this should be improved by memoizing the value of constant exprs 338 // during parsing and reusing that information here. 339 std::stringstream ss( constantExpr->get_constant()->get_value() ); 340 int val = 0; 348 341 std::string tmp; 349 if ( val >= 0 && (unsigned long long)val < tupleType->size() ) { 342 if ( ss >> val && ! (ss >> tmp) ) { 343 if ( val >= 0 && (unsigned int)val < tupleType->size() ) { 344 alternatives.push_back( Alternative( new TupleIndexExpr( expr->clone(), val ), env, newCost ) ); 345 } // if 346 } // if 347 } else if ( NameExpr * nameExpr = dynamic_cast< NameExpr * >( member ) ) { 348 // xxx - temporary hack until 0/1 are int constants 349 if ( nameExpr->get_name() == "0" || nameExpr->get_name() == "1" ) { 350 std::stringstream ss( nameExpr->get_name() ); 351 int val; 352 ss >> val; 350 353 alternatives.push_back( Alternative( new TupleIndexExpr( expr->clone(), val ), env, newCost ) ); 351 } // if354 } 352 355 } // if 353 356 } … … 436 439 return Cost::infinity; 437 440 } 438 }439 if ( DefaultArgExpr * def = dynamic_cast< DefaultArgExpr * >( *actualExpr ) ) {440 // default arguments should be free - don't include conversion cost.441 // Unwrap them here because they are not relevant to the rest of the system.442 *actualExpr = def->expr;443 ++formal;444 continue;445 441 } 446 442 Type * formalType = (*formal)->get_type(); … … 615 611 ConstantExpr* getDefaultValue( Initializer* init ) { 616 612 if ( SingleInit* si = dynamic_cast<SingleInit*>( init ) ) { 617 if ( CastExpr* ce = dynamic_cast<CastExpr*>( si->value ) ) { 618 return dynamic_cast<ConstantExpr*>( ce->arg ); 619 } else { 620 return dynamic_cast<ConstantExpr*>( si->value ); 613 if ( CastExpr* ce = dynamic_cast<CastExpr*>( si->get_value() ) ) { 614 return dynamic_cast<ConstantExpr*>( ce->get_arg() ); 621 615 } 622 616 } … … 879 873 indexer ) ) { 880 874 results.emplace_back( 881 i, new DefaultArgExpr( cnstExpr ), move(env), move(need), move(have),875 i, cnstExpr, move(env), move(need), move(have), 882 876 move(openVars), nextArg, nTuples ); 883 877 } … … 1071 1065 funcFinder.findWithAdjustment( untypedExpr->function ); 1072 1066 // if there are no function alternatives, then proceeding is a waste of time. 1073 // xxx - findWithAdjustment throws, so this check and others like it shouldn't be necessary.1074 1067 if ( funcFinder.alternatives.empty() ) return; 1075 1068
Note:
See TracChangeset
for help on using the changeset viewer.