source: src/Parser/TypedefTable.h @ d0d9610

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change on this file since d0d9610 was 721f17a, checked in by Peter A. Buhr <pabuhr@…>, 9 years ago

fix OT_LABELADDRESS warning, parse genric types

  • Property mode set to 100644
File size: 3.0 KB
RevLine 
[b87a5ed]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
[721f17a]12// Last Modified On : Thu Jun 25 22:52:15 2015
13// Update Count     : 11
[b87a5ed]14//
15
[51b7345]16#ifndef TYPEDEFTABLE_H
17#define TYPEDEFTABLE_H
18
19#include <map>
20#include <list>
21#include <string>
22#include <stack>
23
[c8ffe20b]24class TypedefTable {
[51b7345]25  public:
[b87a5ed]26        enum kind_t { ID, TD, TG };
[51b7345]27  private:
[b87a5ed]28        struct Entry {
29                int scope;
30                kind_t kind;
31        };
32       
33        struct DeferredEntry {
34                std::string identifier;
35                kind_t kind;
36        };
[51b7345]37
[b87a5ed]38        typedef std::map<std::string, std::list<Entry> > tableType;
39        tableType table;
[51b7345]40
[b87a5ed]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;
[51b7345]50
[de62360d]51        bool isKind( const std::string &identifier, kind_t kind ) const;
[b87a5ed]52        void addToScope( const std::string &identifier, kind_t kind, int scope );
[51b7345]53  public:
[b87a5ed]54        TypedefTable();
[51b7345]55
[de62360d]56        bool isIdentifier( const std::string &identifier ) const;
57        bool isTypedef( const std::string &identifier ) const;
58        bool isTypegen( const std::string &identifier ) const;
[721f17a]59
60        void changeKind( const std::string &identifier, kind_t kind );
[b87a5ed]61       
[de62360d]62        // "addToCurrentScope" adds the identifier/type pair to the current scope. This does less than you think it does,
[b87a5ed]63        // since each declaration is within its own scope.  Mostly useful for type parameters.
64        void addToCurrentScope( const std::string &identifier, kind_t kind );
[721f17a]65        void addToCurrentScope( kind_t kind );                  // use nextIdentifiers.top()
[51b7345]66
[b87a5ed]67        // "addToEnclosingScope" adds the identifier/type pair to the scope that encloses the current one.  This is the
68        // right way to handle type and typedef names
69        void addToEnclosingScope( const std::string &identifier, kind_t kind );
70        void addToEnclosingScope( kind_t kind );                // use nextIdentifiers.top()
71       
72        // "addToEnclosingScope2" adds the identifier/type pair to the scope that encloses the scope enclosing the the
73        // current one.  This is the right way to handle assertion names
74        void addToEnclosingScope2( const std::string &identifier, kind_t kind );
75        void addToEnclosingScope2( kind_t kind );               // use nextIdentifiers.top()
76       
77        // set the next identifier to be used by an "add" operation without an identifier parameter within the current scope
78        void setNextIdentifier( const std::string &identifier );
79       
80        // dump the definitions from a pre-defined context into the current scope
[de62360d]81        void openContext( const std::string &contextName );
[b87a5ed]82       
83        void enterScope();
84        void leaveScope();
[de62360d]85        void enterContext( const std::string &contextName );
[b87a5ed]86        void leaveContext();
[51b7345]87
[b87a5ed]88        void print() const;
[51b7345]89};
90
[c8ffe20b]91#endif // TYPEDEFTABLE_H
[b87a5ed]92
93// Local Variables: //
94// tab-width: 4 //
95// mode: c++ //
96// compile-command: "make install" //
97// End: //
Note: See TracBrowser for help on using the repository browser.