Ignore:
Timestamp:
Apr 15, 2016, 12:03:11 PM (9 years ago)
Author:
Thierry Delisle <tdelisle@…>
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.
Message:

Merge branch 'master' into gc_noraii

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/TypedefTable.cc

    rc5833e8 r0f9e4403  
    1010// Created On       : Sat May 16 15:20:13 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jun 26 07:30:16 2015
    13 // Update Count     : 19
     12// Last Modified On : Wed Apr 13 16:57:30 2016
     13// Update Count     : 24
    1414//
    1515
    1616#include <map>
    1717#include <list>
     18#include <cassert>
    1819#include "TypedefTable.h"
    19 #include <cassert>
    2020using namespace std;
    2121
     
    2929TypedefTable::TypedefTable() : currentScope( 0 ) {}
    3030
     31bool TypedefTable::exists( const string &identifier ) {
     32        return table.count( identifier ) > 0;
     33}
     34
     35int 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
    3142void TypedefTable::changeKind( const string &identifier, kind_t kind ) {
    3243        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.
     51void TypedefTable::makeTypedef( const string &name ) {
     52        if ( ! typedefTable.exists( name ) ) {
     53                typedefTable.addToEnclosingScope( name, TypedefTable::TD );
    3854        } // if
    3955}
    4056
    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         } // if
    48 }
    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 
    6257void TypedefTable::addToScope( const std::string &identifier, kind_t kind, int scope ) {
    63         if ( currentContext != "" && scope == contextScope ) {
     58        if ( currentTrait != "" && scope == contextScope ) {
    6459                DeferredEntry entry = { identifier, kind };
    65                 contexts[currentContext].push_back( entry );
     60                contexts[currentTrait].push_back( entry );
    6661        } else {
    6762                debugPrint( "Adding " << identifier << " as kind " << kind << " scope " << scope << " from scope " << currentScope << endl );
     
    112107}
    113108
    114 void TypedefTable::openContext( const std::string &contextName ) {
     109void TypedefTable::openTrait( const std::string &contextName ) {
    115110        map< string, deferListType >::iterator i = contexts.find( contextName );
    116111        if ( i != contexts.end() ) {
     
    150145}
    151146
    152 void TypedefTable::enterContext( const std::string &contextName ) {
    153         currentContext = contextName;
     147void TypedefTable::enterTrait( const std::string &contextName ) {
     148        currentTrait = contextName;
    154149        contextScope = currentScope;
    155150}
    156151
    157 void TypedefTable::leaveContext() {
    158         currentContext = "";
     152void TypedefTable::leaveTrait() {
     153        currentTrait = "";
    159154}
    160155
Note: See TracChangeset for help on using the changeset viewer.