Changeset 0f9e4403 for src/Parser/TypedefTable.cc
- Timestamp:
- Apr 15, 2016, 12:03:11 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 29ad0ac
- Parents:
- c5833e8 (diff), 37f0da8 (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.cc
rc5833e8 r0f9e4403 10 10 // Created On : Sat May 16 15:20:13 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jun 26 07:30:16 201513 // Update Count : 1912 // Last Modified On : Wed Apr 13 16:57:30 2016 13 // Update Count : 24 14 14 // 15 15 16 16 #include <map> 17 17 #include <list> 18 #include <cassert> 18 19 #include "TypedefTable.h" 19 #include <cassert>20 20 using namespace std; 21 21 … … 29 29 TypedefTable::TypedefTable() : currentScope( 0 ) {} 30 30 31 bool TypedefTable::exists( const string &identifier ) { 32 return table.count( identifier ) > 0; 33 } 34 35 int TypedefTable::isKind( const string &identifier ) const { 36 tableType::const_iterator id_pos = table.find( identifier ); 37 // Name lookup defaults to identifier, and then the identifier's kind is set by the parser. 38 if ( id_pos == table.end() ) return IDENTIFIER; 39 return id_pos->second.begin()->kind; 40 } 41 31 42 void TypedefTable::changeKind( const string &identifier, kind_t kind ) { 32 43 tableType::iterator id_pos = table.find( identifier ); 33 if ( id_pos == table.end() ) { 34 return; 35 } else { 36 (*((*id_pos ).second.begin())).kind = kind; 37 return; 44 if ( id_pos == table.end() ) return; 45 id_pos->second.begin()->kind = kind; 46 } 47 48 // SKULLDUGGERY: Generate a typedef for the aggregate name so the aggregate does not have to be qualified by 49 // "struct". Only generate the typedef, if the name is not in use. The typedef is implicitly (silently) removed 50 // if the name is explicitly used. 51 void TypedefTable::makeTypedef( const string &name ) { 52 if ( ! typedefTable.exists( name ) ) { 53 typedefTable.addToEnclosingScope( name, TypedefTable::TD ); 38 54 } // if 39 55 } 40 56 41 bool TypedefTable::isKind( const string &identifier, kind_t kind ) const {42 tableType::const_iterator id_pos = table.find( identifier );43 if ( id_pos == table.end() ) {44 return true;45 } else {46 return (*((*id_pos ).second.begin())).kind == kind;47 } // if48 }49 50 bool TypedefTable::isIdentifier( const string &identifier ) const {51 return isKind( identifier, ID );52 }53 54 bool TypedefTable::isTypedef( const string &identifier ) const {55 return isKind( identifier, TD );56 }57 58 bool TypedefTable::isTypegen( const string &identifier ) const {59 return isKind( identifier, TG );60 }61 62 57 void TypedefTable::addToScope( const std::string &identifier, kind_t kind, int scope ) { 63 if ( current Context != "" && scope == contextScope ) {58 if ( currentTrait != "" && scope == contextScope ) { 64 59 DeferredEntry entry = { identifier, kind }; 65 contexts[current Context].push_back( entry );60 contexts[currentTrait].push_back( entry ); 66 61 } else { 67 62 debugPrint( "Adding " << identifier << " as kind " << kind << " scope " << scope << " from scope " << currentScope << endl ); … … 112 107 } 113 108 114 void TypedefTable::open Context( const std::string &contextName ) {109 void TypedefTable::openTrait( const std::string &contextName ) { 115 110 map< string, deferListType >::iterator i = contexts.find( contextName ); 116 111 if ( i != contexts.end() ) { … … 150 145 } 151 146 152 void TypedefTable::enter Context( const std::string &contextName ) {153 current Context = contextName;147 void TypedefTable::enterTrait( const std::string &contextName ) { 148 currentTrait = contextName; 154 149 contextScope = currentScope; 155 150 } 156 151 157 void TypedefTable::leave Context() {158 current Context = "";152 void TypedefTable::leaveTrait() { 153 currentTrait = ""; 159 154 } 160 155
Note:
See TracChangeset
for help on using the changeset viewer.