Changeset 0bd3faf for src/ResolvExpr


Ignore:
Timestamp:
Nov 13, 2023, 1:40:12 PM (2 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
6ea85b22
Parents:
25f2798
Message:

Removed forward declarations missed in the BaseSyntaxNode removal. Removed code and modified names to support two versions of the ast.

Location:
src/ResolvExpr
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AdjustExprType.cc

    r25f2798 r0bd3faf  
    2323
    2424namespace {
    25         class AdjustExprType_new final : public ast::WithShortCircuiting {
     25        class AdjustExprType final : public ast::WithShortCircuiting {
    2626                const ast::SymbolTable & symtab;
    2727        public:
    2828                const ast::TypeEnvironment & tenv;
    2929
    30                 AdjustExprType_new( const ast::TypeEnvironment & e, const ast::SymbolTable & syms )
     30                AdjustExprType( const ast::TypeEnvironment & e, const ast::SymbolTable & syms )
    3131                : symtab( syms ), tenv( e ) {}
    3232
     
    7575        const ast::Type * type, const ast::TypeEnvironment & env, const ast::SymbolTable & symtab
    7676) {
    77         ast::Pass<AdjustExprType_new> adjuster{ env, symtab };
     77        ast::Pass<AdjustExprType> adjuster{ env, symtab };
    7878        return type->accept( adjuster );
    7979}
  • src/ResolvExpr/AdjustExprType.hpp

    r25f2798 r0bd3faf  
    1616#pragma once
    1717
    18 class Type;
    19 namespace SymTab {
    20         class Indexer;
    21 }
    2218namespace ast {
    2319        class SymbolTable;
     
    2723
    2824namespace ResolvExpr {
    29 
    30 class TypeEnvironment;
    31 
    32 /// Replaces array types with the equivalent pointer, and function types with a pointer-to-function
    33 void adjustExprType( Type *& type, const TypeEnvironment & env, const SymTab::Indexer & indexer );
    34 
    35 /// Replaces array types with the equivalent pointer, and function types with a pointer-to-function using empty TypeEnvironment and Indexer.
    36 void adjustExprType( Type *& type );
    37 
    38 template< typename ForwardIterator >
    39 void adjustExprTypeList( ForwardIterator begin, ForwardIterator end, const TypeEnvironment & env, const SymTab::Indexer & indexer ) {
    40         while ( begin != end ) {
    41                 adjustExprType( *begin++, env, indexer );
    42         } // while
    43 }
    4425
    4526/// Replaces array types with equivalent pointer,
  • src/ResolvExpr/CandidateFinder.cpp

    r25f2798 r0bd3faf  
    6161namespace {
    6262        /// First index is which argument, second is which alternative, third is which exploded element
    63         using ExplodedArgs_new = std::deque< std::vector< ExplodedArg > >;
     63        using ExplodedArgs = std::deque< std::vector< ExplodedArg > >;
    6464
    6565        /// Returns a list of alternatives with the minimum cost in the given list
     
    255255
    256256                /// Gets the list of exploded candidates for this pack
    257                 const ExplodedArg & getExpl( const ExplodedArgs_new & args ) const {
     257                const ExplodedArg & getExpl( const ExplodedArgs & args ) const {
    258258                        return args[ nextArg-1 ][ explAlt ];
    259259                }
     
    281281        bool instantiateArgument(
    282282                const CodeLocation & location,
    283                 const ast::Type * paramType, const ast::Init * init, const ExplodedArgs_new & args,
     283                const ast::Type * paramType, const ast::Init * init, const ExplodedArgs & args,
    284284                std::vector< ArgPack > & results, std::size_t & genStart, const ast::SymbolTable & symtab,
    285285                unsigned nTuples = 0
     
    618618                        const CodeLocation & location,
    619619                        const CandidateRef & func, const ast::FunctionType * funcType,
    620                         const ExplodedArgs_new & args, CandidateList & out );
     620                        const ExplodedArgs & args, CandidateList & out );
    621621
    622622                /// Adds implicit struct-conversions to the alternative list
     
    737737                const CodeLocation & location,
    738738                const CandidateRef & func, const ast::FunctionType * funcType,
    739                 const ExplodedArgs_new & args, CandidateList & out
     739                const ExplodedArgs & args, CandidateList & out
    740740        ) {
    741741                ast::OpenVarSet funcOpen;
     
    997997
    998998                // pre-explode arguments
    999                 ExplodedArgs_new argExpansions;
     999                ExplodedArgs argExpansions;
    10001000                for ( const CandidateFinder & args : argCandidates ) {
    10011001                        argExpansions.emplace_back();
  • src/ResolvExpr/CastCost.cc

    r25f2798 r0bd3faf  
    2626#include "ResolvExpr/ConversionCost.h"   // for conversionCost
    2727#include "ResolvExpr/PtrsCastable.hpp"   // for ptrsCastable
    28 #include "ResolvExpr/typeops.h"          // for ptrsCastable
    2928#include "ResolvExpr/Unify.h"            // for typesCompatibleIgnoreQualifiers
    3029
     
    3837
    3938namespace {
    40         struct CastCost_new : public ConversionCost_new {
    41                 using ConversionCost_new::previsit;
    42                 using ConversionCost_new::postvisit;
     39        struct CastCost : public ConversionCost {
     40                using ConversionCost::previsit;
     41                using ConversionCost::postvisit;
    4342
    44                 CastCost_new(
     43                CastCost(
    4544                        const ast::Type * dst, bool srcIsLvalue, const ast::SymbolTable & symtab,
    4645                        const ast::TypeEnvironment & env, CostCalculation costFunc )
    47                 : ConversionCost_new( dst, srcIsLvalue, symtab, env, costFunc ) {}
     46                : ConversionCost( dst, srcIsLvalue, symtab, env, costFunc ) {}
    4847
    4948                void postvisit( const ast::BasicType * basicType ) {
     
    8584        };
    8685
    87         #warning For overload resolution between the two versions.
    88         int localPtrsCastable(const ast::Type * t1, const ast::Type * t2,
    89                         const ast::SymbolTable & symtab, const ast::TypeEnvironment & env ) {
    90                 return ptrsCastable( t1, t2, symtab, env );
    91         }
    92         Cost localCastCost(
    93                 const ast::Type * src, const ast::Type * dst, bool srcIsLvalue,
    94                 const ast::SymbolTable & symtab, const ast::TypeEnvironment & env
    95         ) { return castCost( src, dst, srcIsLvalue, symtab, env ); }
    9686} // anonymous namespace
    9787
     
    136126        } else if ( auto refType = dynamic_cast< const ast::ReferenceType * >( dst ) ) {
    137127                PRINT( std::cerr << "conversionCost: dest is reference" << std::endl; )
    138                 #warning cast on ptrsCastable artifact of having two functions, remove when port done
    139128                return convertToReferenceCost(
    140                         src, refType, srcIsLvalue, symtab, env, localPtrsCastable );
     129                        src, refType, srcIsLvalue, symtab, env, ptrsCastable );
    141130        } else {
    142                 #warning cast on castCost artifact of having two functions, remove when port done
    143                 ast::Pass< CastCost_new > converter(
    144                         dst, srcIsLvalue, symtab, env, localCastCost );
     131                ast::Pass< CastCost > converter(
     132                        dst, srcIsLvalue, symtab, env, castCost );
    145133                src->accept( converter );
    146134                return converter.core.cost;
  • src/ResolvExpr/CastCost.hpp

    r25f2798 r0bd3faf  
    1818#include "ResolvExpr/Cost.h"     // for Cost
    1919
    20 class Type;
    21 namespace SymTab {
    22         class Indexer;
    23 }
    2420namespace ast {
    2521        class SymbolTable;
     
    3026namespace ResolvExpr {
    3127
    32 class TypeEnvironment;
    33 
    34 Cost castCost(
    35         const Type * src, const Type * dest, bool srcIsLvalue,
    36         const SymTab::Indexer & indexer, const TypeEnvironment & env );
    3728Cost castCost(
    3829        const ast::Type * src, const ast::Type * dst, bool srcIsLvalue,
  • src/ResolvExpr/CommonType.cc

    r25f2798 r0bd3faf  
    343343        );
    344344
    345         class CommonType_new final : public ast::WithShortCircuiting {
     345        class CommonType final : public ast::WithShortCircuiting {
    346346                const ast::Type * type2;
    347347                WidenMode widen;
     
    354354                ast::ptr< ast::Type > result;
    355355
    356                 CommonType_new(
     356                CommonType(
    357357                        const ast::Type * t2, WidenMode w,
    358358                        ast::TypeEnvironment & env, const ast::OpenVarSet & o,
     
    388388                                        result = enumDecl->base.get();
    389389                                } else {
    390                                         #warning remove casts when `commonTypes` moved to new AST
    391390                                        ast::BasicType::Kind kind = commonTypes[ basic->kind ][ ast::BasicType::SignedInt ];
    392391                                        if (
     
    739738        };
    740739
    741         // size_t CommonType_new::traceId = Stats::Heap::new_stacktrace_id("CommonType_new");
     740        // size_t CommonType::traceId = Stats::Heap::new_stacktrace_id("CommonType");
    742741        namespace {
    743742                ast::ptr< ast::Type > handleReference(
     
    811810                }
    812811                // otherwise both are reference types of the same depth and this is handled by the visitor
    813                 ast::Pass<CommonType_new> visitor{ type2, widen, env, open, need, have };
     812                ast::Pass<CommonType> visitor{ type2, widen, env, open, need, have };
    814813                type1->accept( visitor );
    815814                // ast::ptr< ast::Type > result = visitor.core.result;
  • src/ResolvExpr/ConversionCost.cc

    r25f2798 r0bd3faf  
    153153
    154154namespace {
    155         # warning For overload resolution between the two versions.
    156155        int localPtrsAssignable(const ast::Type * t1, const ast::Type * t2,
    157156                        const ast::SymbolTable &, const ast::TypeEnvironment & env ) {
    158157                return ptrsAssignable( t1, t2, env );
    159158        }
    160         Cost localConversionCost(
    161                 const ast::Type * src, const ast::Type * dst, bool srcIsLvalue,
    162                 const ast::SymbolTable & symtab, const ast::TypeEnvironment & env
    163         ) { return conversionCost( src, dst, srcIsLvalue, symtab, env ); }
    164159}
    165160
     
    191186                return convertToReferenceCost( src, refType, srcIsLvalue, symtab, env, localPtrsAssignable );
    192187        } else {
    193                 return ast::Pass<ConversionCost_new>::read( src, dst, srcIsLvalue, symtab, env, localConversionCost );
     188                return ast::Pass<ConversionCost>::read( src, dst, srcIsLvalue, symtab, env, conversionCost );
    194189        }
    195190}
     
    232227                        }
    233228                } else {
    234                         return ast::Pass<ConversionCost_new>::read( src, dst, srcIsLvalue, symtab, env, localConversionCost );
     229                        return ast::Pass<ConversionCost>::read( src, dst, srcIsLvalue, symtab, env, conversionCost );
    235230                }
    236231        } else {
     
    264259}
    265260
    266 void ConversionCost_new::postvisit( const ast::VoidType * voidType ) {
     261void ConversionCost::postvisit( const ast::VoidType * voidType ) {
    267262        (void)voidType;
    268263        cost = Cost::infinity;
    269264}
    270265
    271 void ConversionCost_new::conversionCostFromBasicToBasic( const ast::BasicType * src, const ast::BasicType* dest ) {
     266void ConversionCost::conversionCostFromBasicToBasic( const ast::BasicType * src, const ast::BasicType* dest ) {
    272267        int tableResult = costMatrix[ src->kind ][ dest->kind ];
    273268        if ( tableResult == -1 ) {
     
    280275}
    281276
    282 void ConversionCost_new::postvisit( const ast::BasicType * basicType ) {
     277void ConversionCost::postvisit( const ast::BasicType * basicType ) {
    283278        if ( const ast::BasicType * dstAsBasic = dynamic_cast< const ast::BasicType * >( dst ) ) {
    284279                conversionCostFromBasicToBasic( basicType, dstAsBasic );
     
    286281                const ast::EnumDecl * enumDecl = enumInst->base.get();
    287282                if ( enumDecl->isTyped && !enumDecl->base.get() ) {
    288                         cost = Cost::infinity; 
     283                        cost = Cost::infinity;
    289284                } else if ( const ast::Type * enumType = enumDecl->base.get() ) {
    290285                        if ( const ast::BasicType * enumTypeAsBasic = dynamic_cast<const ast::BasicType *>(enumType) ) {
     
    299294}
    300295
    301 void ConversionCost_new::postvisit( const ast::PointerType * pointerType ) {
     296void ConversionCost::postvisit( const ast::PointerType * pointerType ) {
    302297        if ( const ast::PointerType * dstAsPtr = dynamic_cast< const ast::PointerType * >( dst ) ) {
    303298                ast::CV::Qualifiers tq1 = pointerType->base->qualifiers;
     
    345340}
    346341
    347 void ConversionCost_new::postvisit( const ast::ArrayType * arrayType ) {
     342void ConversionCost::postvisit( const ast::ArrayType * arrayType ) {
    348343        (void)arrayType;
    349344}
    350345
    351 void ConversionCost_new::postvisit( const ast::ReferenceType * refType ) {
     346void ConversionCost::postvisit( const ast::ReferenceType * refType ) {
    352347        assert( nullptr == dynamic_cast< const ast::ReferenceType * >( dst ) );
    353348
     
    367362}
    368363
    369 void ConversionCost_new::postvisit( const ast::FunctionType * functionType ) {
     364void ConversionCost::postvisit( const ast::FunctionType * functionType ) {
    370365        (void)functionType;
    371366}
    372367
    373 void ConversionCost_new::postvisit( const ast::EnumInstType * enumInstType ) {
     368void ConversionCost::postvisit( const ast::EnumInstType * enumInstType ) {
    374369        const ast::EnumDecl * baseEnum = enumInstType->base;
    375370        if ( const ast::Type * baseType = baseEnum->base ) {
     
    384379}
    385380
    386 void ConversionCost_new::postvisit( const ast::TraitInstType * traitInstType ) {
     381void ConversionCost::postvisit( const ast::TraitInstType * traitInstType ) {
    387382        (void)traitInstType;
    388383}
    389384
    390 void ConversionCost_new::postvisit( const ast::TypeInstType * typeInstType ) {
     385void ConversionCost::postvisit( const ast::TypeInstType * typeInstType ) {
    391386        if ( const ast::EqvClass * eqv = env.lookup( *typeInstType ) ) {
    392387                cost = costCalc( eqv->bound, dst, srcIsLvalue, symtab, env );
     
    405400}
    406401
    407 void ConversionCost_new::postvisit( const ast::TupleType * tupleType ) {
     402void ConversionCost::postvisit( const ast::TupleType * tupleType ) {
    408403        Cost c = Cost::zero;
    409404        if ( const ast::TupleType * dstAsTuple = dynamic_cast< const ast::TupleType * >( dst ) ) {
     
    427422}
    428423
    429 void ConversionCost_new::postvisit( const ast::VarArgsType * varArgsType ) {
     424void ConversionCost::postvisit( const ast::VarArgsType * varArgsType ) {
    430425        (void)varArgsType;
    431426        if ( dynamic_cast< const ast::VarArgsType * >( dst ) ) {
     
    434429}
    435430
    436 void ConversionCost_new::postvisit( const ast::ZeroType * zeroType ) {
     431void ConversionCost::postvisit( const ast::ZeroType * zeroType ) {
    437432        (void)zeroType;
    438433        if ( dynamic_cast< const ast::ZeroType * >( dst ) ) {
     
    461456}
    462457
    463 void ConversionCost_new::postvisit( const ast::OneType * oneType ) {
     458void ConversionCost::postvisit( const ast::OneType * oneType ) {
    464459        (void)oneType;
    465460        if ( dynamic_cast< const ast::OneType * >( dst ) ) {
    466461                cost = Cost::zero;
    467462        } else if ( const ast::BasicType * dstAsBasic =
    468                         dynamic_cast< const ast::BasicType * >( dst ) ) {               
     463                        dynamic_cast< const ast::BasicType * >( dst ) ) {
    469464                int tableResult = costMatrix[ ast::BasicType::SignedInt ][ dstAsBasic->kind ];
    470465                if ( -1 == tableResult ) {
     
    475470                        cost.incSign( signMatrix[ ast::BasicType::SignedInt ][ dstAsBasic->kind ] );
    476471                }
    477                
    478                 // cost = Cost::zero;
    479         }
    480 }
    481 // size_t ConversionCost_new::traceId = Stats::Heap::new_stacktrace_id("ConversionCost");
     472        }
     473}
     474
     475// size_t ConversionCost::traceId = Stats::Heap::new_stacktrace_id("ConversionCost");
    482476
    483477} // namespace ResolvExpr
  • src/ResolvExpr/ConversionCost.h

    r25f2798 r0bd3faf  
    2323#include "AST/Pass.hpp"       // for WithShortCircuiting
    2424
    25 namespace SymTab {
    26         class Indexer;
    27 }  // namespace SymTab
    28 
    2925namespace ResolvExpr {
    30         class TypeEnvironment;
    3126
    3227// Some function pointer types, differ in return type.
     
    4439        PtrsCalculation func );
    4540
    46 #warning when the old ConversionCost is removed, get ride of the _new suffix.
    47 class ConversionCost_new : public ast::WithShortCircuiting {
     41class ConversionCost : public ast::WithShortCircuiting {
    4842protected:
    4943        const ast::Type * dst;
     
    5751        Cost result() { return cost; }
    5852
    59         ConversionCost_new( const ast::Type * dst, bool srcIsLvalue, const ast::SymbolTable & symtab,
     53        ConversionCost( const ast::Type * dst, bool srcIsLvalue, const ast::SymbolTable & symtab,
    6054                        const ast::TypeEnvironment & env, CostCalculation costCalc ) :
    6155                dst( dst ), srcIsLvalue( srcIsLvalue ), symtab( symtab ), env( env ),
  • src/ResolvExpr/FindOpenVars.cc

    r25f2798 r0bd3faf  
    2525
    2626        namespace {
    27                 struct FindOpenVars_new final : public ast::WithGuards {
     27                struct FindOpenVars final : public ast::WithGuards {
    2828                        ast::OpenVarSet & open;
    2929                        ast::OpenVarSet & closed;
     
    3333                        bool nextIsOpen;
    3434
    35                         FindOpenVars_new(
     35                        FindOpenVars(
    3636                                ast::OpenVarSet & o, ast::OpenVarSet & c, ast::AssertionSet & n,
    3737                                ast::AssertionSet & h, ast::TypeEnvironment & env, FirstMode firstIsOpen )
     
    7373                        const ast::Type * type, ast::OpenVarSet & open, ast::OpenVarSet & closed,
    7474                        ast::AssertionSet & need, ast::AssertionSet & have, ast::TypeEnvironment & env, FirstMode firstIsOpen ) {
    75                 ast::Pass< FindOpenVars_new > finder{ open, closed, need, have, env, firstIsOpen };
     75                ast::Pass< FindOpenVars > finder{ open, closed, need, have, env, firstIsOpen };
    7676                type->accept( finder );
    7777
  • src/ResolvExpr/PolyCost.cc

    r25f2798 r0bd3faf  
    2121namespace ResolvExpr {
    2222
    23 // TODO: When the old PolyCost is torn out get rid of the _new suffix.
    24 class PolyCost_new {
     23class PolyCost {
    2524        const ast::SymbolTable &symtab;
    2625public:
     
    2827        const ast::TypeEnvironment &env_;
    2928
    30         PolyCost_new( const ast::SymbolTable & symtab, const ast::TypeEnvironment & env )
     29        PolyCost( const ast::SymbolTable & symtab, const ast::TypeEnvironment & env )
    3130        : symtab( symtab ), result( 0 ), env_( env ) {}
    3231
     
    4948        const ast::Type * type, const ast::SymbolTable & symtab, const ast::TypeEnvironment & env
    5049) {
    51         ast::Pass<PolyCost_new> costing( symtab, env );
     50        ast::Pass<PolyCost> costing( symtab, env );
    5251        type->accept( costing );
    5352        return (costing.core.result > 0) ? 1 : 0;
  • src/ResolvExpr/PolyCost.hpp

    r25f2798 r0bd3faf  
    1616#pragma once
    1717
    18 class Type;
    19 namespace SymTab {
    20     class Indexer;
    21 }
    2218namespace ast {
    2319    class SymbolTable;
     
    2824namespace ResolvExpr {
    2925
    30 class TypeEnvironment;
    31 
    32 int polyCost( Type * type,
    33         const TypeEnvironment & env, const SymTab::Indexer & indexer );
    3426int polyCost( const ast::Type * type,
    3527        const ast::SymbolTable & symtab, const ast::TypeEnvironment & env );
  • src/ResolvExpr/PtrsAssignable.cc

    r25f2798 r0bd3faf  
    2222namespace ResolvExpr {
    2323
    24 // TODO: Get rid of the `_new` suffix when the old version is removed.
    25 struct PtrsAssignable_new : public ast::WithShortCircuiting {
     24struct PtrsAssignable : public ast::WithShortCircuiting {
    2625        const ast::Type * dst;
    2726        const ast::TypeEnvironment & typeEnv;
    2827        int result;
    2928
    30         PtrsAssignable_new( const ast::Type * dst, const ast::TypeEnvironment & env ) :
     29        PtrsAssignable( const ast::Type * dst, const ast::TypeEnvironment & env ) :
    3130                dst( dst ), typeEnv( env ), result( 0 ) {}
    3231
    33         void previsit( Type * ) { visit_children = false; }
     32        void previsit( ast::Type * ) { visit_children = false; }
    3433
    3534        void postvisit( const ast::EnumInstType * ) {
     
    6362                return -1;
    6463        } else {
    65                 ast::Pass<PtrsAssignable_new> visitor( dst, env );
     64                ast::Pass<PtrsAssignable> visitor( dst, env );
    6665                src->accept( visitor );
    6766                return visitor.core.result;
  • src/ResolvExpr/PtrsAssignable.hpp

    r25f2798 r0bd3faf  
    1616#pragma once
    1717
    18 class Type;
    1918namespace ast {
    2019        class Type;
     
    2423namespace ResolvExpr {
    2524
    26 class TypeEnvironment;
    27 
    28 int ptrsAssignable( const Type * src, const Type * dest,
    29         const TypeEnvironment & env );
    3025int ptrsAssignable( const ast::Type * src, const ast::Type * dst,
    3126        const ast::TypeEnvironment & env );
  • src/ResolvExpr/PtrsCastable.cc

    r25f2798 r0bd3faf  
    5555        }
    5656
    57         class PtrsCastable_new : public ast::WithShortCircuiting {
     57        class PtrsCastable : public ast::WithShortCircuiting {
    5858                const ast::Type * dst;
    5959                const ast::TypeEnvironment & env;
     
    6262                int result;
    6363
    64                 PtrsCastable_new(
     64                PtrsCastable(
    6565                        const ast::Type * d, const ast::TypeEnvironment & e, const ast::SymbolTable & syms )
    6666                : dst( d ), env( e ), symtab( syms ), result( 0 ) {}
     
    149149                return objectCast( src, env, symtab );
    150150        } else {
    151                 return ast::Pass<PtrsCastable_new>::read( src, dst, env, symtab );
     151                return ast::Pass<PtrsCastable>::read( src, dst, env, symtab );
    152152        }
    153153}
  • src/ResolvExpr/PtrsCastable.hpp

    r25f2798 r0bd3faf  
    1616#pragma once
    1717
    18 class Type;
    19 namespace SymTab {
    20     class Indexer;
    21 }
    2218namespace ast {
    2319    class SymbolTable;
     
    2824namespace ResolvExpr {
    2925
    30 class TypeEnvironment;
    31 
    32 int ptrsCastable(
    33         const Type * src, const Type * dst,
    34         const TypeEnvironment & env, const SymTab::Indexer & indexer );
    3526int ptrsCastable(
    3627        const ast::Type * src, const ast::Type * dst,
  • src/ResolvExpr/RenameVars.cc

    r25f2798 r0bd3faf  
    101101        RenamingData renaming;
    102102
    103         struct RenameVars_new : public ast::PureVisitor /*: public ast::WithForallSubstitutor*/ {
     103        struct RenameVars final : public ast::PureVisitor /*: public ast::WithForallSubstitutor*/ {
    104104                RenameMode mode;
    105105
     
    132132
    133133const ast::Type * renameTyVars( const ast::Type * t, RenameMode mode, bool reset ) {
    134         ast::Pass<RenameVars_new> renamer;
     134        ast::Pass<RenameVars> renamer;
    135135        renamer.core.mode = mode;
    136136        if (mode == GEN_USAGE && reset) {
  • src/ResolvExpr/ResolveTypeof.cc

    r25f2798 r0bd3faf  
    3333
    3434namespace {
    35 struct ResolveTypeof_new : public ast::WithShortCircuiting {
     35struct ResolveTypeof : public ast::WithShortCircuiting {
    3636    const ResolveContext & context;
    3737
    38                 ResolveTypeof_new( const ResolveContext & context ) :
     38                ResolveTypeof( const ResolveContext & context ) :
    3939                        context( context ) {}
    4040
     
    7878
    7979const ast::Type * resolveTypeof( const ast::Type * type , const ResolveContext & context ) {
    80         ast::Pass< ResolveTypeof_new > mutator( context );
     80        ast::Pass< ResolveTypeof > mutator( context );
    8181        return type->accept( mutator );
    8282}
  • src/ResolvExpr/ResolveTypeof.h

    r25f2798 r0bd3faf  
    1616#pragma once
    1717
    18 class Type;
    19 namespace SymTab {
    20 class Indexer;
    21 }  // namespace SymTab
    2218namespace ast {
    2319        class Type;
     
    2824        struct ResolveContext;
    2925
    30         Type *resolveTypeof( Type*, const SymTab::Indexer &indexer );
    3126        const ast::Type * resolveTypeof( const ast::Type *, const ResolveContext & );
    3227        const ast::Type * fixArrayType( const ast::Type *, const ResolveContext & );
    3328        const ast::ObjectDecl * fixObjectType( const ast::ObjectDecl * decl , const ResolveContext & );
    34         const ast::ObjectDecl * fixObjectInit( const ast::ObjectDecl * decl , const ResolveContext &);
     29        const ast::ObjectDecl * fixObjectInit( const ast::ObjectDecl * decl , const ResolveContext & );
    3530} // namespace ResolvExpr
    3631
  • src/ResolvExpr/Resolver.cc

    r25f2798 r0bd3faf  
    6262        namespace {
    6363                /// Finds deleted expressions in an expression tree
    64                 struct DeleteFinder_new final : public ast::WithShortCircuiting, public ast::WithVisitorRef<DeleteFinder_new> {
     64                struct DeleteFinder final : public ast::WithShortCircuiting, public ast::WithVisitorRef<DeleteFinder> {
    6565                        const ast::DeletedExpr * result = nullptr;
    6666
     
    8080                };
    8181
    82                 struct ResolveDesignators_new final : public ast::WithShortCircuiting {
     82                struct ResolveDesignators final : public ast::WithShortCircuiting {
    8383                        ResolveContext& context;
    8484                        bool result = false;
    8585
    86                         ResolveDesignators_new( ResolveContext& _context ): context{_context} {};
     86                        ResolveDesignators( ResolveContext& _context ): context{_context} {};
    8787
    8888                        void previsit( const ast::Node * ) {
     
    113113        /// Check if this expression is or includes a deleted expression
    114114        const ast::DeletedExpr * findDeletedExpr( const ast::Expr * expr ) {
    115                 return ast::Pass<DeleteFinder_new>::read( expr );
     115                return ast::Pass<DeleteFinder>::read( expr );
    116116        }
    117117
     
    203203
    204204                /// Strips extraneous casts out of an expression
    205                 struct StripCasts_new final {
     205                struct StripCasts final {
    206206                        const ast::Expr * postvisit( const ast::CastExpr * castExpr ) {
    207207                                if (
     
    217217
    218218                        static void strip( ast::ptr< ast::Expr > & expr ) {
    219                                 ast::Pass< StripCasts_new > stripper;
     219                                ast::Pass< StripCasts > stripper;
    220220                                expr = expr->accept( stripper );
    221221                        }
     
    251251                        expr.get_and_mutate()->env = std::move( newenv );
    252252                        // remove unncecessary casts
    253                         StripCasts_new::strip( expr );
     253                        StripCasts::strip( expr );
    254254                }
    255255
     
    368368        }
    369369
    370         class Resolver_new final
     370        class Resolver final
    371371        : public ast::WithSymbolTable, public ast::WithGuards,
    372           public ast::WithVisitorRef<Resolver_new>, public ast::WithShortCircuiting,
     372          public ast::WithVisitorRef<Resolver>, public ast::WithShortCircuiting,
    373373          public ast::WithStmtsToAdd<> {
    374374
     
    376376                ast::CurrentObject currentObject;
    377377                // for work previously in GenInit
    378                 static InitTweak::ManagedTypes_new managedTypes;
     378                static InitTweak::ManagedTypes managedTypes;
    379379                ResolveContext context;
    380380
     
    383383        public:
    384384                static size_t traceId;
    385                 Resolver_new( const ast::TranslationGlobal & global ) :
     385                Resolver( const ast::TranslationGlobal & global ) :
    386386                        ast::WithSymbolTable(ast::SymbolTable::ErrorDetection::ValidateOnAdd),
    387387                        context{ symtab, global } {}
    388                 Resolver_new( const ResolveContext & context ) :
     388                Resolver( const ResolveContext & context ) :
    389389                        ast::WithSymbolTable{ context.symtab },
    390390                        context{ symtab, context.global } {}
     
    427427                bool on_error(ast::ptr<ast::Decl> & decl);
    428428        };
    429         // size_t Resolver_new::traceId = Stats::Heap::new_stacktrace_id("Resolver");
    430 
    431         InitTweak::ManagedTypes_new Resolver_new::managedTypes;
     429        // size_t Resolver::traceId = Stats::Heap::new_stacktrace_id("Resolver");
     430
     431        InitTweak::ManagedTypes Resolver::managedTypes;
    432432
    433433        void resolve( ast::TranslationUnit& translationUnit ) {
    434                 ast::Pass< Resolver_new >::run( translationUnit, translationUnit.global );
     434                ast::Pass< Resolver >::run( translationUnit, translationUnit.global );
    435435        }
    436436
     
    439439        ) {
    440440                assert( ctorInit );
    441                 ast::Pass< Resolver_new > resolver( context );
     441                ast::Pass< Resolver > resolver( context );
    442442                return ctorInit->accept( resolver );
    443443        }
     
    447447        ) {
    448448                assert( stmtExpr );
    449                 ast::Pass< Resolver_new > resolver( context );
     449                ast::Pass< Resolver > resolver( context );
    450450                auto ret = mutate(stmtExpr->accept(resolver));
    451451                strict_dynamic_cast< ast::StmtExpr * >( ret )->computeResult();
     
    489489        }
    490490
    491         const ast::FunctionDecl * Resolver_new::previsit( const ast::FunctionDecl * functionDecl ) {
     491        const ast::FunctionDecl * Resolver::previsit( const ast::FunctionDecl * functionDecl ) {
    492492                GuardValue( functionReturn );
    493493
     
    563563        }
    564564
    565         const ast::FunctionDecl * Resolver_new::postvisit( const ast::FunctionDecl * functionDecl ) {
     565        const ast::FunctionDecl * Resolver::postvisit( const ast::FunctionDecl * functionDecl ) {
    566566                // default value expressions have an environment which shouldn't be there and trips up
    567567                // later passes.
     
    591591        }
    592592
    593         const ast::ObjectDecl * Resolver_new::previsit( const ast::ObjectDecl * objectDecl ) {
     593        const ast::ObjectDecl * Resolver::previsit( const ast::ObjectDecl * objectDecl ) {
    594594                // To handle initialization of routine pointers [e.g. int (*fp)(int) = foo()],
    595595                // class-variable `initContext` is changed multiple times because the LHS is analyzed
     
    630630                                        // constructed objects cannot be designated
    631631                                        if ( InitTweak::isDesignated( mutDecl->init ) ) {
    632                                                 ast::Pass<ResolveDesignators_new> res( context );
     632                                                ast::Pass<ResolveDesignators> res( context );
    633633                                                maybe_accept( mutDecl->init.get(), res );
    634634                                                if ( !res.core.result ) {
     
    650650        }
    651651
    652         void Resolver_new::previsit( const ast::AggregateDecl * _aggDecl ) {
     652        void Resolver::previsit( const ast::AggregateDecl * _aggDecl ) {
    653653                auto aggDecl = mutate(_aggDecl);
    654654                assertf(aggDecl == _aggDecl, "type declarations must be unique");
     
    662662        }
    663663
    664         void Resolver_new::previsit( const ast::StructDecl * structDecl ) {
     664        void Resolver::previsit( const ast::StructDecl * structDecl ) {
    665665                previsit(static_cast<const ast::AggregateDecl *>(structDecl));
    666666                managedTypes.handleStruct(structDecl);
    667667        }
    668668
    669         void Resolver_new::previsit( const ast::EnumDecl * ) {
     669        void Resolver::previsit( const ast::EnumDecl * ) {
    670670                // in case we decide to allow nested enums
    671671                GuardValue( inEnumDecl );
     
    674674        }
    675675
    676         const ast::StaticAssertDecl * Resolver_new::previsit(
     676        const ast::StaticAssertDecl * Resolver::previsit(
    677677                const ast::StaticAssertDecl * assertDecl
    678678        ) {
     
    694694        }
    695695
    696         const ast::ArrayType * Resolver_new::previsit( const ast::ArrayType * at ) {
     696        const ast::ArrayType * Resolver::previsit( const ast::ArrayType * at ) {
    697697                return handlePtrType( at, context );
    698698        }
    699699
    700         const ast::PointerType * Resolver_new::previsit( const ast::PointerType * pt ) {
     700        const ast::PointerType * Resolver::previsit( const ast::PointerType * pt ) {
    701701                return handlePtrType( pt, context );
    702702        }
    703703
    704         const ast::ExprStmt * Resolver_new::previsit( const ast::ExprStmt * exprStmt ) {
     704        const ast::ExprStmt * Resolver::previsit( const ast::ExprStmt * exprStmt ) {
    705705                visit_children = false;
    706706                assertf( exprStmt->expr, "ExprStmt has null expression in resolver" );
     
    710710        }
    711711
    712         const ast::AsmExpr * Resolver_new::previsit( const ast::AsmExpr * asmExpr ) {
     712        const ast::AsmExpr * Resolver::previsit( const ast::AsmExpr * asmExpr ) {
    713713                visit_children = false;
    714714
     
    719719        }
    720720
    721         const ast::AsmStmt * Resolver_new::previsit( const ast::AsmStmt * asmStmt ) {
     721        const ast::AsmStmt * Resolver::previsit( const ast::AsmStmt * asmStmt ) {
    722722                visitor->maybe_accept( asmStmt, &ast::AsmStmt::input );
    723723                visitor->maybe_accept( asmStmt, &ast::AsmStmt::output );
     
    726726        }
    727727
    728         const ast::IfStmt * Resolver_new::previsit( const ast::IfStmt * ifStmt ) {
     728        const ast::IfStmt * Resolver::previsit( const ast::IfStmt * ifStmt ) {
    729729                return ast::mutate_field(
    730730                        ifStmt, &ast::IfStmt::cond, findIntegralExpression( ifStmt->cond, context ) );
    731731        }
    732732
    733         const ast::WhileDoStmt * Resolver_new::previsit( const ast::WhileDoStmt * whileDoStmt ) {
     733        const ast::WhileDoStmt * Resolver::previsit( const ast::WhileDoStmt * whileDoStmt ) {
    734734                return ast::mutate_field(
    735735                        whileDoStmt, &ast::WhileDoStmt::cond, findIntegralExpression( whileDoStmt->cond, context ) );
    736736        }
    737737
    738         const ast::ForStmt * Resolver_new::previsit( const ast::ForStmt * forStmt ) {
     738        const ast::ForStmt * Resolver::previsit( const ast::ForStmt * forStmt ) {
    739739                if ( forStmt->cond ) {
    740740                        forStmt = ast::mutate_field(
     
    750750        }
    751751
    752         const ast::SwitchStmt * Resolver_new::previsit( const ast::SwitchStmt * switchStmt ) {
     752        const ast::SwitchStmt * Resolver::previsit( const ast::SwitchStmt * switchStmt ) {
    753753                GuardValue( currentObject );
    754754                switchStmt = ast::mutate_field(
     
    759759        }
    760760
    761         const ast::CaseClause * Resolver_new::previsit( const ast::CaseClause * caseStmt ) {
     761        const ast::CaseClause * Resolver::previsit( const ast::CaseClause * caseStmt ) {
    762762                if ( caseStmt->cond ) {
    763763                        std::deque< ast::InitAlternative > initAlts = currentObject.getOptions();
     
    780780        }
    781781
    782         const ast::BranchStmt * Resolver_new::previsit( const ast::BranchStmt * branchStmt ) {
     782        const ast::BranchStmt * Resolver::previsit( const ast::BranchStmt * branchStmt ) {
    783783                visit_children = false;
    784784                // must resolve the argument of a computed goto
     
    793793        }
    794794
    795         const ast::ReturnStmt * Resolver_new::previsit( const ast::ReturnStmt * returnStmt ) {
     795        const ast::ReturnStmt * Resolver::previsit( const ast::ReturnStmt * returnStmt ) {
    796796                visit_children = false;
    797797                if ( returnStmt->expr ) {
     
    803803        }
    804804
    805         const ast::ThrowStmt * Resolver_new::previsit( const ast::ThrowStmt * throwStmt ) {
     805        const ast::ThrowStmt * Resolver::previsit( const ast::ThrowStmt * throwStmt ) {
    806806                visit_children = false;
    807807                if ( throwStmt->expr ) {
     
    818818        }
    819819
    820         const ast::CatchClause * Resolver_new::previsit( const ast::CatchClause * catchClause ) {
     820        const ast::CatchClause * Resolver::previsit( const ast::CatchClause * catchClause ) {
    821821                // Until we are very sure this invarent (ifs that move between passes have then)
    822822                // holds, check it. This allows a check for when to decode the mangling.
     
    834834        }
    835835
    836         const ast::CatchClause * Resolver_new::postvisit( const ast::CatchClause * catchClause ) {
     836        const ast::CatchClause * Resolver::postvisit( const ast::CatchClause * catchClause ) {
    837837                // Decode the catchStmt so everything is stored properly.
    838838                const ast::IfStmt * ifStmt = catchClause->body.as<ast::IfStmt>();
     
    849849        }
    850850
    851         const ast::WaitForStmt * Resolver_new::previsit( const ast::WaitForStmt * stmt ) {
     851        const ast::WaitForStmt * Resolver::previsit( const ast::WaitForStmt * stmt ) {
    852852                visit_children = false;
    853853
     
    11141114        }
    11151115
    1116         const ast::WithStmt * Resolver_new::previsit( const ast::WithStmt * withStmt ) {
     1116        const ast::WithStmt * Resolver::previsit( const ast::WithStmt * withStmt ) {
    11171117                auto mutStmt = mutate(withStmt);
    11181118                resolveWithExprs(mutStmt->exprs, stmtsToAddBefore);
     
    11201120        }
    11211121
    1122         void Resolver_new::resolveWithExprs(std::vector<ast::ptr<ast::Expr>> & exprs, std::list<ast::ptr<ast::Stmt>> & stmtsToAdd) {
     1122        void Resolver::resolveWithExprs(std::vector<ast::ptr<ast::Expr>> & exprs, std::list<ast::ptr<ast::Stmt>> & stmtsToAdd) {
    11231123                for (auto & expr : exprs) {
    11241124                        // only struct- and union-typed expressions are viable candidates
     
    11461146
    11471147
    1148         const ast::SingleInit * Resolver_new::previsit( const ast::SingleInit * singleInit ) {
     1148        const ast::SingleInit * Resolver::previsit( const ast::SingleInit * singleInit ) {
    11491149                visit_children = false;
    11501150                // resolve initialization using the possibilities as determined by the `currentObject`
     
    11951195        }
    11961196
    1197         const ast::ListInit * Resolver_new::previsit( const ast::ListInit * listInit ) {
     1197        const ast::ListInit * Resolver::previsit( const ast::ListInit * listInit ) {
    11981198                // move cursor into brace-enclosed initializer-list
    11991199                currentObject.enterListInit( listInit->location );
     
    12181218        }
    12191219
    1220         const ast::ConstructorInit * Resolver_new::previsit( const ast::ConstructorInit * ctorInit ) {
     1220        const ast::ConstructorInit * Resolver::previsit( const ast::ConstructorInit * ctorInit ) {
    12211221                visitor->maybe_accept( ctorInit, &ast::ConstructorInit::ctor );
    12221222                visitor->maybe_accept( ctorInit, &ast::ConstructorInit::dtor );
     
    12401240
    12411241        // suppress error on autogen functions and mark invalid autogen as deleted.
    1242         bool Resolver_new::on_error(ast::ptr<ast::Decl> & decl) {
     1242        bool Resolver::on_error(ast::ptr<ast::Decl> & decl) {
    12431243                if (auto functionDecl = decl.as<ast::FunctionDecl>()) {
    12441244                        // xxx - can intrinsic gen ever fail?
  • src/ResolvExpr/Resolver.h

    r25f2798 r0bd3faf  
    1616#pragma once
    1717
    18 #include <list>          // for list
    19 
    2018#include "AST/Node.hpp"  // for ptr
    21 
    22 class ConstructorInit;
    23 class Declaration;
    24 class Expression;
    25 class DeletedExpr;
    26 class StmtExpr;
    27 class Type;
    28 namespace SymTab {
    29         class Indexer;
    30 } // namespace SymTab
    3119
    3220namespace ast {
     
    4533
    4634namespace ResolvExpr {
    47         /// Checks types and binds syntactic constructs to typed representations
    48         void resolve( std::list< Declaration * > translationUnit );
    49         void resolveDecl( Declaration *, const SymTab::Indexer & indexer );
    50         Expression *resolveInVoidContext( Expression * expr, const SymTab::Indexer & indexer );
    51         void findVoidExpression( Expression *& untyped, const SymTab::Indexer & indexer );
    52         void findSingleExpression( Expression *& untyped, const SymTab::Indexer & indexer );
    53         void findSingleExpression( Expression *& untyped, Type * type, const SymTab::Indexer & indexer );
    54         void resolveCtorInit( ConstructorInit * ctorInit, const SymTab::Indexer & indexer );
    55         void resolveStmtExpr( StmtExpr * stmtExpr, const SymTab::Indexer & indexer );
    56         /// Searches expr and returns the first DeletedExpr found, otherwise nullptr
    57         DeletedExpr * findDeletedExpr( Expression * expr );
    58         /// Resolves with-stmts and with-clauses on functions
    59         void resolveWithExprs( std::list< Declaration * > & translationUnit );
    6035
    6136        /// Helper Type: Passes around information between various sub-calls.
  • src/ResolvExpr/SpecCost.cc

    r25f2798 r0bd3faf  
    7676
    7777        public:
    78                 int get_count() const { return 0 <= count ? count : 0; }
     78                int result() const { return 0 <= count ? count : 0; }
    7979
    8080                // Mark specialization of base type.
     
    125125                return 0;
    126126        }
    127         ast::Pass<SpecCounter> counter;
    128         type->accept( counter );
    129         return counter.core.get_count();
     127        return ast::Pass<SpecCounter>::read( type );
    130128}
    131129
  • src/ResolvExpr/Unify.cc

    r25f2798 r0bd3faf  
    105105                /// If this isn't done when satifying ttype assertions, then argument lists can have
    106106                /// different size and structure when they should be compatible.
    107                 struct TtypeExpander_new : public ast::WithShortCircuiting, public ast::PureVisitor {
     107                struct TtypeExpander : public ast::WithShortCircuiting, public ast::PureVisitor {
    108108                        ast::TypeEnvironment & tenv;
    109109
    110                         TtypeExpander_new( ast::TypeEnvironment & env ) : tenv( env ) {}
     110                        TtypeExpander( ast::TypeEnvironment & env ) : tenv( env ) {}
    111111
    112112                        const ast::Type * postvisit( const ast::TypeInstType * typeInst ) {
     
    128128                dst.reserve( src.size() );
    129129                for ( const auto & d : src ) {
    130                         ast::Pass<TtypeExpander_new> expander{ env };
     130                        ast::Pass<TtypeExpander> expander{ env };
    131131                        // TtypeExpander pass is impure (may mutate nodes in place)
    132132                        // need to make nodes shared to prevent accidental mutation
     
    268268        }
    269269
    270         class Unify_new final : public ast::WithShortCircuiting {
     270        class Unify final : public ast::WithShortCircuiting {
    271271                const ast::Type * type2;
    272272                ast::TypeEnvironment & tenv;
     
    279279                bool result;
    280280
    281                 Unify_new(
     281                Unify(
    282282                        const ast::Type * type2, ast::TypeEnvironment & env, ast::AssertionSet & need,
    283283                        ast::AssertionSet & have, const ast::OpenVarSet & open, WidenMode widen )
     
    606606                        if ( ! tuple2 ) return;
    607607
    608                         ast::Pass<TtypeExpander_new> expander{ tenv };
     608                        ast::Pass<TtypeExpander> expander{ tenv };
    609609
    610610                        const ast::Type * flat = tuple->accept( expander );
     
    634634        };
    635635
    636         // size_t Unify_new::traceId = Stats::Heap::new_stacktrace_id("Unify_new");
     636        // size_t Unify::traceId = Stats::Heap::new_stacktrace_id("Unify");
     637
    637638        bool unify(
    638639                        const ast::ptr<ast::Type> & type1, const ast::ptr<ast::Type> & type2,
     
    678679                        return env.bindVar( var2, type1, ast::TypeData{var2->base}, need, have, open, widen );
    679680                } else {
    680                         return ast::Pass<Unify_new>::read(
     681                        return ast::Pass<Unify>::read(
    681682                                type1, type2, env, need, have, open, widen );
    682683                }
  • src/ResolvExpr/typeops.h

    r25f2798 r0bd3faf  
    1919
    2020#include "AST/Type.hpp"
    21 
    22 namespace SymTab {
    23         class Indexer;
    24 }
    2521
    2622namespace ResolvExpr {
Note: See TracChangeset for help on using the changeset viewer.