Ignore:
Timestamp:
Apr 15, 2016, 12:03:11 PM (10 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
29ad0ac
Parents:
c5833e8 (diff), 37f0da8 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into gc_noraii

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Indexer.h

    rc5833e8 r0f9e4403  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 21:38:55 2015
    11 // Last Modified By : Rob Schluntz
    12 // Last Modified On : Thu Sep 17 16:05:38 2015
    13 // Update Count     : 5
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Mar  2 17:34:14 2016
     13// Update Count     : 6
    1414//
    1515
     
    2121
    2222#include "SynTree/Visitor.h"
    23 #include "IdTable.h"
    24 #include "AggregateTable.h"
    25 #include "TypeTable.h"
    2623
    2724namespace SymTab {
     
    2926          public:
    3027                Indexer( bool useDebug = false );
     28
     29                Indexer( const Indexer &that );
     30                Indexer( Indexer &&that );
    3131                virtual ~Indexer();
     32                Indexer& operator= ( const Indexer &that );
     33                Indexer& operator= ( Indexer &&that );
    3234
    3335                //using Visitor::visit;
     
    3941                virtual void visit( UnionDecl *aggregateDecl );
    4042                virtual void visit( EnumDecl *aggregateDecl );
    41                 virtual void visit( ContextDecl *aggregateDecl );
     43                virtual void visit( TraitDecl *aggregateDecl );
    4244
    4345                virtual void visit( CompoundStmt *compoundStmt );
     
    5759                virtual void visit( UntypedOffsetofExpr *offsetofExpr );
    5860                virtual void visit( OffsetofExpr *offsetofExpr );
     61                virtual void visit( OffsetPackExpr *offsetPackExpr );
    5962                virtual void visit( AttrExpr *attrExpr );
    6063                virtual void visit( LogicalExpr *logicalExpr );
     
    6770                virtual void visit( UntypedValofExpr *valofExpr );
    6871
    69                 virtual void visit( ContextInstType *contextInst );
     72                virtual void visit( TraitInstType *contextInst );
    7073                virtual void visit( StructInstType *contextInst );
    7174                virtual void visit( UnionInstType *contextInst );
     
    7881                void leaveScope();
    7982
    80                 void lookupId( const std::string &id, std::list< DeclarationWithType* >& ) const;
    81                 DeclarationWithType* lookupId( const std::string &id) const;
     83                /// Gets all declarations with the given ID
     84                void lookupId( const std::string &id, std::list< DeclarationWithType* > &out ) const;
     85                /// Gets the top-most type declaration with the given ID
    8286                NamedTypeDecl *lookupType( const std::string &id ) const;
     87                /// Gets the top-most struct declaration with the given ID
    8388                StructDecl *lookupStruct( const std::string &id ) const;
     89                /// Gets the top-most enum declaration with the given ID
    8490                EnumDecl *lookupEnum( const std::string &id ) const;
     91                /// Gets the top-most union declaration with the given ID
    8592                UnionDecl *lookupUnion( const std::string &id ) const;
    86                 ContextDecl *lookupContext( const std::string &id ) const;
     93                /// Gets the top-most trait declaration with the given ID
     94                TraitDecl *lookupTrait( const std::string &id ) const;
    8795 
    8896                void print( std::ostream &os, int indent = 0 ) const;
    8997          private:
    90                 IdTable idTable;
    91                 TypeTable typeTable;
    92                 StructTable structTable;
    93                 EnumTable enumTable;
    94                 UnionTable unionTable;
    95                 ContextTable contextTable;
    96  
    97                 bool doDebug;                                   // display debugging trace
     98                /// looks up a specific mangled ID at the given scope
     99                DeclarationWithType *lookupIdAtScope( const std::string &id, const std::string &mangleName, unsigned long scope ) const;
     100                /// returns true if there exists a declaration with C linkage and the given name with a different mangled name
     101                bool hasIncompatibleCDecl( const std::string &id, const std::string &mangleName ) const;
     102                // equivalents to lookup functions that only look at tables at scope `scope` (which should be >= tables->scope)
     103                NamedTypeDecl *lookupTypeAtScope( const std::string &id, unsigned long scope ) const;
     104                StructDecl *lookupStructAtScope( const std::string &id, unsigned long scope ) const;
     105                EnumDecl *lookupEnumAtScope( const std::string &id, unsigned long scope ) const;
     106                UnionDecl *lookupUnionAtScope( const std::string &id, unsigned long scope ) const;
     107                TraitDecl *lookupTraitAtScope( const std::string &id, unsigned long scope ) const;
     108               
     109                void addId( DeclarationWithType *decl );
     110                void addType( NamedTypeDecl *decl );
     111                void addStruct( const std::string &id );
     112                void addStruct( StructDecl *decl );
     113                void addEnum( EnumDecl *decl );
     114                void addUnion( const std::string &id );
     115                void addUnion( UnionDecl *decl );
     116                void addTrait( TraitDecl *decl );
     117               
     118                struct Impl;
     119                Impl *tables;         ///< Copy-on-write instance of table data structure
     120                unsigned long scope;  ///< Scope index of this pointer
     121                bool doDebug;         ///< Display debugging trace?
     122
     123                /// Takes a new ref to a table (returns null if null)
     124                static Impl *newRef( Impl *toClone );
     125                /// Clears a ref to a table (does nothing if null)
     126                static void deleteRef( Impl *toFree );
     127
     128                /// Ensures that tables variable is writable (i.e. allocated, uniquely owned by this Indexer, and at the current scope)
     129                void makeWritable();
    98130        };
    99131} // namespace SymTab
Note: See TracChangeset for help on using the changeset viewer.