Changeset 0bd3faf for src/SymTab


Ignore:
Timestamp:
Nov 13, 2023, 1:40:12 PM (6 months 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/SymTab
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/FixFunction.cc

    r25f2798 r0bd3faf  
    2626
    2727namespace {
    28         struct FixFunction_new final : public ast::WithShortCircuiting {
     28        struct FixFunction final : public ast::WithShortCircuiting {
    2929                bool isVoid = false;
    3030
     
    7070
    7171const ast::DeclWithType * fixFunction( const ast::DeclWithType * dwt, bool & isVoid ) {
    72         ast::Pass< FixFunction_new > fixer;
     72        ast::Pass< FixFunction > fixer;
    7373        dwt = dwt->accept( fixer );
    7474        isVoid |= fixer.core.isVoid;
     
    7777
    7878const ast::Type * fixFunction( const ast::Type * type, bool & isVoid ) {
    79         ast::Pass< FixFunction_new > fixer;
     79        ast::Pass< FixFunction > fixer;
    8080        type = type->accept( fixer );
    8181        isVoid |= fixer.core.isVoid;
  • src/SymTab/GenImplicitCall.cpp

    r25f2798 r0bd3faf  
    3232template< typename OutIter >
    3333ast::ptr< ast::Stmt > genCall(
    34         InitTweak::InitExpander_new & srcParam, const ast::Expr * dstParam,
     34        InitTweak::InitExpander & srcParam, const ast::Expr * dstParam,
    3535        const CodeLocation & loc, const std::string & fname, OutIter && out,
    3636        const ast::Type * type, const ast::Type * addCast, LoopDirection forward = LoopForward );
     
    4242template< typename OutIter >
    4343ast::ptr< ast::Stmt > genScalarCall(
    44         InitTweak::InitExpander_new & srcParam, const ast::Expr * dstParam,
     44        InitTweak::InitExpander & srcParam, const ast::Expr * dstParam,
    4545        const CodeLocation & loc, std::string fname, OutIter && out, const ast::Type * type,
    4646        const ast::Type * addCast = nullptr
     
    9898template< typename OutIter >
    9999void genArrayCall(
    100         InitTweak::InitExpander_new & srcParam, const ast::Expr * dstParam,
     100        InitTweak::InitExpander & srcParam, const ast::Expr * dstParam,
    101101        const CodeLocation & loc, const std::string & fname, OutIter && out,
    102102        const ast::ArrayType * array, const ast::Type * addCast = nullptr,
     
    167167template< typename OutIter >
    168168ast::ptr< ast::Stmt > genCall(
    169         InitTweak::InitExpander_new & srcParam, const ast::Expr * dstParam,
     169        InitTweak::InitExpander & srcParam, const ast::Expr * dstParam,
    170170        const CodeLocation & loc, const std::string & fname, OutIter && out,
    171171        const ast::Type * type, const ast::Type * addCast, LoopDirection forward
     
    185185
    186186ast::ptr< ast::Stmt > genImplicitCall(
    187         InitTweak::InitExpander_new & srcParam, const ast::Expr * dstParam,
     187        InitTweak::InitExpander & srcParam, const ast::Expr * dstParam,
    188188        const CodeLocation & loc, const std::string & fname, const ast::ObjectDecl * obj,
    189189        LoopDirection forward
  • src/SymTab/GenImplicitCall.hpp

    r25f2798 r0bd3faf  
    2626/// dstParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls.
    2727ast::ptr<ast::Stmt> genImplicitCall(
    28         InitTweak::InitExpander_new & srcParam, const ast::Expr * dstParam,
     28        InitTweak::InitExpander & srcParam, const ast::Expr * dstParam,
    2929        const CodeLocation & loc, const std::string & fname, const ast::ObjectDecl * obj,
    3030        LoopDirection forward = LoopForward
  • src/SymTab/Mangler.cc

    r25f2798 r0bd3faf  
    3030        namespace {
    3131                /// Mangles names to a unique C identifier
    32                 struct Mangler_new : public ast::WithShortCircuiting, public ast::WithVisitorRef<Mangler_new>, public ast::WithGuards {
    33                         Mangler_new( Mangle::Mode mode );
    34                         Mangler_new( const Mangler_new & ) = delete;
     32                struct Mangler : public ast::WithShortCircuiting, public ast::WithVisitorRef<Mangler>, public ast::WithGuards {
     33                        Mangler( Mangle::Mode mode );
     34                        Mangler( const Mangler & ) = delete;
    3535
    3636                        void previsit( const ast::Node * ) { visit_children = false; }
     
    7272
    7373                  private:
    74                         Mangler_new( bool mangleOverridable, bool typeMode, bool mangleGenericParams,
     74                        Mangler( bool mangleOverridable, bool typeMode, bool mangleGenericParams,
    7575                                int nextVarNum, const VarMapType& varNums );
    76                         friend class ast::Pass<Mangler_new>;
     76                        friend class ast::Pass<Mangler>;
    7777
    7878                  private:
     
    8181
    8282                        void printQualifiers( const ast::Type *type );
    83                 }; // Mangler_new
     83                }; // Mangler
    8484        } // namespace
    8585
    8686        std::string mangle( const ast::Node * decl, Mangle::Mode mode ) {
    87                 return ast::Pass<Mangler_new>::read( decl, mode );
     87                return ast::Pass<Mangler>::read( decl, mode );
    8888        }
    8989
    9090        namespace {
    91                 Mangler_new::Mangler_new( Mangle::Mode mode )
     91                Mangler::Mangler( Mangle::Mode mode )
    9292                        : nextVarNum( 0 ), isTopLevel( true ),
    9393                        mangleOverridable  ( ! mode.no_overrideable   ),
     
    9595                        mangleGenericParams( ! mode.no_generic_params ) {}
    9696
    97                 Mangler_new::Mangler_new( bool mangleOverridable, bool typeMode, bool mangleGenericParams,
     97                Mangler::Mangler( bool mangleOverridable, bool typeMode, bool mangleGenericParams,
    9898                        int nextVarNum, const VarMapType& varNums )
    9999                        : varNums( varNums ), nextVarNum( nextVarNum ), isTopLevel( false ),
     
    101101                        mangleGenericParams( mangleGenericParams ) {}
    102102
    103                 void Mangler_new::mangleDecl( const ast::DeclWithType * decl ) {
     103                void Mangler::mangleDecl( const ast::DeclWithType * decl ) {
    104104                        bool wasTopLevel = isTopLevel;
    105105                        if ( isTopLevel ) {
     
    131131                }
    132132
    133                 void Mangler_new::postvisit( const ast::ObjectDecl * decl ) {
     133                void Mangler::postvisit( const ast::ObjectDecl * decl ) {
    134134                        mangleDecl( decl );
    135135                }
    136136
    137                 void Mangler_new::postvisit( const ast::FunctionDecl * decl ) {
     137                void Mangler::postvisit( const ast::FunctionDecl * decl ) {
    138138                        mangleDecl( decl );
    139139                }
    140140
    141                 void Mangler_new::postvisit( const ast::VoidType * voidType ) {
     141                void Mangler::postvisit( const ast::VoidType * voidType ) {
    142142                        printQualifiers( voidType );
    143143                        mangleName += Encoding::void_t;
    144144                }
    145145
    146                 void Mangler_new::postvisit( const ast::BasicType * basicType ) {
     146                void Mangler::postvisit( const ast::BasicType * basicType ) {
    147147                        printQualifiers( basicType );
    148148                        assertf( basicType->kind < ast::BasicType::NUMBER_OF_BASIC_TYPES, "Unhandled basic type: %d", basicType->kind );
     
    150150                }
    151151
    152                 void Mangler_new::postvisit( const ast::PointerType * pointerType ) {
     152                void Mangler::postvisit( const ast::PointerType * pointerType ) {
    153153                        printQualifiers( pointerType );
    154154                        // mangle void (*f)() and void f() to the same name to prevent overloading on functions and function pointers
     
    157157                }
    158158
    159                 void Mangler_new::postvisit( const ast::ArrayType * arrayType ) {
     159                void Mangler::postvisit( const ast::ArrayType * arrayType ) {
    160160                        // TODO: encode dimension
    161161                        printQualifiers( arrayType );
     
    164164                }
    165165
    166                 void Mangler_new::postvisit( const ast::ReferenceType * refType ) {
     166                void Mangler::postvisit( const ast::ReferenceType * refType ) {
    167167                        // don't print prefix (e.g. 'R') for reference types so that references and non-references do not overload.
    168168                        // Further, do not print the qualifiers for a reference type (but do run printQualifers because of TypeDecls, etc.),
     
    174174                }
    175175
    176                 void Mangler_new::postvisit( const ast::FunctionType * functionType ) {
     176                void Mangler::postvisit( const ast::FunctionType * functionType ) {
    177177                        printQualifiers( functionType );
    178178                        mangleName += Encoding::function;
     
    189189                }
    190190
    191                 void Mangler_new::mangleRef(
     191                void Mangler::mangleRef(
    192192                                const ast::BaseInstType * refType, const std::string & prefix ) {
    193193                        printQualifiers( refType );
     
    206206                }
    207207
    208                 void Mangler_new::postvisit( const ast::StructInstType * aggregateUseType ) {
     208                void Mangler::postvisit( const ast::StructInstType * aggregateUseType ) {
    209209                        mangleRef( aggregateUseType, Encoding::struct_t );
    210210                }
    211211
    212                 void Mangler_new::postvisit( const ast::UnionInstType * aggregateUseType ) {
     212                void Mangler::postvisit( const ast::UnionInstType * aggregateUseType ) {
    213213                        mangleRef( aggregateUseType, Encoding::union_t );
    214214                }
    215215
    216                 void Mangler_new::postvisit( const ast::EnumInstType * aggregateUseType ) {
     216                void Mangler::postvisit( const ast::EnumInstType * aggregateUseType ) {
    217217                        mangleRef( aggregateUseType, Encoding::enum_t );
    218218                }
    219219
    220                 void Mangler_new::postvisit( const ast::TypeInstType * typeInst ) {
     220                void Mangler::postvisit( const ast::TypeInstType * typeInst ) {
    221221                        VarMapType::iterator varNum = varNums.find( typeInst->name );
    222222                        if ( varNum == varNums.end() ) {
     
    234234                }
    235235
    236                 void Mangler_new::postvisit( const ast::TraitInstType * inst ) {
     236                void Mangler::postvisit( const ast::TraitInstType * inst ) {
    237237                        printQualifiers( inst );
    238238                        mangleName += std::to_string( inst->name.size() ) + inst->name;
    239239                }
    240240
    241                 void Mangler_new::postvisit( const ast::TupleType * tupleType ) {
     241                void Mangler::postvisit( const ast::TupleType * tupleType ) {
    242242                        printQualifiers( tupleType );
    243243                        mangleName += Encoding::tuple + std::to_string( tupleType->types.size() );
     
    245245                }
    246246
    247                 void Mangler_new::postvisit( const ast::VarArgsType * varArgsType ) {
     247                void Mangler::postvisit( const ast::VarArgsType * varArgsType ) {
    248248                        printQualifiers( varArgsType );
    249249                        static const std::string vargs = "__builtin_va_list";
     
    251251                }
    252252
    253                 void Mangler_new::postvisit( const ast::ZeroType * ) {
     253                void Mangler::postvisit( const ast::ZeroType * ) {
    254254                        mangleName += Encoding::zero;
    255255                }
    256256
    257                 void Mangler_new::postvisit( const ast::OneType * ) {
     257                void Mangler::postvisit( const ast::OneType * ) {
    258258                        mangleName += Encoding::one;
    259259                }
    260260
    261                 void Mangler_new::postvisit( const ast::QualifiedType * qualType ) {
     261                void Mangler::postvisit( const ast::QualifiedType * qualType ) {
    262262                        bool inqual = inQualifiedType;
    263263                        if ( !inqual ) {
     
    275275                }
    276276
    277                 void Mangler_new::postvisit( const ast::TypeDecl * decl ) {
     277                void Mangler::postvisit( const ast::TypeDecl * decl ) {
    278278                        // TODO: is there any case where mangling a TypeDecl makes sense? If so, this code needs to be
    279279                        // fixed to ensure that two TypeDecls mangle to the same name when they are the same type and vice versa.
     
    281281                        // and the case has not yet come up in practice. Alternatively, if not then this code can be removed
    282282                        // aside from the assert false.
    283                         assertf(false, "Mangler_new should not visit typedecl: %s", toCString(decl));
     283                        assertf(false, "Mangler should not visit typedecl: %s", toCString(decl));
    284284                        assertf( decl->kind < ast::TypeDecl::Kind::NUMBER_OF_KINDS, "Unhandled type variable kind: %d", decl->kind );
    285285                        mangleName += Encoding::typeVariables[ decl->kind ] + std::to_string( decl->name.length() ) + decl->name;
     
    293293                }
    294294
    295                 void Mangler_new::printQualifiers( const ast::Type * type ) {
     295                void Mangler::printQualifiers( const ast::Type * type ) {
    296296                        // skip if not including qualifiers
    297297                        if ( typeMode ) return;
     
    318318                                } // for
    319319                                for ( auto & assert : funcType->assertions ) {
    320                                         assertionNames.push_back( ast::Pass<Mangler_new>::read(
     320                                        assertionNames.push_back( ast::Pass<Mangler>::read(
    321321                                                assert->var.get(),
    322322                                                mangleOverridable, typeMode, mangleGenericParams, nextVarNum, varNums ) );
Note: See TracChangeset for help on using the changeset viewer.