Ignore:
Timestamp:
Jul 12, 2019, 1:35:58 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
fce4e31
Parents:
7870799
Message:

Indexer now has const lookup by default

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Indexer.h

    r7870799 ref5b828  
    3434                virtual ~Indexer();
    3535
    36                 // when using an indexer manually (e.g., within a mutator traversal), it is necessary to 
     36                // when using an indexer manually (e.g., within a mutator traversal), it is necessary to
    3737                // tell the indexer explicitly when scopes begin and end
    3838                void enterScope();
     
    5050                        // NOTE: shouldn't need either of these constructors, but gcc-4 does not properly support initializer lists with default members.
    5151                        IdData() = default;
    52                         IdData( 
     52                        IdData(
    5353                                DeclarationWithType * id, Expression * baseExpr, BaseSyntaxNode * deleteStmt,
    54                                 unsigned long scope ) 
     54                                unsigned long scope )
    5555                                : id( id ), baseExpr( baseExpr ), deleteStmt( deleteStmt ), scope( scope ) {}
    5656                        IdData( const IdData& o, BaseSyntaxNode * deleteStmt )
     
    6161
    6262                /// Gets all declarations with the given ID
    63                 void lookupId( const std::string &id, std::list< IdData > &out ) const;
     63                void lookupId( const std::string & id, std::list< IdData > &out ) const;
    6464                /// Gets the top-most type declaration with the given ID
    65                 NamedTypeDecl *lookupType( const std::string &id ) const;
     65                const NamedTypeDecl * lookupType( const std::string & id ) const;
     66                NamedTypeDecl * lookupMutableType( const std::string & id ) const;
    6667                /// Gets the top-most struct declaration with the given ID
    67                 StructDecl *lookupStruct( const std::string &id ) const;
     68                const StructDecl * lookupStruct( const std::string & id ) const;
     69                StructDecl * lookupMutableStruct( const std::string & id ) const;
    6870                /// Gets the top-most enum declaration with the given ID
    69                 EnumDecl *lookupEnum( const std::string &id ) const;
     71                const EnumDecl * lookupEnum( const std::string & id ) const;
     72                EnumDecl * lookupMutableEnum( const std::string & id ) const;
    7073                /// Gets the top-most union declaration with the given ID
    71                 UnionDecl *lookupUnion( const std::string &id ) const;
     74                const UnionDecl * lookupUnion( const std::string & id ) const;
     75                UnionDecl * lookupMutableUnion( const std::string & id ) const;
    7276                /// Gets the top-most trait declaration with the given ID
    73                 TraitDecl *lookupTrait( const std::string &id ) const;
     77                const TraitDecl * lookupTrait( const std::string & id ) const;
     78                TraitDecl * lookupMutableTrait( const std::string & id ) const;
    7479
    7580                /// Gets the type declaration with the given ID at global scope
    76                 NamedTypeDecl *globalLookupType( const std::string &id ) const;
     81                const NamedTypeDecl * globalLookupType( const std::string & id ) const;
    7782                /// Gets the struct declaration with the given ID at global scope
    78                 StructDecl *globalLookupStruct( const std::string &id ) const;
     83                const StructDecl * globalLookupStruct( const std::string & id ) const;
    7984                /// Gets the union declaration with the given ID at global scope
    80                 UnionDecl *globalLookupUnion( const std::string &id ) const;
     85                const UnionDecl * globalLookupUnion( const std::string & id ) const;
    8186                /// Gets the enum declaration with the given ID at global scope
    82                 EnumDecl *globalLookupEnum( const std::string &id ) const;
     87                const EnumDecl * globalLookupEnum( const std::string & id ) const;
    8388
    8489                void addId( DeclarationWithType * decl, Expression * baseExpr = nullptr );
    8590                void addDeletedId( DeclarationWithType * decl, BaseSyntaxNode * deleteStmt );
    8691
    87                 void addType( NamedTypeDecl *decl );
    88                 void addStruct( const std::string &id );
    89                 void addStruct( StructDecl *decl );
    90                 void addEnum( EnumDecl *decl );
    91                 void addUnion( const std::string &id );
    92                 void addUnion( UnionDecl *decl );
    93                 void addTrait( TraitDecl *decl );
     92                void addType( NamedTypeDecl * decl );
     93                void addStruct( const std::string & id );
     94                void addStruct( StructDecl * decl );
     95                void addEnum( EnumDecl * decl );
     96                void addUnion( const std::string & id );
     97                void addUnion( UnionDecl * decl );
     98                void addTrait( TraitDecl * decl );
    9499
    95100                /// adds all of the IDs from WithStmt exprs
     
    106111
    107112          private:
    108                 /// Wraps a Decl* with a scope
     113                /// Wraps a Decl * with a scope
    109114                template<typename Decl>
    110115                struct Scoped {
    111                         Decl* decl;           ///< declaration
     116                        Decl * decl;           ///< declaration
    112117                        unsigned long scope;  ///< scope of this declaration
    113118
    114                         Scoped(Decl* d, unsigned long s) : decl(d), scope(s) {}
     119                        Scoped(Decl * d, unsigned long s) : decl(d), scope(s) {}
    115120                };
    116121
     
    140145
    141146                /// Gets the indexer at the given scope
    142                 const Indexer* atScope( unsigned long scope ) const;
     147                const Indexer * atScope( unsigned long scope ) const;
    143148
    144                 /// Removes matching autogenerated constructors and destructors so that they will not be 
     149                /// Removes matching autogenerated constructors and destructors so that they will not be
    145150                /// selected. If returns false, passed decl should not be added.
    146151                bool removeSpecialOverrides( IdData& decl, MangleTable::Ptr& mangleTable );
     
    166171                /// true if the existing identifier conflicts with the added identifier
    167172                bool addedIdConflicts(
    168                         const IdData& existing, DeclarationWithType * added, OnConflict handleConflicts, 
     173                        const IdData& existing, DeclarationWithType * added, OnConflict handleConflicts,
    169174                        BaseSyntaxNode * deleteStmt );
    170175
    171176                /// common code for addId, addDeletedId, etc.
    172                 void addId( 
    173                         DeclarationWithType * decl, OnConflict handleConflicts, 
     177                void addId(
     178                        DeclarationWithType * decl, OnConflict handleConflicts,
    174179                        Expression * baseExpr = nullptr, BaseSyntaxNode * deleteStmt = nullptr );
    175180
     
    178183
    179184                /// returns true if there exists a declaration with C linkage and the given name with the same mangled name
    180                 bool hasCompatibleCDecl( const std::string &id, const std::string &mangleName ) const;
     185                bool hasCompatibleCDecl( const std::string & id, const std::string &mangleName ) const;
    181186                /// returns true if there exists a declaration with C linkage and the given name with a different mangled name
    182                 bool hasIncompatibleCDecl( const std::string &id, const std::string &mangleName ) const;
     187                bool hasIncompatibleCDecl( const std::string & id, const std::string &mangleName ) const;
    183188        };
    184189} // namespace SymTab
Note: See TracChangeset for help on using the changeset viewer.