Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Initializer.cc

    rd82daa1 r50377a4  
    3838}
    3939
    40 void Designation::print( std::ostream &os, int indent ) const {
     40void Designation::print( std::ostream &os, Indenter indent ) const {
    4141        if ( ! designators.empty() ) {
    42                 os << std::string(indent + 2, ' ' ) << "designated by: " << std::endl;
    43                 for ( std::list < Expression * >::const_iterator i = designators.begin(); i != designators.end(); i++ ) {
    44                         os << std::string(indent + 4, ' ' );
    45                         ( *i )->print(os, indent + 4 );
     42                os << "... designated by: " << std::endl;
     43                for ( const Expression * d : designators ) {
     44                        os << indent+1;
     45                        d->print(os, indent+1 );
     46                        os << std::endl;
    4647                }
    47                 os << std::endl;
    4848        } // if
    4949}
     
    6464}
    6565
    66 void SingleInit::print( std::ostream &os, int indent ) const {
    67         os << std::string(indent, ' ' ) << "Simple Initializer: " << std::endl;
    68         os << std::string(indent+4, ' ' );
    69         value->print( os, indent+4 );
     66void SingleInit::print( std::ostream &os, Indenter indent ) const {
     67        os << "Simple Initializer: ";
     68        value->print( os, indent );
    7069}
    7170
     
    9392}
    9493
    95 void ListInit::print( std::ostream &os, int indent ) const {
    96         os << std::string(indent, ' ') << "Compound initializer:  " << std::endl;
    97         for ( Designation * d : designations ) {
    98                 d->print( os, indent + 2 );
    99         }
    100 
    101         for ( const Initializer * init : initializers ) {
    102                 init->print( os, indent + 2 );
     94void ListInit::print( std::ostream &os, Indenter indent ) const {
     95        os << "Compound initializer: " << std::endl;
     96        for ( auto p : group_iterate( designations, initializers ) ) {
     97                const Designation * d = std::get<0>(p);
     98                const Initializer * init = std::get<1>(p);
     99                os << indent+1;
     100                init->print( os, indent+1 );
    103101                os << std::endl;
     102                if ( ! d->designators.empty() ) {
     103                        os << indent+1;
     104                        d->print( os, indent+1 );
     105                }
    104106        }
    105107}
     
    116118}
    117119
    118 void ConstructorInit::print( std::ostream &os, int indent ) const {
    119         os << std::endl << std::string(indent, ' ') << "Constructor initializer: " << std::endl;
     120void ConstructorInit::print( std::ostream &os, Indenter indent ) const {
     121        os << "Constructor initializer: " << std::endl;
    120122        if ( ctor ) {
    121                 os << std::string(indent+2, ' ');
    122                 os << "initially constructed with ";
    123                 ctor->print( os, indent+4 );
     123                os << indent << "... initially constructed with ";
     124                ctor->print( os, indent+1 );
    124125        } // if
    125126
    126127        if ( dtor ) {
    127                 os << std::string(indent+2, ' ');
    128                 os << "destructed with ";
    129                 dtor->print( os, indent+4 );
     128                os << indent << "... destructed with ";
     129                dtor->print( os, indent+1 );
    130130        }
    131131
    132132        if ( init ) {
    133                 os << std::string(indent+2, ' ');
    134                 os << "with fallback C-style initializer: ";
    135                 init->print( os, indent+4 );
     133                os << indent << "... with fallback C-style initializer: ";
     134                init->print( os, indent+1 );
    136135        }
    137 }
    138 
    139 std::ostream & operator<<( std::ostream & out, const Initializer * init ) {
    140         if ( init ) {
    141                 init->print( out );
    142         } else {
    143                 out << "nullptr";
    144         }
    145         return out;
    146 }
    147 
    148 std::ostream & operator<<( std::ostream & out, const Designation * des ) {
    149         if ( des ) {
    150                 des->print( out );
    151         } else {
    152                 out << "nullptr";
    153         }
    154         return out;
    155136}
    156137
Note: See TracChangeset for help on using the changeset viewer.