Changeset 3d26610 for src/Parser/TypedefTable.cc
- Timestamp:
- May 31, 2018, 4:05:01 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:
- b368dd8
- Parents:
- bd946e4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/TypedefTable.cc
rbd946e4 r3d26610 10 10 // Created On : Sat May 16 15:20:13 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue May 22 08:40:01201813 // Update Count : 1 2112 // Last Modified On : Wed May 30 18:04:38 2018 13 // Update Count : 148 14 14 // 15 15 … … 20 20 #if 0 21 21 #include <iostream> 22 #define debugPrint( x ) cerr << x22 #define debugPrint( code ) code 23 23 #else 24 #define debugPrint( x)24 #define debugPrint( code ) 25 25 #endif 26 26 … … 29 29 TypedefTable::~TypedefTable() { 30 30 if ( ! SemanticErrorThrow && kindTable.currentScope() != 0 ) { 31 //std::cerr << "scope failure " << kindTable.currentScope() << endl;31 std::cerr << "scope failure " << kindTable.currentScope() << endl; 32 32 } // if 33 33 } // TypedefTable::~TypedefTable … … 54 54 void TypedefTable::makeTypedef( const string & name ) { 55 55 if ( ! typedefTable.exists( name ) ) { 56 typedefTable.addToEnclosingScope( name, TYPEDEFname );56 typedefTable.addToEnclosingScope( name, TYPEDEFname /*, "MTD"*/ ); 57 57 } // if 58 58 } // TypedefTable::makeTypedef 59 59 60 void TypedefTable::addToEnclosingScope( const std::string & identifier, int kind ) { 60 void TypedefTable::addToScope( const std::string & identifier, int kind /*, const char * locn*/ ) { 61 auto scope = kindTable.currentScope(); 62 debugPrint( cerr << "Adding at " /* << locn */ << " " << identifier << " as kind " << kind << " scope " << scope << endl ); 63 auto ret = kindTable.insertAt( scope, identifier, kind ); 64 if ( ! ret.second ) ret.first->second = kind; // exists => update 65 } // TypedefTable::addToScope 66 67 void TypedefTable::addToEnclosingScope( const std::string & identifier, int kind /*, const char * locn*/ ) { 61 68 assert( kindTable.currentScope() >= 1 ); 62 69 auto scope = kindTable.currentScope() - 1; 63 debugPrint( "Adding" << identifier << " as kind " << kind << " scope " << scope << endl );70 debugPrint( cerr << "Adding2 at " /* << locn */ << " " << identifier << " as kind " << kind << " scope " << scope << endl ); 64 71 auto ret = kindTable.insertAt( scope, identifier, kind ); 65 72 if ( ! ret.second ) ret.first->second = kind; // exists => update … … 68 75 void TypedefTable::enterScope() { 69 76 kindTable.beginScope(); 70 debugPrint( "Entering scope " << kindTable.currentScope() << endl ); 77 debugPrint( cerr << "Entering scope " << kindTable.currentScope() << endl ); 78 debugPrint( print() ); 71 79 } // TypedefTable::enterScope 72 80 73 81 void TypedefTable::leaveScope() { 74 debugPrint( "Leaving scope " << kindTable.currentScope() << endl ); 82 debugPrint( cerr << "Leaving scope " << kindTable.currentScope() << endl ); 83 debugPrint( print() ); 75 84 kindTable.endScope(); 76 85 } // TypedefTable::leaveScope 77 86 78 // void TypedefTable::print( void ) const { 79 // for ( KindTable::const_iterator i = table.begin(); i != table.end(); i++) { 80 // debugPrint( (*i ).first << ": " ); 81 // list< Entry > declList = (*i).second; 82 // for ( list< Entry >::const_iterator j = declList.begin(); j != declList.end(); j++ ) { 83 // debugPrint( "(" << (*j).scope << " " << (*j).kind << ") " ); 84 // } 85 // debugPrint( endl ); 86 // } // for 87 // } 87 void TypedefTable::print( void ) const { 88 KindTable::size_type scope = kindTable.currentScope(); 89 debugPrint( cerr << "[" << scope << "]" ); 90 for ( KindTable::const_iterator i = kindTable.begin(); i != kindTable.end(); i++ ) { 91 while ( i.get_level() != scope ) { 92 --scope; 93 debugPrint( cerr << endl << "[" << scope << "]" ); 94 } // while 95 debugPrint( cerr << " " << (*i).first << ":" << (*i).second ); 96 } // for 97 while ( scope > 0 ) { 98 --scope; 99 debugPrint( cerr << endl << "[" << scope << "]" ); 100 } 101 debugPrint( cerr << endl ); 102 } 88 103 89 104 // Local Variables: //
Note: See TracChangeset
for help on using the changeset viewer.