Ignore:
Timestamp:
May 31, 2018, 4:05:01 PM (6 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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
Message:

more push/pop updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/TypedefTable.cc

    rbd946e4 r3d26610  
    1010// Created On       : Sat May 16 15:20:13 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue May 22 08:40:01 2018
    13 // Update Count     : 121
     12// Last Modified On : Wed May 30 18:04:38 2018
     13// Update Count     : 148
    1414//
    1515
     
    2020#if 0
    2121#include <iostream>
    22 #define debugPrint( x ) cerr << x
     22#define debugPrint( code ) code
    2323#else
    24 #define debugPrint( x )
     24#define debugPrint( code )
    2525#endif
    2626
     
    2929TypedefTable::~TypedefTable() {
    3030        if ( ! SemanticErrorThrow && kindTable.currentScope() != 0 ) {
    31                 // std::cerr << "scope failure " << kindTable.currentScope() << endl;
     31                std::cerr << "scope failure " << kindTable.currentScope() << endl;
    3232        } // if
    3333} // TypedefTable::~TypedefTable
     
    5454void TypedefTable::makeTypedef( const string & name ) {
    5555        if ( ! typedefTable.exists( name ) ) {
    56                 typedefTable.addToEnclosingScope( name, TYPEDEFname );
     56                typedefTable.addToEnclosingScope( name, TYPEDEFname /*, "MTD"*/ );
    5757        } // if
    5858} // TypedefTable::makeTypedef
    5959
    60 void TypedefTable::addToEnclosingScope( const std::string & identifier, int kind ) {
     60void 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
     67void TypedefTable::addToEnclosingScope( const std::string & identifier, int kind /*, const char * locn*/ ) {
    6168        assert( kindTable.currentScope() >= 1 );
    6269        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 );
    6471        auto ret = kindTable.insertAt( scope, identifier, kind );
    6572        if ( ! ret.second ) ret.first->second = kind;           // exists => update
     
    6875void TypedefTable::enterScope() {
    6976        kindTable.beginScope();
    70         debugPrint( "Entering scope " << kindTable.currentScope() << endl );
     77        debugPrint( cerr << "Entering scope " << kindTable.currentScope() << endl );
     78        debugPrint( print() );
    7179} // TypedefTable::enterScope
    7280
    7381void TypedefTable::leaveScope() {
    74         debugPrint( "Leaving scope " << kindTable.currentScope() << endl );
     82        debugPrint( cerr << "Leaving scope " << kindTable.currentScope() << endl );
     83        debugPrint( print() );
    7584        kindTable.endScope();
    7685} // TypedefTable::leaveScope
    7786
    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 // }
     87void 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}
    88103
    89104// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.