Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Indexer.h

    r8884112 rd0d9610  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Indexer.h --
     7// Indexer.h -- 
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 21:38:55 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 17:34:14 2016
    13 // Update Count     : 6
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Thu Sep 17 16:05:38 2015
     13// Update Count     : 5
    1414//
    1515
     
    2121
    2222#include "SynTree/Visitor.h"
     23#include "IdTable.h"
     24#include "AggregateTable.h"
     25#include "TypeTable.h"
    2326
    2427namespace SymTab {
     
    2629          public:
    2730                Indexer( bool useDebug = false );
     31                virtual ~Indexer();
    2832
    29                 Indexer( const Indexer &that );
    30                 Indexer( Indexer &&that );
    31                 virtual ~Indexer();
    32                 Indexer& operator= ( const Indexer &that );
    33                 Indexer& operator= ( Indexer &&that );
    34 
    35                 using Visitor::visit;
     33                //using Visitor::visit;
    3634                virtual void visit( ObjectDecl *objectDecl );
    3735                virtual void visit( FunctionDecl *functionDecl );
     
    4139                virtual void visit( UnionDecl *aggregateDecl );
    4240                virtual void visit( EnumDecl *aggregateDecl );
    43                 virtual void visit( TraitDecl *aggregateDecl );
     41                virtual void visit( ContextDecl *aggregateDecl );
    4442
    4543                virtual void visit( CompoundStmt *compoundStmt );
     
    5452                virtual void visit( MemberExpr *memberExpr );
    5553                virtual void visit( VariableExpr *variableExpr );
    56                 virtual void visit( ConstantExpr *constantExpr );
     54                virtual void visit( ConstantExpr *constantExpr ); 
    5755                virtual void visit( SizeofExpr *sizeofExpr );
    58                 virtual void visit( AlignofExpr *alignofExpr );
    59                 virtual void visit( UntypedOffsetofExpr *offsetofExpr );
    60                 virtual void visit( OffsetofExpr *offsetofExpr );
    61                 virtual void visit( OffsetPackExpr *offsetPackExpr );
    6256                virtual void visit( AttrExpr *attrExpr );
    6357                virtual void visit( LogicalExpr *logicalExpr );
     
    7064                virtual void visit( UntypedValofExpr *valofExpr );
    7165
    72                 virtual void visit( TraitInstType *contextInst );
     66                virtual void visit( ContextInstType *contextInst );
    7367                virtual void visit( StructInstType *contextInst );
    7468                virtual void visit( UnionInstType *contextInst );
     
    8175                void leaveScope();
    8276
    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
     77                void lookupId( const std::string &id, std::list< DeclarationWithType* >& ) const;
     78                DeclarationWithType* lookupId( const std::string &id) const;
    8679                NamedTypeDecl *lookupType( const std::string &id ) const;
    87                 /// Gets the top-most struct declaration with the given ID
    8880                StructDecl *lookupStruct( const std::string &id ) const;
    89                 /// Gets the top-most enum declaration with the given ID
    9081                EnumDecl *lookupEnum( const std::string &id ) const;
    91                 /// Gets the top-most union declaration with the given ID
    9282                UnionDecl *lookupUnion( const std::string &id ) const;
    93                 /// Gets the top-most trait declaration with the given ID
    94                 TraitDecl *lookupTrait( const std::string &id ) const;
    95 
     83                ContextDecl *lookupContext( const std::string &id ) const;
     84 
    9685                void print( std::ostream &os, int indent = 0 ) const;
    9786          private:
    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, unsigned long scope ) const;
    102                 /// returns true if there exists a declaration with C linkage and the given name with the same mangled name
    103                 bool hasCompatibleCDecl( const std::string &id, const std::string &mangleName, unsigned long scope ) const;
    104                 // equivalents to lookup functions that only look at tables at scope `scope` (which should be >= tables->scope)
    105                 NamedTypeDecl *lookupTypeAtScope( const std::string &id, unsigned long scope ) const;
    106                 StructDecl *lookupStructAtScope( const std::string &id, unsigned long scope ) const;
    107                 EnumDecl *lookupEnumAtScope( const std::string &id, unsigned long scope ) const;
    108                 UnionDecl *lookupUnionAtScope( const std::string &id, unsigned long scope ) const;
    109                 TraitDecl *lookupTraitAtScope( const std::string &id, unsigned long scope ) const;
    110 
    111                 void addId( DeclarationWithType *decl );
    112                 void addType( NamedTypeDecl *decl );
    113                 void addStruct( const std::string &id );
    114                 void addStruct( StructDecl *decl );
    115                 void addEnum( EnumDecl *decl );
    116                 void addUnion( const std::string &id );
    117                 void addUnion( UnionDecl *decl );
    118                 void addTrait( TraitDecl *decl );
    119 
    120                 struct Impl;
    121                 Impl *tables;         ///< Copy-on-write instance of table data structure
    122                 unsigned long scope;  ///< Scope index of this pointer
    123                 bool doDebug;         ///< Display debugging trace?
    124 
    125                 /// Takes a new ref to a table (returns null if null)
    126                 static Impl *newRef( Impl *toClone );
    127                 /// Clears a ref to a table (does nothing if null)
    128                 static void deleteRef( Impl *toFree );
    129 
    130                 /// Ensures that tables variable is writable (i.e. allocated, uniquely owned by this Indexer, and at the current scope)
    131                 void makeWritable();
     87                IdTable idTable;
     88                TypeTable typeTable;
     89                StructTable structTable;
     90                EnumTable enumTable;
     91                UnionTable unionTable;
     92                ContextTable contextTable;
     93 
     94                bool doDebug;                                   // display debugging trace
    13295        };
    13396} // namespace SymTab
Note: See TracChangeset for help on using the changeset viewer.