Changeset 7aa209e7 for src/ResolvExpr


Ignore:
Timestamp:
Apr 17, 2024, 10:50:36 AM (4 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
8fd53b6e
Parents:
710d0c8c
Message:

Fixing some whitespace around a recent merge. That lead to some general clean-up, including removing tailing whitespace and removing some unneeded dependences.

Location:
src/ResolvExpr
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/CandidateFinder.cpp

    r710d0c8c r7aa209e7  
    14001400                                }
    14011401                        }
    1402                        
     1402
    14031403                        CandidateRef newCand = std::make_shared<Candidate>(
    14041404                                newExpr, copy( tenv ), ast::OpenVarSet{}, ast::AssertionSet{}, bentConversion? Cost::safe: Cost::zero,
     
    17941794                                                auto commonAsEnumAttr = common.as<ast::EnumAttrType>();
    17951795                                                if ( commonAsEnumAttr && commonAsEnumAttr->attr == ast::EnumAttribute::Value ) {
    1796                                                        
    17971796                                                        auto callExpr = new ast::UntypedExpr(
    17981797                                                                cand->expr->location, new ast::NameExpr( cand->expr->location, "valueE"), {cand->expr} );
     
    18231822                                                        // if this somehow changes in the future (e.g. delayed by indeterminate return type)
    18241823                                                        // we may need to revisit the logic.
    1825                                                         inferParameters( newCand, matches );   
     1824                                                        inferParameters( newCand, matches );
    18261825                                                }
    1827                                         }                       
    1828                                 }       
     1826                                        }
     1827                                }
    18291828                        }
    18301829                }
     
    21512150}
    21522151
    2153 // get the valueE(...) ApplicationExpr that returns the enum value
    2154 const ast::Expr * getValueEnumCall(
    2155         const ast::Expr * expr,
    2156         const ResolvExpr::ResolveContext & context, const ast::TypeEnvironment & env ) {
    2157                 auto callExpr = new ast::UntypedExpr(
    2158                         expr->location, new ast::NameExpr( expr->location, "valueE"), {expr} );
    2159                 CandidateFinder finder( context, env );
    2160                 finder.find( callExpr );
    2161                 CandidateList winners = findMinCost( finder.candidates );
    2162                 if (winners.size() != 1) {
    2163                         SemanticError( callExpr, "Ambiguous expression in valueE" );
    2164                 }
    2165                 CandidateRef & choice = winners.front();
    2166                 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;
    21672164}
    21682165
  • src/ResolvExpr/CandidateFinder.hpp

    r710d0c8c r7aa209e7  
    3030struct CandidateFinder {
    3131        CandidateList candidates;          ///< List of candidate resolutions
    32         const ResolveContext & context;  ///< Information about where the canditates are being found.
     32        const ResolveContext & context;    ///< Information about where the canditates are being found.
    3333        const ast::TypeEnvironment & env;  ///< Substitutions performed in this resolution
    3434        ast::ptr< ast::Type > targetType;  ///< Target type for resolution
    3535        bool strictMode = false;           ///< If set to true, requires targetType to be exact match (inside return cast)
    3636        bool allowVoid = false;            ///< If set to true, allow void-returning function calls (only top level, cast to void and first in comma)
    37         std::set< std::string > otypeKeys;  /// different type may map to same key
     37        std::set< std::string > otypeKeys; ///< different type may map to same key
    3838
    3939        CandidateFinder(
     
    7070        const ast::Expr * expr, Cost & cost );
    7171
    72 const ast::Expr * getValueEnumCall(const ast::Expr * expr,
    73         const ResolvExpr::ResolveContext & context, const ast::TypeEnvironment & env );
     72/// Get the valueE application that returns the enum's value.
     73const ast::Expr * getValueEnumCall( const ast::Expr * expr,
     74        const ResolveContext & context, const ast::TypeEnvironment & env );
     75
    7476/// Wrap an expression to convert the result to a conditional result.
    7577const ast::Expr * createCondExpr( const ast::Expr * expr );
Note: See TracChangeset for help on using the changeset viewer.