Changeset eba74ba for src/Parser/TypedefTable.h
- Timestamp:
- May 25, 2018, 2:51:06 PM (6 years ago)
- Branches:
- new-env, with_gc
- Children:
- cdc4d43
- Parents:
- 3ef35bd (diff), 58e822a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/TypedefTable.h
r3ef35bd reba74ba 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 : Tue May 22 08:39:29 2018 13 // Update Count : 77 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 { 25 typedef ScopedMap< std::string, int > KindTable; 26 KindTable kindTable; 27 27 public: 28 enum kind_t { ID = IDENTIFIER, TD = TYPEDEFname, TG = TYPEGENname }; 29 private: 30 struct Entry { 31 int scope; 32 kind_t kind; 33 }; 28 ~TypedefTable(); 34 29 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 ); 30 bool exists( const std::string & identifier ); 31 int isKind( const std::string & identifier ) const; 32 void changeKind( const std::string & identifier, int kind ); 33 void makeTypedef( const std::string & name ); 34 void addToEnclosingScope( const std::string & identifier, int kind ); 83 35 84 36 void enterScope(); 85 37 void leaveScope(); 86 void enterTrait( const std::string &contextName ); 87 void leaveTrait(); 88 89 void print() const; 90 }; 38 }; // TypedefTable 91 39 92 40 // Local Variables: //
Note: See TracChangeset
for help on using the changeset viewer.