Changeset 7fdb94e for src/Parser/TypedefTable.h
- Timestamp:
- May 21, 2018, 10:48:05 PM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
- Children:
- b12c036
- Parents:
- 4358c1e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/TypedefTable.h
r4358c1e r7fdb94e 7 7 // TypedefTable.h -- 8 8 // 9 // Author : Rodolfo G. Esteves9 // Author : Peter A. Buhr 10 10 // Created On : Sat May 16 15:24:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jul 22 09:33:14 201713 // Update Count : 3412 // Last Modified On : Mon May 21 20:28:01 2018 13 // Update Count : 76 14 14 // 15 15 16 16 #pragma once 17 17 18 #include <list> // for list 19 #include <map> // for map, map<>::value_compare 20 #include <stack> // for stack 21 #include <string> // for string 18 #include <string> // for string 22 19 20 #include "Common/ScopedMap.h" // for ScopedMap 23 21 #include "ParserTypes.h" 24 #include "parser.hh" 22 #include "parser.hh" // for IDENTIFIER, TYPEDEFname, TYPEGENname 25 23 26 24 class TypedefTable { … … 28 26 enum kind_t { ID = IDENTIFIER, TD = TYPEDEFname, TG = TYPEGENname }; 29 27 private: 30 struct Entry {31 int scope;32 kind_t kind; 33 };28 typedef ScopedMap< std::string, kind_t > KindTable; 29 KindTable kindTable; 30 public: 31 ~TypedefTable(); 34 32 35 struct DeferredEntry { 36 std::string identifier; 37 kind_t kind; 38 }; 39 40 typedef std::map< std::string, std::list< Entry > > tableType; 41 tableType table; 42 43 int currentScope; 44 std::string currentTrait; 45 int contextScope; 46 47 typedef std::list< DeferredEntry > deferListType; 48 std::stack< deferListType > deferListStack; 49 std::map< std::string, deferListType > contexts; 50 51 std::stack< std::string > nextIdentifiers; 52 53 void addToScope( const std::string &identifier, kind_t kind, int scope ); 54 public: 55 TypedefTable(); 56 57 bool exists( const std::string &identifier ); 58 int isKind( const std::string &identifier ) const; 59 void changeKind( const std::string &identifier, kind_t kind ); 60 61 void makeTypedef( const std::string &name ); 62 63 // "addToCurrentScope" adds the identifier/type pair to the current scope. This does less than you think it does, 64 // since each declaration is within its own scope. Mostly useful for type parameters. 65 void addToCurrentScope( const std::string &identifier, kind_t kind ); 66 void addToCurrentScope( kind_t kind ); // use nextIdentifiers.top() 67 68 // "addToEnclosingScope" adds the identifier/type pair to the scope that encloses the current one. This is the 69 // right way to handle type and typedef names 70 void addToEnclosingScope( const std::string &identifier, kind_t kind ); 71 void addToEnclosingScope( kind_t kind ); // use nextIdentifiers.top() 72 73 // "addToEnclosingScope2" adds the identifier/type pair to the scope that encloses the scope enclosing the the 74 // current one. This is the right way to handle assertion names 75 void addToEnclosingScope2( const std::string &identifier, kind_t kind ); 76 void addToEnclosingScope2( kind_t kind ); // use nextIdentifiers.top() 77 78 // set the next identifier to be used by an "add" operation without an identifier parameter within the current scope 79 void setNextIdentifier( const std::string &identifier ); 80 81 // dump the definitions from a pre-defined context into the current scope 82 void openTrait( const std::string &contextName ); 33 bool exists( const std::string & identifier ); 34 int isKind( const std::string & identifier ) const; 35 void changeKind( const std::string & identifier, kind_t kind ); 36 void makeTypedef( const std::string & name ); 37 void addToEnclosingScope( const std::string & identifier, kind_t kind ); 83 38 84 39 void enterScope(); 85 40 void leaveScope(); 86 void enterTrait( const std::string &contextName ); 87 void leaveTrait(); 88 89 void print() const; 90 }; 41 }; // TypedefTable 91 42 92 43 // Local Variables: //
Note: See TracChangeset
for help on using the changeset viewer.