Ignore:
Timestamp:
May 16, 2015, 3:36:19 PM (9 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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, string, with_gc
Children:
a32b204
Parents:
b8508a2
Message:

licencing: first groups of files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • translator/Parser/TypedefTable.h

    rb8508a2 rb87a5ed  
     1//
     2// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
     3//
     4// The contents of this file are covered under the licence agreement in the
     5// file "LICENCE" distributed with Cforall.
     6//
     7// TypedefTable.h --
     8//
     9// Author           : Rodolfo G. Esteves
     10// Created On       : Sat May 16 15:24:36 2015
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sat May 16 15:25:59 2015
     13// Update Count     : 3
     14//
     15
    116#ifndef TYPEDEFTABLE_H
    217#define TYPEDEFTABLE_H
     
    924class TypedefTable {
    1025  public:
    11     enum kind_t { ID, TD, TG };
     26        enum kind_t { ID, TD, TG };
    1227  private:
    13     struct Entry {
    14         int scope;
    15         kind_t kind;
    16     };
    17    
    18     struct DeferredEntry {
    19         std::string identifier;
    20         kind_t kind;
    21     };
     28        struct Entry {
     29                int scope;
     30                kind_t kind;
     31        };
     32       
     33        struct DeferredEntry {
     34                std::string identifier;
     35                kind_t kind;
     36        };
    2237
    23     typedef std::map<std::string, std::list<Entry> > tableType;
    24     tableType table;
     38        typedef std::map<std::string, std::list<Entry> > tableType;
     39        tableType table;
    2540
    26     int currentScope;
    27     std::string currentContext;
    28     int contextScope;
    29    
    30     typedef std::list< DeferredEntry > deferListType;
    31     std::stack< deferListType > deferListStack;
    32     std::map< std::string, deferListType > contexts;
    33    
    34     std::stack< std::string > nextIdentifiers;
     41        int currentScope;
     42        std::string currentContext;
     43        int contextScope;
     44       
     45        typedef std::list< DeferredEntry > deferListType;
     46        std::stack< deferListType > deferListStack;
     47        std::map< std::string, deferListType > contexts;
     48       
     49        std::stack< std::string > nextIdentifiers;
    3550
    36     bool isKind( std::string identifier, kind_t kind ) const;
    37     void addToScope( const std::string &identifier, kind_t kind, int scope );
     51        bool isKind( std::string identifier, kind_t kind ) const;
     52        void addToScope( const std::string &identifier, kind_t kind, int scope );
    3853  public:
    39     TypedefTable();
     54        TypedefTable();
    4055
    41     bool isIdentifier( std::string identifier ) const;
    42     bool isTypedef( std::string identifier ) const;
    43     bool isTypegen( std::string identifier ) const;
    44    
    45     // "addToCurrentScope" adds the identifier/type pair to the current scope This does less than you think it does,
    46     // since each declaration is within its own scope.  Mostly useful for type parameters.
    47     void addToCurrentScope( const std::string &identifier, kind_t kind );
    48     void addToCurrentScope( kind_t kind );              // use nextIdentifiers.top()
     56        bool isIdentifier( std::string identifier ) const;
     57        bool isTypedef( std::string identifier ) const;
     58        bool isTypegen( std::string identifier ) const;
     59       
     60        // "addToCurrentScope" adds the identifier/type pair to the current scope This does less than you think it does,
     61        // since each declaration is within its own scope.  Mostly useful for type parameters.
     62        void addToCurrentScope( const std::string &identifier, kind_t kind );
     63        void addToCurrentScope( kind_t kind );          // use nextIdentifiers.top()
    4964
    50     // "addToEnclosingScope" adds the identifier/type pair to the scope that encloses the current one.  This is the
    51     // right way to handle type and typedef names
    52     void addToEnclosingScope( const std::string &identifier, kind_t kind );
    53     void addToEnclosingScope( kind_t kind );            // use nextIdentifiers.top()
    54    
    55     // "addToEnclosingScope2" adds the identifier/type pair to the scope that encloses the scope enclosing the the
    56     // current one.  This is the right way to handle assertion names
    57     void addToEnclosingScope2( const std::string &identifier, kind_t kind );
    58     void addToEnclosingScope2( kind_t kind );           // use nextIdentifiers.top()
    59    
    60     // set the next identifier to be used by an "add" operation without an identifier parameter within the current scope
    61     void setNextIdentifier( const std::string &identifier );
    62    
    63     // dump the definitions from a pre-defined context into the current scope
    64     void openContext( std::string contextName );
    65    
    66     void enterScope( void );
    67     void leaveScope( void );
    68     void enterContext( std::string contextName );
    69     void leaveContext( void );
     65        // "addToEnclosingScope" adds the identifier/type pair to the scope that encloses the current one.  This is the
     66        // right way to handle type and typedef names
     67        void addToEnclosingScope( const std::string &identifier, kind_t kind );
     68        void addToEnclosingScope( kind_t kind );                // use nextIdentifiers.top()
     69       
     70        // "addToEnclosingScope2" adds the identifier/type pair to the scope that encloses the scope enclosing the the
     71        // current one.  This is the right way to handle assertion names
     72        void addToEnclosingScope2( const std::string &identifier, kind_t kind );
     73        void addToEnclosingScope2( kind_t kind );               // use nextIdentifiers.top()
     74       
     75        // set the next identifier to be used by an "add" operation without an identifier parameter within the current scope
     76        void setNextIdentifier( const std::string &identifier );
     77       
     78        // dump the definitions from a pre-defined context into the current scope
     79        void openContext( std::string contextName );
     80       
     81        void enterScope();
     82        void leaveScope();
     83        void enterContext( std::string contextName );
     84        void leaveContext();
    7085
    71     void print( void ) const;
     86        void print() const;
    7287};
    7388
    7489#endif // TYPEDEFTABLE_H
     90
     91// Local Variables: //
     92// tab-width: 4 //
     93// mode: c++ //
     94// compile-command: "make install" //
     95// End: //
Note: See TracChangeset for help on using the changeset viewer.