Changeset 66406f3 for src/Parser


Ignore:
Timestamp:
Aug 8, 2022, 5:11:25 PM (2 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, ast-experimental, master, pthread-emulation
Children:
d78c238
Parents:
df00c78
Message:

update debug printing

Location:
src/Parser
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    rdf00c78 r66406f3  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jul 14 17:36:57 2021
    13 // Update Count     : 1154
     12// Last Modified On : Mon Aug  8 17:07:00 2022
     13// Update Count     : 1185
    1414//
    1515
     
    128128        if ( name ) {
    129129                os << *name << ": ";
    130         } else {
    131                 os << "unnamed: ";
    132130        } // if
    133131
     
    154152                initializer->printOneLine( os );
    155153                os << " maybe constructed? " << initializer->get_maybeConstructed();
    156 
    157         } // if
     154        } // if
     155
     156        for ( Attribute * attr: reverseIterate( attributes ) ) {
     157                os << string( indent + 2, ' ' ) << "attr " << attr->name.c_str();
     158        } // for
    158159
    159160        os << endl;
     
    243244        newnode->type = new TypeData( TypeData::Aggregate );
    244245        newnode->type->aggregate.kind = kind;
    245         newnode->type->aggregate.name =  name == nullptr ? new string( DeclarationNode::anonymous.newName() ) : name;
     246        newnode->type->aggregate.name = name == nullptr ? new string( DeclarationNode::anonymous.newName() ) : name;
    246247        newnode->type->aggregate.actuals = actuals;
    247248        newnode->type->aggregate.fields = fields;
     
    518519        storageClasses |= q->storageClasses;
    519520
    520         for ( Attribute *attr: reverseIterate( q->attributes ) ) {
     521        for ( Attribute * attr: reverseIterate( q->attributes ) ) {
    521522                attributes.push_front( attr->clone() );
    522523        } // for
     
    683684        } // if
    684685        delete o;
     686
    685687        return this;
    686688}
  • src/Parser/TypeData.cc

    rdf00c78 r66406f3  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 15:12:51 2015
    11 // Last Modified By : Henry Xue
    12 // Last Modified On : Tue Jul 20 04:10:50 2021
    13 // Update Count     : 673
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Tue May 10 22:36:52 2022
     13// Update Count     : 677
    1414//
    1515
     
    283283                if ( signedness != DeclarationNode::NoSignedness ) os << DeclarationNode::signednessNames[ signedness ] << " ";
    284284                if ( length != DeclarationNode::NoLength ) os << DeclarationNode::lengthNames[ length ] << " ";
    285                 if ( complextype == DeclarationNode::NoComplexType ) { // basic type
    286                         assert( basictype != DeclarationNode::NoBasicType );
    287                         os << DeclarationNode::basicTypeNames[ basictype ] << " ";
    288                 } else {                                                                                // complex type
    289                         // handle double _Complex
    290                         if ( basictype != DeclarationNode::NoBasicType ) os << DeclarationNode::basicTypeNames[ basictype ] << " ";
    291                         os << DeclarationNode::complexTypeNames[ complextype ] << " ";
    292                 } // if
     285                if ( complextype != DeclarationNode::NoComplexType ) os << DeclarationNode::complexTypeNames[ complextype ] << " ";
     286                if ( basictype != DeclarationNode::NoBasicType ) os << DeclarationNode::basicTypeNames[ basictype ] << " ";
    293287                break;
    294288          case Pointer:
     
    437431                        __attribute__((fallthrough));
    438432                #endif
     433                // FALL THROUGH
    439434          case Typeof:
    440435                os << "type-of expression ";
     
    442437                        typeexpr->print( os, indent + 2 );
    443438                } // if
     439                break;
     440          case Vtable:
     441                os << "vtable";
    444442                break;
    445443          case Builtin:
  • src/Parser/TypeData.h

    rdf00c78 r66406f3  
    1010// Created On       : Sat May 16 15:18:36 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jul 14 17:44:05 2021
    13 // Update Count     : 202
     12// Last Modified On : Tue May 10 22:18:49 2022
     13// Update Count     : 203
    1414//
    1515
     
    2727struct TypeData {
    2828        enum Kind { Basic, Pointer, Reference, Array, Function, Aggregate, AggregateInst, Enum, EnumConstant, Symbolic,
    29                                 SymbolicInst, Tuple, Typeof, Basetypeof, Vtable, Builtin, GlobalScope, Qualified, Unknown };
     29                                SymbolicInst, Tuple, Basetypeof, Typeof, Vtable, Builtin, GlobalScope, Qualified, Unknown };
    3030
    3131        struct Aggregate_t {
  • src/Parser/TypedefTable.cc

    rdf00c78 r66406f3  
    1010// Created On       : Sat May 16 15:20:13 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 19 08:30:14 2021
    13 // Update Count     : 262
     12// Last Modified On : Tue Feb 15 08:27:24 2022
     13// Update Count     : 275
    1414//
    1515
     
    1818#include <cassert>                                                                              // for assert
    1919#include <iostream>
     20using namespace std;
    2021
    2122#if 0
     
    2829
    2930debugPrint(
    30 static const char *kindName( int kind ) {
    31         switch ( kind ) {
    32           case IDENTIFIER: return "identifier";
    33           case TYPEDIMname: return "typedim";
    34           case TYPEDEFname: return "typedef";
    35           case TYPEGENname: return "typegen";
    36           default:
    37                 cerr << "Error: cfa-cpp internal error, invalid kind of identifier" << endl;
    38                 abort();
    39         } // switch
    40 } // kindName
    41 )
     31        static const char *kindName( int kind ) {
     32                switch ( kind ) {
     33                  case IDENTIFIER: return "identifier";
     34                  case TYPEDIMname: return "typedim";
     35                  case TYPEDEFname: return "typedef";
     36                  case TYPEGENname: return "typegen";
     37                  default:
     38                        cerr << "Error: cfa-cpp internal error, invalid kind of identifier" << endl;
     39                        abort();
     40                } // switch
     41        } // kindName
     42);
    4243
    4344TypedefTable::~TypedefTable() {
     
    8081
    8182void TypedefTable::addToScope( const string & identifier, int kind, const char * locn __attribute__((unused)) ) {
    82         auto scope = kindTable.currentScope();
     83        KindTable::size_type scope = kindTable.currentScope();
    8384        debugPrint( cerr << "Adding current at " << locn << " " << identifier << " as " << kindName( kind ) << " scope " << scope << endl );
    8485        kindTable.insertAt( scope, identifier, kind );
     
    8687
    8788void TypedefTable::addToEnclosingScope( const string & identifier, int kind, const char * locn __attribute__((unused)) ) {
    88         auto scope = kindTable.currentScope() - 1 - kindTable.getNote( kindTable.currentScope() - 1 ).level;
    89 //      auto scope = level - kindTable.getNote( kindTable.currentScope() - 1 ).level;
     89        KindTable::size_type scope = kindTable.currentScope() - 1 - kindTable.getNote( kindTable.currentScope() - 1 ).level;
     90//      size_type scope = level - kindTable.getNote( kindTable.currentScope() - 1 ).level;
    9091        debugPrint( cerr << "Adding enclosing at " << locn << " " << identifier << " as " << kindName( kind ) << " scope " << scope << " level " << level << " note " << kindTable.getNote( kindTable.currentScope() - 1 ).level << endl );
    91         auto ret = kindTable.insertAt( scope, identifier, kind );
     92        pair< KindTable::iterator, bool > ret = kindTable.insertAt( scope, identifier, kind );
    9293        if ( ! ret.second ) ret.first->second = kind;           // exists => update
    9394} // TypedefTable::addToEnclosingScope
Note: See TracChangeset for help on using the changeset viewer.