- Timestamp:
- Jul 12, 2023, 7:26:16 AM (13 months ago)
- Branches:
- master
- Children:
- 71a422a
- Parents:
- bdbb448
- Location:
- src/Parser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/TypedefTable.cc
rbdbb448 rfc95df3 10 10 // Created On : Sat May 16 15:20:13 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 15 08:27:24 202213 // Update Count : 27 512 // Last Modified On : Wed Jul 12 06:11:28 2023 13 // Update Count : 276 14 14 // 15 15 … … 17 17 #include "TypedefTable.h" 18 18 19 #include <cassert> 20 #include <string> 21 #include <iostream> 19 #include <cassert> // for assert 20 #include <string> // for string 21 #include <iostream> // for iostream 22 22 23 #include "ExpressionNode.h" 24 #include "ParserTypes.h" 25 #include "StatementNode.h" 23 #include "ExpressionNode.h" // for LabelNode 24 #include "ParserTypes.h" // for Token 25 #include "StatementNode.h" // for CondCtl, ForCtrl 26 26 // This (generated) header must come late as it is missing includes. 27 #include "parser.hh" 27 #include "parser.hh" // for IDENTIFIER, TYPEDEFname, TYPEGENname 28 28 29 29 using namespace std; … … 72 72 // "struct". Only generate the typedef, if the name is not in use. The typedef is implicitly (silently) removed if the 73 73 // name is explicitly used. 74 void TypedefTable::makeTypedef( const string & name, int kind ) {74 void TypedefTable::makeTypedef( const string & name, int kind, const char * locn __attribute__((unused)) ) { 75 75 // Check for existence is necessary to handle: 76 76 // struct Fred {}; … … 80 80 // Fred(); 81 81 // } 82 debugPrint( cerr << "Make typedef at " << locn << " \"" << name << "\" as " << kindName( kind ) << " scope " << kindTable.currentScope() << endl ); 82 83 if ( ! typedefTable.exists( name ) ) { 83 84 typedefTable.addToEnclosingScope( name, kind, "MTD" ); … … 85 86 } // TypedefTable::makeTypedef 86 87 87 void TypedefTable::makeTypedef( const string & name ) { 88 return makeTypedef( name, TYPEDEFname ); 88 void TypedefTable::makeTypedef( const string & name, const char * locn __attribute__((unused)) ) { 89 debugPrint( cerr << "Make typedef at " << locn << " \"" << name << " scope " << kindTable.currentScope() << endl ); 90 return makeTypedef( name, TYPEDEFname, "makeTypede" ); 89 91 } // TypedefTable::makeTypedef 90 92 91 93 void TypedefTable::addToScope( const string & identifier, int kind, const char * locn __attribute__((unused)) ) { 92 94 KindTable::size_type scope = kindTable.currentScope(); 93 debugPrint( cerr << "Adding current at " << locn << " " << identifier <<" as " << kindName( kind ) << " scope " << scope << endl );95 debugPrint( cerr << "Adding current at " << locn << " \"" << identifier << "\" as " << kindName( kind ) << " scope " << scope << endl ); 94 96 kindTable.insertAt( scope, identifier, kind ); 95 97 } // TypedefTable::addToScope … … 98 100 KindTable::size_type scope = kindTable.currentScope() - 1 - kindTable.getNote( kindTable.currentScope() - 1 ).level; 99 101 // size_type scope = level - kindTable.getNote( kindTable.currentScope() - 1 ).level; 100 debugPrint( cerr << "Adding enclosing at " << locn << " " << identifier <<" as " << kindName( kind ) << " scope " << scope << " level " << level << " note " << kindTable.getNote( kindTable.currentScope() - 1 ).level << endl );102 debugPrint( cerr << "Adding enclosing at " << locn << " \"" << identifier << "\" as " << kindName( kind ) << " scope " << scope << " level " << level << " note " << kindTable.getNote( kindTable.currentScope() - 1 ).level << endl ); 101 103 pair< KindTable::iterator, bool > ret = kindTable.insertAt( scope, identifier, kind ); 102 104 if ( ! ret.second ) ret.first->second = kind; // exists => update -
src/Parser/TypedefTable.h
rbdbb448 rfc95df3 10 10 // Created On : Sat May 16 15:24:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Feb 15 08:06:37 202013 // Update Count : 11 712 // Last Modified On : Wed Jul 12 06:09:37 2023 13 // Update Count : 118 14 14 // 15 15 … … 21 21 22 22 class TypedefTable { 23 struct Note { size_t level; bool forall; }; 23 struct Note { 24 size_t level; 25 bool forall; 26 }; 24 27 typedef ScopedMap< std::string, int, Note > KindTable; 25 28 KindTable kindTable; … … 31 34 bool existsCurr( const std::string & identifier ) const; 32 35 int isKind( const std::string & identifier ) const; 33 void makeTypedef( const std::string & name, int kind );34 void makeTypedef( const std::string & name );36 void makeTypedef( const std::string & name, int kind, const char * ); 37 void makeTypedef( const std::string & name, const char * ); 35 38 void addToScope( const std::string & identifier, int kind, const char * ); 36 39 void addToEnclosingScope( const std::string & identifier, int kind, const char * );
Note: See TracChangeset
for help on using the changeset viewer.