Changeset 60c5b6d


Ignore:
Timestamp:
Apr 18, 2024, 12:12:25 PM (13 days ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
7a780ad, d4264e8
Parents:
fbe3f03 (diff), 8fd53b6e (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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Type.hpp

    rfbe3f03 r60c5b6d  
    430430        TypeInstType( const TypeInstType & o ) = default;
    431431
    432         TypeInstType( const TypeEnvKey & key );
     432        explicit TypeInstType( const TypeEnvKey & key );
    433433
    434434        /// sets `base`, updating `kind` correctly
  • src/ResolvExpr/CandidateFinder.cpp

    rfbe3f03 r60c5b6d  
    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

    rfbe3f03 r60c5b6d  
    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 );
  • src/Tuples/TupleAssignment.cc

    rfbe3f03 r60c5b6d  
    3535#include "InitTweak/GenInit.h"             // for genCtorInit
    3636#include "InitTweak/InitTweak.h"           // for getPointerBase, isAssignment
     37#include "ResolvExpr/CandidateFinder.hpp"  // for CandidateFinder
    3738#include "ResolvExpr/Cost.h"               // for Cost
    3839#include "ResolvExpr/Resolver.h"           // for resolveCtorInit
  • src/Tuples/Tuples.h

    rfbe3f03 r60c5b6d  
    2121#include "AST/Fwd.hpp"
    2222#include "AST/Node.hpp"
    23 #include "ResolvExpr/CandidateFinder.hpp"
     23namespace ResolvExpr {
     24        class CandidateFinder;
     25}
    2426
    2527namespace Tuples {
Note: See TracChangeset for help on using the changeset viewer.