Changeset 270fdcf for src/ResolvExpr/AlternativeFinder.cc
- Timestamp:
- Jun 14, 2018, 4:33:34 PM (6 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, with_gc
- Children:
- d286cf68, db4062d
- Parents:
- ef952d7 (diff), d16cf16 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativeFinder.cc
ref952d7 r270fdcf 176 176 selected[ mangleName ] = current; 177 177 } else if ( candidate->cost == mapPlace->second.candidate->cost ) { 178 PRINT( 179 std::cerr << "marking ambiguous" << std::endl; 180 ) 181 mapPlace->second.isAmbiguous = true; 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 } 182 192 } else { 183 193 PRINT( … … 335 345 if ( ConstantExpr * constantExpr = dynamic_cast< ConstantExpr * >( member ) ) { 336 346 // get the value of the constant expression as an int, must be between 0 and the length of the tuple type to have meaning 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; 347 auto val = constantExpr->intValue(); 341 348 std::string tmp; 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 349 if ( val >= 0 && (unsigned long long)val < tupleType->size() ) { 350 alternatives.push_back( Alternative( new TupleIndexExpr( expr->clone(), val ), env, newCost ) ); 346 351 } // if 347 } else if ( NameExpr * nameExpr = dynamic_cast< NameExpr * >( member ) ) {348 // xxx - temporary hack until 0/1 are int constants349 if ( nameExpr->get_name() == "0" || nameExpr->get_name() == "1" ) {350 std::stringstream ss( nameExpr->get_name() );351 int val;352 ss >> val;353 alternatives.push_back( Alternative( new TupleIndexExpr( expr->clone(), val ), env, newCost ) );354 }355 352 } // if 356 353 } … … 439 436 return Cost::infinity; 440 437 } 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; 441 445 } 442 446 Type * formalType = (*formal)->get_type(); … … 611 615 ConstantExpr* getDefaultValue( Initializer* init ) { 612 616 if ( SingleInit* si = dynamic_cast<SingleInit*>( init ) ) { 613 if ( CastExpr* ce = dynamic_cast<CastExpr*>( si->get_value() ) ) { 614 return dynamic_cast<ConstantExpr*>( ce->get_arg() ); 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 ); 615 621 } 616 622 } … … 873 879 indexer ) ) { 874 880 results.emplace_back( 875 i, cnstExpr, move(env), move(need), move(have),881 i, new DefaultArgExpr( cnstExpr ), move(env), move(need), move(have), 876 882 move(openVars), nextArg, nTuples ); 877 883 } … … 1065 1071 funcFinder.findWithAdjustment( untypedExpr->function ); 1066 1072 // 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. 1067 1074 if ( funcFinder.alternatives.empty() ) return; 1068 1075
Note: See TracChangeset
for help on using the changeset viewer.