Changes in src/SynTree/Initializer.cc [d82daa1:50377a4]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Initializer.cc
rd82daa1 r50377a4 38 38 } 39 39 40 void Designation::print( std::ostream &os, intindent ) const {40 void Designation::print( std::ostream &os, Indenter indent ) const { 41 41 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; 46 47 } 47 os << std::endl;48 48 } // if 49 49 } … … 64 64 } 65 65 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 ); 66 void SingleInit::print( std::ostream &os, Indenter indent ) const { 67 os << "Simple Initializer: "; 68 value->print( os, indent ); 70 69 } 71 70 … … 93 92 } 94 93 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 ); 94 void 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 ); 103 101 os << std::endl; 102 if ( ! d->designators.empty() ) { 103 os << indent+1; 104 d->print( os, indent+1 ); 105 } 104 106 } 105 107 } … … 116 118 } 117 119 118 void ConstructorInit::print( std::ostream &os, intindent ) const {119 os << std::endl << std::string(indent, ' ') <<"Constructor initializer: " << std::endl;120 void ConstructorInit::print( std::ostream &os, Indenter indent ) const { 121 os << "Constructor initializer: " << std::endl; 120 122 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 ); 124 125 } // if 125 126 126 127 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 ); 130 130 } 131 131 132 132 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 ); 136 135 } 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;155 136 } 156 137
Note:
See TracChangeset
for help on using the changeset viewer.