Changeset 4a89b52 for src


Ignore:
Timestamp:
Nov 30, 2023, 2:41:11 PM (6 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
d787828d
Parents:
83fd57d
Message:

Renamed ResolvMode? to ResolveMode?. This is less consistent with the namespace, but is more consistent with almost everything else.

Location:
src
Files:
6 edited
1 moved

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/CandidateFinder.cpp

    r83fd57d r4a89b52  
    105105
    106106                        // CandidateFinder finder{ symtab, env };
    107                         // finder.find( arg, ResolvMode::withAdjustment() );
     107                        // finder.find( arg, ResolveMode::withAdjustment() );
    108108                        // assertf( finder.candidates.size() > 0,
    109109                        //      "Somehow castable expression failed to find alternatives." );
     
    974974                // xxx - is it possible that handleTupleAssignment and main finder both produce candidates?
    975975                // this means there exists ctor/assign functions with a tuple as first parameter.
    976                 ResolvMode mode = {
     976                ResolveMode mode = {
    977977                        true, // adjust
    978978                        !untypedExpr->func.as<ast::NameExpr>(), // prune if not calling by name
     
    989989                CandidateFinder opFinder( context, tenv );
    990990                // okay if there aren't any function operations
    991                 opFinder.find( opExpr, ResolvMode::withoutFailFast() );
     991                opFinder.find( opExpr, ResolveMode::withoutFailFast() );
    992992                PRINT(
    993993                        std::cerr << "known function ops:" << std::endl;
     
    11751175                if ( castExpr->kind == ast::CastExpr::Return ) {
    11761176                        finder.strictMode = true;
    1177                         finder.find( castExpr->arg, ResolvMode::withAdjustment() );
     1177                        finder.find( castExpr->arg, ResolveMode::withAdjustment() );
    11781178
    11791179                        // return casts are eliminated (merely selecting an overload, no actual operation)
    11801180                        candidates = std::move(finder.candidates);
    11811181                }
    1182                 finder.find( castExpr->arg, ResolvMode::withAdjustment() );
     1182                finder.find( castExpr->arg, ResolveMode::withAdjustment() );
    11831183
    11841184                if ( !finder.candidates.empty() ) reason.code = NoMatch;
     
    12511251                CandidateFinder finder( context, tenv );
    12521252                // don't prune here, all alternatives guaranteed to have same type
    1253                 finder.find( castExpr->arg, ResolvMode::withoutPrune() );
     1253                finder.find( castExpr->arg, ResolveMode::withoutPrune() );
    12541254                for ( CandidateRef & r : finder.candidates ) {
    12551255                        addCandidate(
     
    12981298
    12991299                        // don't prune here, since it's guaranteed all alternatives will have the same type
    1300                         finder.find( tech1.get(), ResolvMode::withoutPrune() );
     1300                        finder.find( tech1.get(), ResolveMode::withoutPrune() );
    13011301                        pick_alternatives(finder.candidates, false);
    13021302
     
    13071307                std::unique_ptr<const ast::Expr> fallback { ast::UntypedExpr::createDeref(loc,  new ast::UntypedExpr(loc, new ast::NameExpr(loc, castExpr->concrete_target.getter), { castExpr->arg })) };
    13081308                // don't prune here, since it's guaranteed all alternatives will have the same type
    1309                 finder.find( fallback.get(), ResolvMode::withoutPrune() );
     1309                finder.find( fallback.get(), ResolveMode::withoutPrune() );
    13101310
    13111311                pick_alternatives(finder.candidates, true);
     
    13161316        void Finder::postvisit( const ast::UntypedMemberExpr * memberExpr ) {
    13171317                CandidateFinder aggFinder( context, tenv );
    1318                 aggFinder.find( memberExpr->aggregate, ResolvMode::withAdjustment() );
     1318                aggFinder.find( memberExpr->aggregate, ResolveMode::withAdjustment() );
    13191319                for ( CandidateRef & agg : aggFinder.candidates ) {
    13201320                        // it's okay for the aggregate expression to have reference type -- cast it to the
     
    14751475        void Finder::postvisit( const ast::LogicalExpr * logicalExpr ) {
    14761476                CandidateFinder finder1( context, tenv );
    1477                 finder1.find( logicalExpr->arg1, ResolvMode::withAdjustment() );
     1477                finder1.find( logicalExpr->arg1, ResolveMode::withAdjustment() );
    14781478                if ( finder1.candidates.empty() ) return;
    14791479
    14801480                CandidateFinder finder2( context, tenv );
    1481                 finder2.find( logicalExpr->arg2, ResolvMode::withAdjustment() );
     1481                finder2.find( logicalExpr->arg2, ResolveMode::withAdjustment() );
    14821482                if ( finder2.candidates.empty() ) return;
    14831483
     
    15051505                // candidates for condition
    15061506                CandidateFinder finder1( context, tenv );
    1507                 finder1.find( conditionalExpr->arg1, ResolvMode::withAdjustment() );
     1507                finder1.find( conditionalExpr->arg1, ResolveMode::withAdjustment() );
    15081508                if ( finder1.candidates.empty() ) return;
    15091509
     
    15111511                CandidateFinder finder2( context, tenv );
    15121512                finder2.allowVoid = true;
    1513                 finder2.find( conditionalExpr->arg2, ResolvMode::withAdjustment() );
     1513                finder2.find( conditionalExpr->arg2, ResolveMode::withAdjustment() );
    15141514                if ( finder2.candidates.empty() ) return;
    15151515
     
    15171517                CandidateFinder finder3( context, tenv );
    15181518                finder3.allowVoid = true;
    1519                 finder3.find( conditionalExpr->arg3, ResolvMode::withAdjustment() );
     1519                finder3.find( conditionalExpr->arg3, ResolveMode::withAdjustment() );
    15201520                if ( finder3.candidates.empty() ) return;
    15211521
     
    15701570
    15711571                CandidateFinder finder2( context, env );
    1572                 finder2.find( commaExpr->arg2, ResolvMode::withAdjustment() );
     1572                finder2.find( commaExpr->arg2, ResolveMode::withAdjustment() );
    15731573
    15741574                for ( const CandidateRef & r2 : finder2.candidates ) {
     
    15841584                CandidateFinder finder( context, tenv );
    15851585                finder.allowVoid = true;
    1586                 finder.find( ctorExpr->callExpr, ResolvMode::withoutPrune() );
     1586                finder.find( ctorExpr->callExpr, ResolveMode::withoutPrune() );
    15871587                for ( CandidateRef & r : finder.candidates ) {
    15881588                        addCandidate( *r, new ast::ConstructorExpr{ ctorExpr->location, r->expr } );
     
    15931593                // resolve low and high, accept candidates where low and high types unify
    15941594                CandidateFinder finder1( context, tenv );
    1595                 finder1.find( rangeExpr->low, ResolvMode::withAdjustment() );
     1595                finder1.find( rangeExpr->low, ResolveMode::withAdjustment() );
    15961596                if ( finder1.candidates.empty() ) return;
    15971597
    15981598                CandidateFinder finder2( context, tenv );
    1599                 finder2.find( rangeExpr->high, ResolvMode::withAdjustment() );
     1599                finder2.find( rangeExpr->high, ResolveMode::withAdjustment() );
    16001600                if ( finder2.candidates.empty() ) return;
    16011601
     
    16731673        void Finder::postvisit( const ast::UniqueExpr * unqExpr ) {
    16741674                CandidateFinder finder( context, tenv );
    1675                 finder.find( unqExpr->expr, ResolvMode::withAdjustment() );
     1675                finder.find( unqExpr->expr, ResolveMode::withAdjustment() );
    16761676                for ( CandidateRef & r : finder.candidates ) {
    16771677                        // ensure that the the id is passed on so that the expressions are "linked"
     
    16991699                        // only open for the duration of resolving the UntypedExpr.
    17001700                        CandidateFinder finder( context, tenv, toType );
    1701                         finder.find( initExpr->expr, ResolvMode::withAdjustment() );
     1701                        finder.find( initExpr->expr, ResolveMode::withAdjustment() );
    17021702
    17031703                        Cost minExprCost = Cost::infinity;
     
    18891889}
    18901890
    1891 void CandidateFinder::find( const ast::Expr * expr, ResolvMode mode ) {
     1891void CandidateFinder::find( const ast::Expr * expr, ResolveMode mode ) {
    18921892        // Find alternatives for expression
    18931893        ast::Pass<Finder> finder{ *this };
     
    20042004        for ( const auto & x : xs ) {
    20052005                out.emplace_back( context, env );
    2006                 out.back().find( x, ResolvMode::withAdjustment() );
     2006                out.back().find( x, ResolveMode::withAdjustment() );
    20072007
    20082008                PRINT(
  • src/ResolvExpr/CandidateFinder.hpp

    r83fd57d r4a89b52  
    1717
    1818#include "Candidate.hpp"
    19 #include "ResolvMode.h"
     19#include "ResolveMode.hpp"
    2020#include "AST/Fwd.hpp"
    2121#include "AST/Node.hpp"
     
    4343
    4444        /// Fill candidates with feasible resolutions for `expr`
    45         void find( const ast::Expr * expr, ResolvMode mode = {} );
     45        void find( const ast::Expr * expr, ResolveMode mode = {} );
    4646        bool pruneCandidates( CandidateList & candidates, CandidateList & out, std::vector<std::string> & errors );
    4747
  • src/ResolvExpr/CandidatePrinter.cpp

    r83fd57d r4a89b52  
    1616#include "CandidatePrinter.hpp"
    1717
     18#include <iostream>
     19
    1820#include "AST/Expr.hpp"
    1921#include "AST/Pass.hpp"
     
    2325#include "ResolvExpr/CandidateFinder.hpp"
    2426#include "ResolvExpr/Resolver.h"
    25 
    26 #include <iostream>
    2727
    2828namespace ResolvExpr {
     
    3939                ast::TypeEnvironment env;
    4040                CandidateFinder finder( { symtab, transUnit().global }, env );
    41                 finder.find( stmt->expr, ResolvMode::withAdjustment() );
     41                finder.find( stmt->expr, ResolveMode::withAdjustment() );
    4242                int count = 1;
    4343                os << "There are " << finder.candidates.size() << " candidates\n";
  • src/ResolvExpr/ResolveMode.hpp

    r83fd57d r4a89b52  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // ResolvMode.h --
     7// ResolveMode.hpp --
    88//
    99// Author           : Aaron B. Moss
     
    1919
    2020/// Flag set for resolution
    21 struct ResolvMode {
     21struct ResolveMode {
    2222        const bool adjust;                       ///< Adjust array and function types to pointer types? [false]
    2323        const bool prune;            ///< Prune alternatives to min-cost per return type? [true]
    2424        const bool failFast;         ///< Fail on no resulting alternatives? [true]
    2525
    26         constexpr ResolvMode(bool a, bool p, bool ff)
     26        constexpr ResolveMode(bool a, bool p, bool ff)
    2727        : adjust(a), prune(p), failFast(ff) {}
    2828
    2929        /// Default settings
    30         constexpr ResolvMode() : adjust(false), prune(true), failFast(true) {}
     30        constexpr ResolveMode() : adjust(false), prune(true), failFast(true) {}
    3131
    3232        /// With adjust flag set; turns array and function types into equivalent pointers
    33         static constexpr ResolvMode withAdjustment() { return { true, true, true }; }
     33        static constexpr ResolveMode withAdjustment() { return { true, true, true }; }
    3434
    3535        /// With adjust flag set but prune unset; pruning ensures there is at least one alternative
    3636        /// per result type
    37         static constexpr ResolvMode withoutPrune() { return { true, false, true }; }
     37        static constexpr ResolveMode withoutPrune() { return { true, false, true }; }
    3838
    3939        /// With adjust and prune flags set but failFast unset; failFast ensures there is at least
    4040        /// one resulting alternative
    41         static constexpr ResolvMode withoutFailFast() { return { true, true, false }; }
     41        static constexpr ResolveMode withoutFailFast() { return { true, true, false }; }
    4242
    4343        /// The same mode, but with satisfyAssns turned on; for top-level calls
    44         ResolvMode atTopLevel() const { return { adjust, true, failFast }; }
     44        ResolveMode atTopLevel() const { return { adjust, true, failFast }; }
    4545};
    4646
  • src/ResolvExpr/Resolver.cc

    r83fd57d r4a89b52  
    2525#include "Resolver.h"
    2626#include "ResolveTypeof.h"
    27 #include "ResolvMode.h"                  // for ResolvMode
     27#include "ResolveMode.hpp"               // for ResolveMode
    2828#include "typeops.h"                     // for extractResultType
    2929#include "Unify.h"                       // for unify
     
    123123                CandidateRef findUnfinishedKindExpression(
    124124                        const ast::Expr * untyped, const ResolveContext & context, const std::string & kind,
    125                         std::function<bool(const Candidate &)> pred = anyCandidate, ResolvMode mode = {}
     125                        std::function<bool(const Candidate &)> pred = anyCandidate, ResolveMode mode = {}
    126126                ) {
    127127                        if ( ! untyped ) return nullptr;
     
    263263                ast::ptr< ast::CastExpr > untyped = new ast::CastExpr{ expr };
    264264                CandidateRef choice = findUnfinishedKindExpression(
    265                         untyped, context, "", anyCandidate, ResolvMode::withAdjustment() );
     265                        untyped, context, "", anyCandidate, ResolveMode::withAdjustment() );
    266266
    267267                // a cast expression has either 0 or 1 interpretations (by language rules);
     
    292292                        const ast::Expr * untyped, const ResolveContext & context,
    293293                        std::function<bool(const Candidate &)> pred = anyCandidate,
    294                         const std::string & kind = "", ResolvMode mode = {}
     294                        const std::string & kind = "", ResolveMode mode = {}
    295295                ) {
    296296                        if ( ! untyped ) return {};
     
    860860
    861861                        // Find all candidates for a function in canonical form
    862                         funcFinder.find( clause.target, ResolvMode::withAdjustment() );
     862                        funcFinder.find( clause.target, ResolveMode::withAdjustment() );
    863863
    864864                        if ( funcFinder.candidates.empty() ) {
  • src/ResolvExpr/module.mk

    r83fd57d r4a89b52  
    4747      ResolvExpr/ResolveTypeof.cc \
    4848      ResolvExpr/ResolveTypeof.h \
    49       ResolvExpr/ResolvMode.h \
     49      ResolvExpr/ResolveMode.hpp \
    5050      ResolvExpr/SatisfyAssertions.cpp \
    5151      ResolvExpr/SatisfyAssertions.hpp \
  • src/Tuples/TupleAssignment.cc

    r83fd57d r4a89b52  
    1313// Update Count     : 10
    1414//
     15
     16#include "Tuples.h"
    1517
    1618#include <algorithm>                       // for transform
     
    224226                                // by the cast type as needed, and transfer the resulting environment.
    225227                                ResolvExpr::CandidateFinder finder( spotter.crntFinder.context, env );
    226                                 finder.find( rhsCand->expr, ResolvExpr::ResolvMode::withAdjustment() );
     228                                finder.find( rhsCand->expr, ResolvExpr::ResolveMode::withAdjustment() );
    227229                                assert( 1 == finder.candidates.size() );
    228230                                env = std::move( finder.candidates.front()->env );
     
    345347
    346348                        try {
    347                                 finder.find( expr, ResolvExpr::ResolvMode::withAdjustment() );
     349                                finder.find( expr, ResolvExpr::ResolveMode::withAdjustment() );
    348350                        } catch (...) {
    349351                                // No match is not failure, just that this tuple assignment is invalid.
Note: See TracChangeset for help on using the changeset viewer.