source: src/Parser/TypedefTable.h @ de62360d

aaron-thesisarm-ehcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerresolv-newstringwith_gc
Last change on this file since de62360d was de62360d, checked in by Peter A. Buhr <pabuhr@…>, 7 years ago

fix computed goto, fixed -std=, implicit typedefs for enum and aggregates, add _Noreturn _Thread_local

  • Property mode set to 100644
File size: 2.9 KB
Line 
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 : Thu Jun 18 21:03:17 2015
13// Update Count     : 7
14//
15
16#ifndef TYPEDEFTABLE_H
17#define TYPEDEFTABLE_H
18
19#include <map>
20#include <list>
21#include <string>
22#include <stack>
23
24class TypedefTable {
25  public:
26        enum kind_t { ID, TD, TG };
27  private:
28        struct Entry {
29                int scope;
30                kind_t kind;
31        };
32       
33        struct DeferredEntry {
34                std::string identifier;
35                kind_t kind;
36        };
37
38        typedef std::map<std::string, std::list<Entry> > tableType;
39        tableType table;
40
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;
50
51        bool isKind( const std::string &identifier, kind_t kind ) const;
52        void addToScope( const std::string &identifier, kind_t kind, int scope );
53  public:
54        TypedefTable();
55
56        bool isIdentifier( const std::string &identifier ) const;
57        bool isTypedef( const std::string &identifier ) const;
58        bool isTypegen( const 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()
64
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( const std::string &contextName );
80       
81        void enterScope();
82        void leaveScope();
83        void enterContext( const std::string &contextName );
84        void leaveContext();
85
86        void print() const;
87};
88
89#endif // TYPEDEFTABLE_H
90
91// Local Variables: //
92// tab-width: 4 //
93// mode: c++ //
94// compile-command: "make install" //
95// End: //
Note: See TracBrowser for help on using the repository browser.