Ignore:
Timestamp:
Oct 2, 2017, 4:39:42 PM (4 years ago)
Author:
Rob Schluntz <rschlunt@…>
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, resolv-new, with_gc
Children:
bf4b4cf
Parents:
a8555c5
Message:

Refactor tree print code to use Indenter

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/ObjectDecl.cc

    ra8555c5 r50377a4  
    4444}
    4545
    46 void ObjectDecl::print( std::ostream &os, int indent ) const {
    47         if ( get_name() != "" ) {
    48                 os << get_name() << ": ";
     46void ObjectDecl::print( std::ostream &os, Indenter indent ) const {
     47        if ( name != "" ) os << name << ": ";
     48
     49        if ( linkage != LinkageSpec::Cforall ) {
     50                os << LinkageSpec::linkageName( linkage ) << " ";
    4951        } // if
    50 
    51         if ( get_linkage() != LinkageSpec::Cforall ) {
    52                 os << LinkageSpec::linkageName( get_linkage() ) << " ";
    53         } // if
    54 
    55         printAll( get_attributes(), os, indent );
    5652
    5753        get_storageClasses().print( os );
    5854
    59         if ( get_type() ) {
    60                 get_type()->print( os, indent );
     55        if ( type ) {
     56                type->print( os, indent );
    6157        } else {
    6258                os << " untyped entity ";
     
    6460
    6561        if ( init ) {
    66                 os << " with initializer " << std::endl;
    67                 init->print( os, indent+2 );
    68                 os << std::endl << std::string(indent+2, ' ');
    69                 os << "maybeConstructed? " << init->get_maybeConstructed();
     62                os << " with initializer (" << (init->get_maybeConstructed() ? "maybe constructed" : "not constructed") << ")" << std::endl << indent+1;
     63                init->print( os, indent+1 );
     64                os << std::endl;
    7065        } // if
    7166
     67        if ( ! attributes.empty() ) {
     68                os << std::endl << indent << "... with attributes: " << std::endl;
     69                printAll( attributes, os, indent+1 );
     70        }
     71
    7272        if ( bitfieldWidth ) {
    73                 os << std::string(indent, ' ');
    74                 os << " with bitfield width ";
     73                os << indent << " with bitfield width ";
    7574                bitfieldWidth->print( os );
    7675        } // if
    7776}
    7877
    79 void ObjectDecl::printShort( std::ostream &os, int indent ) const {
     78void ObjectDecl::printShort( std::ostream &os, Indenter indent ) const {
    8079#if 0
    8180        if ( get_mangleName() != "") {
     
    8382        } else
    8483#endif
    85         if ( get_name() != "" ) {
    86                 os << get_name() << ": ";
    87         } // if
    88 
    89         // xxx - should printShort print attributes?
     84        if ( name != "" ) os << name << ": ";
    9085
    9186        get_storageClasses().print( os );
    9287
    93         if ( get_type() ) {
    94                 get_type()->print( os, indent );
     88        if ( type ) {
     89                type->print( os, indent );
    9590        } else {
    9691                os << "untyped entity ";
Note: See TracChangeset for help on using the changeset viewer.