source: translator/Parser.old/TypedefTable.h @ 3c70d38

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 3c70d38 was 51b7345, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

initial commit

  • Property mode set to 100644
File size: 2.6 KB
Line 
1/*
2 * This file is part of the Cforall project
3 *
4 * $Id: TypedefTable.h,v 1.5 2003/05/11 15:24:05 rcbilson Exp $
5 *
6 */
7
8#ifndef TYPEDEFTABLE_H
9#define TYPEDEFTABLE_H
10
11#include <map>
12#include <list>
13#include <string>
14#include <stack>
15
16class TypedefTable
17{
18  public:
19    enum kind_t { ID, TD, TG };
20  private:
21    struct Entry
22    {
23        int scope;
24        kind_t kind;
25    };
26   
27    struct DeferredEntry
28    {
29      std::string identifier;
30      kind_t kind;
31    };
32
33    typedef std::map<std::string, std::list<Entry> > tableType;
34    tableType table;
35
36    int currentScope;
37    std::string currentContext;
38    int contextScope;
39   
40    typedef std::list< DeferredEntry > deferListType;
41    std::stack< deferListType > deferListStack;
42    std::map< std::string, deferListType > contexts;
43   
44    std::stack< std::string > nextIdentifiers;
45
46    bool isKind(std::string identifier, kind_t kind) const;
47    void addToScope(const std::string &identifier, kind_t kind, int scope);
48  public:
49    TypedefTable();
50
51    bool isIdentifier(std::string identifier) const;
52    bool isTypedef(std::string identifier) const;
53    bool isTypegen(std::string identifier) const;
54   
55    // "addToCurrentScope" adds the identifier/type pair to the current scope This does less
56    // than you think it does, since each declaration is within its own scope.  Mostly useful for
57    // type parameters.
58    void addToCurrentScope(const std::string &identifier, kind_t kind);
59    void addToCurrentScope(kind_t kind);   // use nextIdentifiers.top()
60
61    // "addToEnclosingScope" adds the identifier/type pair to the scope that encloses the current
62    // one.  This is the right way to handle type and typedef names
63    void addToEnclosingScope(const std::string &identifier, kind_t kind);
64    void addToEnclosingScope(kind_t kind); // use nextIdentifiers.top()
65   
66    // "addToEnclosingScope2" adds the identifier/type pair to the scope that encloses the scope
67    // enclosing the the current one.  This is the right way to handle assertion names
68    void addToEnclosingScope2(const std::string &identifier, kind_t kind);
69    void addToEnclosingScope2(kind_t kind); // use nextIdentifiers.top()
70   
71    // set the next identifier to be used by an "add" operation without an identifier parameter
72    // within the current scope
73    void setNextIdentifier( const std::string &identifier );
74   
75    // dump the definitions from a pre-defined context into the current scope
76    void openContext( std::string contextName );
77   
78    void enterScope(void);
79    void leaveScope(void);
80    void enterContext( std::string contextName );
81    void leaveContext(void);
82
83    void print(void) const;
84};
85
86#endif /* ifndef TYPEDEFTABLE_H */
Note: See TracBrowser for help on using the repository browser.