Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Indexer.h

    re67991f r114bde6  
    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();
     
    4040
    4141                struct IdData {
    42                         const DeclarationWithType * id = nullptr;
    43                         const Expression * baseExpr = nullptr; // WithExpr
     42                        DeclarationWithType * id = nullptr;
     43                        Expression * baseExpr = nullptr; // WithExpr
    4444
    4545                        /// non-null if this declaration is deleted
    46                         const Declaration * deleteStmt = nullptr;
     46                        BaseSyntaxNode * deleteStmt = nullptr;
    4747                        /// scope of identifier
    4848                        unsigned long scope = 0;
     
    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(
    53                                 const DeclarationWithType * id, const Expression * baseExpr, const Declaration * deleteStmt,
    54                                 unsigned long scope )
     52                        IdData( 
     53                                DeclarationWithType * id, Expression * baseExpr, BaseSyntaxNode * deleteStmt,
     54                                unsigned long scope ) 
    5555                                : id( id ), baseExpr( baseExpr ), deleteStmt( deleteStmt ), scope( scope ) {}
    56                         IdData( const IdData& o, const Declaration * deleteStmt )
     56                        IdData( const IdData& o, BaseSyntaxNode * deleteStmt )
    5757                                : id( o.id ), baseExpr( o.baseExpr ), deleteStmt( deleteStmt ), scope( o.scope ) {}
    5858
     
    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                 const NamedTypeDecl * lookupType( const std::string & id ) const;
     65                NamedTypeDecl *lookupType( const std::string &id ) const;
    6666                /// Gets the top-most struct declaration with the given ID
    67                 const StructDecl * lookupStruct( const std::string & id ) const;
     67                StructDecl *lookupStruct( const std::string &id ) const;
    6868                /// Gets the top-most enum declaration with the given ID
    69                 const EnumDecl * lookupEnum( const std::string & id ) const;
     69                EnumDecl *lookupEnum( const std::string &id ) const;
    7070                /// Gets the top-most union declaration with the given ID
    71                 const UnionDecl * lookupUnion( const std::string & id ) const;
     71                UnionDecl *lookupUnion( const std::string &id ) const;
    7272                /// Gets the top-most trait declaration with the given ID
    73                 const TraitDecl * lookupTrait( const std::string & id ) const;
     73                TraitDecl *lookupTrait( const std::string &id ) const;
    7474
    7575                /// Gets the type declaration with the given ID at global scope
    76                 const NamedTypeDecl * globalLookupType( const std::string & id ) const;
     76                NamedTypeDecl *globalLookupType( const std::string &id ) const;
    7777                /// Gets the struct declaration with the given ID at global scope
    78                 const StructDecl * globalLookupStruct( const std::string & id ) const;
     78                StructDecl *globalLookupStruct( const std::string &id ) const;
    7979                /// Gets the union declaration with the given ID at global scope
    80                 const UnionDecl * globalLookupUnion( const std::string & id ) const;
     80                UnionDecl *globalLookupUnion( const std::string &id ) const;
    8181                /// Gets the enum declaration with the given ID at global scope
    82                 const EnumDecl * globalLookupEnum( const std::string & id ) const;
     82                EnumDecl *globalLookupEnum( const std::string &id ) const;
    8383
    84                 void addId( const DeclarationWithType * decl, const Expression * baseExpr = nullptr );
    85                 void addDeletedId( const DeclarationWithType * decl, const Declaration * deleteStmt );
     84                void addId( DeclarationWithType * decl, Expression * baseExpr = nullptr );
     85                void addDeletedId( DeclarationWithType * decl, BaseSyntaxNode * deleteStmt );
    8686
    87                 void addType( const NamedTypeDecl * decl );
    88                 void addStruct( const std::string & id );
    89                 void addStruct( const StructDecl * decl );
    90                 void addEnum( const EnumDecl * decl );
    91                 void addUnion( const std::string & id );
    92                 void addUnion( const UnionDecl * decl );
    93                 void addTrait( const TraitDecl * decl );
     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 );
    9494
    9595                /// adds all of the IDs from WithStmt exprs
    96                 void addWith( const std::list< Expression * > & withExprs, const Declaration * withStmt );
     96                void addWith( std::list< Expression * > & withExprs, BaseSyntaxNode * withStmt );
    9797
    9898                /// convenience function for adding a list of Ids to the indexer
     
    103103
    104104                /// convenience function for adding all of the declarations in a function type to the indexer
    105                 void addFunctionType( const FunctionType * ftype );
     105                void addFunctionType( FunctionType * ftype );
    106106
    107107          private:
    108                 /// Wraps a Decl * with a scope
     108                /// Wraps a Decl* with a scope
    109109                template<typename Decl>
    110110                struct Scoped {
    111                         const Decl * decl;           ///< declaration
     111                        Decl* decl;           ///< declaration
    112112                        unsigned long scope;  ///< scope of this declaration
    113113
    114                         Scoped(const Decl * d, unsigned long s) : decl(d), scope(s) {}
     114                        Scoped(Decl* d, unsigned long s) : decl(d), scope(s) {}
    115115                };
    116116
     
    140140
    141141                /// Gets the indexer at the given scope
    142                 const Indexer * atScope( unsigned long scope ) const;
     142                const Indexer* atScope( unsigned long scope ) const;
    143143
    144                 /// Removes matching autogenerated constructors and destructors so that they will not be
     144                /// Removes matching autogenerated constructors and destructors so that they will not be 
    145145                /// selected. If returns false, passed decl should not be added.
    146                 bool removeSpecialOverrides( IdData & decl, MangleTable::Ptr & mangleTable );
     146                bool removeSpecialOverrides( IdData& decl, MangleTable::Ptr& mangleTable );
    147147
    148148                /// Options for handling identifier conflicts
     
    152152                                Delete  ///< Delete the earlier version with the delete statement
    153153                        } mode;
    154                         const Declaration * deleteStmt;  ///< Statement that deletes this expression
     154                        BaseSyntaxNode * deleteStmt;  ///< Statement that deletes this expression
    155155
    156156                private:
    157157                        OnConflict() : mode(Error), deleteStmt(nullptr) {}
    158                         OnConflict( const Declaration * d ) : mode(Delete), deleteStmt(d) {}
     158                        OnConflict( BaseSyntaxNode * d ) : mode(Delete), deleteStmt(d) {}
    159159                public:
    160160                        OnConflict( const OnConflict& ) = default;
    161161
    162162                        static OnConflict error() { return {}; }
    163                         static OnConflict deleteWith( const Declaration * d ) { return { d }; }
     163                        static OnConflict deleteWith( BaseSyntaxNode * d ) { return { d }; }
    164164                };
    165165
    166166                /// true if the existing identifier conflicts with the added identifier
    167167                bool addedIdConflicts(
    168                         const IdData & existing, const DeclarationWithType * added, OnConflict handleConflicts,
    169                         const Declaration * deleteStmt );
     168                        const IdData& existing, DeclarationWithType * added, OnConflict handleConflicts,
     169                        BaseSyntaxNode * deleteStmt );
    170170
    171171                /// common code for addId, addDeletedId, etc.
    172                 void addId(const DeclarationWithType * decl, OnConflict handleConflicts,
    173                         const Expression * baseExpr = nullptr, const Declaration * deleteStmt = nullptr );
     172                void addId(
     173                        DeclarationWithType * decl, OnConflict handleConflicts,
     174                        Expression * baseExpr = nullptr, BaseSyntaxNode * deleteStmt = nullptr );
    174175
    175176                /// adds all of the members of the Aggregate (addWith helper)
    176                 void addMembers( const AggregateDecl * aggr, const Expression * expr, OnConflict handleConflicts );
     177                void addMembers( AggregateDecl * aggr, Expression * expr, OnConflict handleConflicts );
    177178
    178179                /// returns true if there exists a declaration with C linkage and the given name with the same mangled name
    179                 bool hasCompatibleCDecl( const std::string & id, const std::string & mangleName ) const;
     180                bool hasCompatibleCDecl( const std::string &id, const std::string &mangleName ) const;
    180181                /// returns true if there exists a declaration with C linkage and the given name with a different mangled name
    181                 bool hasIncompatibleCDecl( const std::string & id, const std::string & mangleName ) const;
     182                bool hasIncompatibleCDecl( const std::string &id, const std::string &mangleName ) const;
    182183        };
    183184} // namespace SymTab
Note: See TracChangeset for help on using the changeset viewer.