Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/CandidateFinder.cpp

    rcdb4eaa r7a780ad  
    513513                                        // add new result
    514514                                        assert( common );
     515                                        // auto attrType = common.as<ast::EnumAttrType>();
     516                                        // if ( attrType && ( attrType->attr == ast::EnumAttribute::Value ) ) {
     517                                        //      auto callExpr = new ast::UntypedExpr(
     518                                        //              expr->location, new ast::NameExpr( expr->location, "valueE"), {expr} );
     519                                        //      CandidateFinder finder( context, env );
     520                                        //      finder.find( callExpr );
     521                                        //      CandidateList winners = findMinCost( finder.candidates );
     522                                        //      if (winners.size() != 1) {
     523                                        //              SemanticError( callExpr, "Ambiguous expression in valueE" );
     524                                        //      }
     525                                        //      CandidateRef & choice = winners.front();
     526                                        //      choice->expr = referenceToRvalueConversion( choice->expr, choice->cost );
     527
     528                                        //      results.emplace_back(
     529                                        //              i, choice->expr,
     530                                        //              std::move( env ), std::move( need ), std::move( have ), std::move( open ),
     531                                        //              nextArg + 1, nTuples, expl.cost, expl.exprs.size() == 1 ? 0 : 1, j );
     532                                        // } else {
    515533                                                results.emplace_back(
    516534                                                        i, expr, std::move( env ), std::move( need ), std::move( have ), std::move( open ),
     
    903921                                CandidateList winners = findMinCost( finder.candidates );
    904922                                if (winners.size() != 1) {
    905                                         SemanticError( callExpr, "Ambiguous expression in valueE..." );
     923                                        SemanticError( callExpr, "Ambiguous expression in valueE" );
    906924                                }
    907925                                CandidateRef & choice = winners.front();
    908                                 choice->cost.incVar();
     926                                // choice->cost.incSafe();
    909927                                candidates.emplace_back( std::move(choice) );
    910928                        }
     
    13821400                                }
    13831401                        }
    1384                        
     1402
    13851403                        CandidateRef newCand = std::make_shared<Candidate>(
    13861404                                newExpr, copy( tenv ), ast::OpenVarSet{}, ast::AssertionSet{}, bentConversion? Cost::safe: Cost::zero,
     
    17761794                                                auto commonAsEnumAttr = common.as<ast::EnumAttrType>();
    17771795                                                if ( commonAsEnumAttr && commonAsEnumAttr->attr == ast::EnumAttribute::Value ) {
    1778                                                        
    17791796                                                        auto callExpr = new ast::UntypedExpr(
    17801797                                                                cand->expr->location, new ast::NameExpr( cand->expr->location, "valueE"), {cand->expr} );
     
    17831800                                                        CandidateList winners = findMinCost( finder.candidates );
    17841801                                                        if (winners.size() != 1) {
    1785                                                                 SemanticError( callExpr, "Ambiguous expression in valueE..." );
     1802                                                                SemanticError( callExpr, "Ambiguous expression in valueE" );
    17861803                                                        }
    17871804                                                        CandidateRef & choice = winners.front();
     
    18051822                                                        // if this somehow changes in the future (e.g. delayed by indeterminate return type)
    18061823                                                        // we may need to revisit the logic.
    1807                                                         inferParameters( newCand, matches );   
     1824                                                        inferParameters( newCand, matches );
    18081825                                                }
    1809                                         }                       
    1810                                 }       
     1826                                        }
     1827                                }
    18111828                        }
    18121829                }
     
    21332150}
    21342151
    2135 // get the valueE(...) ApplicationExpr that returns the enum value
    2136 const ast::Expr * getValueEnumCall(
    2137         const ast::Expr * expr,
    2138         const ResolvExpr::ResolveContext & context, const ast::TypeEnvironment & env ) {
    2139                 auto callExpr = new ast::UntypedExpr(
    2140                         expr->location, new ast::NameExpr( expr->location, "valueE"), {expr} );
    2141                 CandidateFinder finder( context, env );
    2142                 finder.find( callExpr );
    2143                 CandidateList winners = findMinCost( finder.candidates );
    2144                 if (winners.size() != 1) {
    2145                         SemanticError( callExpr, "Ambiguous expression in valueE..." );
    2146                 }
    2147                 CandidateRef & choice = winners.front();
    2148                 return choice->expr;
     2152const ast::Expr * getValueEnumCall( const ast::Expr * expr,
     2153                const ResolveContext & context, const ast::TypeEnvironment & env ) {
     2154        auto callExpr = new ast::UntypedExpr(
     2155                expr->location, new ast::NameExpr( expr->location, "valueE"), {expr} );
     2156        CandidateFinder finder( context, env );
     2157        finder.find( callExpr );
     2158        CandidateList winners = findMinCost( finder.candidates );
     2159        if (winners.size() != 1) {
     2160                SemanticError( callExpr, "Ambiguous expression in valueE" );
     2161        }
     2162        CandidateRef & choice = winners.front();
     2163        return choice->expr;
    21492164}
    21502165
     
    21612176                        }
    21622177                ),
    2163                 new ast::BasicType( ast::BasicType::SignedInt )
     2178                new ast::BasicType( ast::BasicKind::SignedInt )
    21642179        );
    21652180}
Note: See TracChangeset for help on using the changeset viewer.