Ignore:
Timestamp:
May 22, 2018, 9:26:14 AM (4 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, with_gc
Children:
3d2ae8d, cac8a6e
Parents:
21bdce2
Message:

simplify TypedefTable?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/TypedefTable.cc

    r21bdce2 r2f0a0678  
    1010// Created On       : Sat May 16 15:20:13 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon May 21 20:55:24 2018
    13 // Update Count     : 117
     12// Last Modified On : Tue May 22 08:40:01 2018
     13// Update Count     : 121
    1414//
    1515
    1616
    1717#include "TypedefTable.h"
    18 #include <cassert>               // for assert
     18#include <cassert>                                                                              // for assert
    1919
    2020#if 0
     
    2525#endif
    2626
    27 using namespace std;
     27using namespace std;                                                                    // string, iostream
    2828
    2929TypedefTable::~TypedefTable() {
     
    3838
    3939int TypedefTable::isKind( const string & identifier ) const {
     40        KindTable::const_iterator posn = kindTable.find( identifier );
    4041        // Name lookup defaults to identifier, and then the identifier's kind is set by the parser.
    41         KindTable::const_iterator posn = kindTable.find( identifier );
    4242        if ( posn == kindTable.end() ) return IDENTIFIER;
    4343        return posn->second;
    4444} // TypedefTable::isKind
    4545
    46 void TypedefTable::changeKind( const string & identifier, kind_t kind ) {
     46void TypedefTable::changeKind( const string & identifier, int kind ) {
    4747        KindTable::iterator posn = kindTable.find( identifier );
    48         if ( posn != kindTable.end() ) posn->second = kind;
     48        if ( posn != kindTable.end() ) posn->second = kind;     // exists => update
    4949} // TypedefTable::changeKind
    5050
     
    5454void TypedefTable::makeTypedef( const string & name ) {
    5555        if ( ! typedefTable.exists( name ) ) {
    56                 typedefTable.addToEnclosingScope( name, TypedefTable::TD );
     56                typedefTable.addToEnclosingScope( name, TYPEDEFname );
    5757        } // if
    5858} // TypedefTable::makeTypedef
    5959
    60 void TypedefTable::addToEnclosingScope( const std::string & identifier, kind_t kind ) {
     60void TypedefTable::addToEnclosingScope( const std::string & identifier, int kind ) {
    6161        assert( kindTable.currentScope() >= 1 );
    6262        auto scope = kindTable.currentScope() - 1;
    6363        debugPrint( "Adding " << identifier << " as kind " << kind << " scope " << scope << endl );
    6464        auto ret = kindTable.insertAt( scope, identifier, kind );
    65         if ( ! ret.second ) { // already an element there
    66                 ret.first->second = kind; // update existing element with new kind
    67         } // if
     65        if ( ! ret.second ) ret.first->second = kind;           // exists => update
    6866} // TypedefTable::addToEnclosingScope
    6967
Note: See TracChangeset for help on using the changeset viewer.