Changes in src/SynTree/Expression.cc [bf4b4cf:d67cdb7]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Expression.cc
rbf4b4cf rd67cdb7 33 33 #include "GenPoly/Lvalue.h" 34 34 35 Expression::Expression( ) : result( 0 ), env( 0) {}36 37 Expression::Expression( const Expression &other ) : BaseSyntaxNode( other ), result( maybeClone( other.result ) ), env( maybeClone( other.env ) ), extension( other.extension ) {35 Expression::Expression( Expression *_aname ) : result( 0 ), env( 0 ), argName( _aname ) {} 36 37 Expression::Expression( const Expression &other ) : BaseSyntaxNode( other ), result( maybeClone( other.result ) ), env( maybeClone( other.env ) ), argName( maybeClone( other.get_argName() ) ), extension( other.extension ) { 38 38 } 39 39 40 40 Expression::~Expression() { 41 41 delete env; 42 delete argName; // xxx -- there's a problem in cloning ConstantExpr I still don't know how to fix 42 43 delete result; 43 44 } 44 45 45 void Expression::print( std::ostream &os, Indenterindent ) const {46 void Expression::print( std::ostream &os, int indent ) const { 46 47 if ( env ) { 47 os << std:: endl << indent << "...with environment:" << std::endl;48 env->print( os, indent+ 1);48 os << std::string( indent, ' ' ) << "with environment:" << std::endl; 49 env->print( os, indent+2 ); 49 50 } // if 50 51 52 if ( argName ) { 53 os << std::string( indent, ' ' ) << "with designator:"; 54 argName->print( os, indent+2 ); 55 } // if 56 51 57 if ( extension ) { 52 os << std:: endl << indent << "...with extension:";58 os << std::string( indent, ' ' ) << "with extension:"; 53 59 } // if 54 60 } 55 61 56 ConstantExpr::ConstantExpr( Constant _c ) : Expression(), constant( _c ) {62 ConstantExpr::ConstantExpr( Constant _c, Expression *_aname ) : Expression( _aname ), constant( _c ) { 57 63 set_result( constant.get_type()->clone() ); 58 64 } … … 63 69 ConstantExpr::~ConstantExpr() {} 64 70 65 void ConstantExpr::print( std::ostream &os, Indenterindent ) const {71 void ConstantExpr::print( std::ostream &os, int indent ) const { 66 72 os << "constant expression " ; 67 73 constant.print( os ); … … 69 75 } 70 76 71 VariableExpr::VariableExpr( DeclarationWithType *_var ) : Expression(), var( _var ) {77 VariableExpr::VariableExpr( DeclarationWithType *_var, Expression *_aname ) : Expression( _aname ), var( _var ) { 72 78 assert( var ); 73 79 assert( var->get_type() ); … … 90 96 } 91 97 92 void VariableExpr::print( std::ostream &os, Indenterindent ) const {98 void VariableExpr::print( std::ostream &os, int indent ) const { 93 99 os << "Variable Expression: "; 94 var->printShort(os, indent); 95 Expression::print( os, indent ); 96 } 97 98 SizeofExpr::SizeofExpr( Expression *expr_ ) : 99 Expression(), expr(expr_), type(0), isType(false) { 100 101 Declaration *decl = get_var(); 102 if ( decl != 0) decl->printShort(os, indent + 2); 103 os << std::endl; 104 Expression::print( os, indent ); 105 } 106 107 SizeofExpr::SizeofExpr( Expression *expr_, Expression *_aname ) : 108 Expression( _aname ), expr(expr_), type(0), isType(false) { 100 109 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 101 110 } 102 111 103 SizeofExpr::SizeofExpr( Type *type_ ) :104 Expression( ), expr(0), type(type_), isType(true) {112 SizeofExpr::SizeofExpr( Type *type_, Expression *_aname ) : 113 Expression( _aname ), expr(0), type(type_), isType(true) { 105 114 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 106 115 } … … 115 124 } 116 125 117 void SizeofExpr::print( std::ostream &os, Indenterindent) const {126 void SizeofExpr::print( std::ostream &os, int indent) const { 118 127 os << "Sizeof Expression on: "; 119 if (isType) type->print(os, indent+1); 120 else expr->print(os, indent+1); 121 Expression::print( os, indent ); 122 } 123 124 AlignofExpr::AlignofExpr( Expression *expr_ ) : 125 Expression(), expr(expr_), type(0), isType(false) { 128 129 if (isType) 130 type->print(os, indent + 2); 131 else 132 expr->print(os, indent + 2); 133 134 os << std::endl; 135 Expression::print( os, indent ); 136 } 137 138 AlignofExpr::AlignofExpr( Expression *expr_, Expression *_aname ) : 139 Expression( _aname ), expr(expr_), type(0), isType(false) { 126 140 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 127 141 } 128 142 129 AlignofExpr::AlignofExpr( Type *type_ ) :130 Expression( ), expr(0), type(type_), isType(true) {143 AlignofExpr::AlignofExpr( Type *type_, Expression *_aname ) : 144 Expression( _aname ), expr(0), type(type_), isType(true) { 131 145 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 132 146 } … … 141 155 } 142 156 143 void AlignofExpr::print( std::ostream &os, Indenterindent) const {157 void AlignofExpr::print( std::ostream &os, int indent) const { 144 158 os << "Alignof Expression on: "; 145 if (isType) type->print(os, indent+1); 146 else expr->print(os, indent+1); 147 Expression::print( os, indent ); 148 } 149 150 UntypedOffsetofExpr::UntypedOffsetofExpr( Type *type, const std::string &member ) : 151 Expression(), type(type), member(member) { 152 assert( type ); 159 160 if (isType) 161 type->print(os, indent + 2); 162 else 163 expr->print(os, indent + 2); 164 165 os << std::endl; 166 Expression::print( os, indent ); 167 } 168 169 UntypedOffsetofExpr::UntypedOffsetofExpr( Type *type_, const std::string &member_, Expression *_aname ) : 170 Expression( _aname ), type(type_), member(member_) { 153 171 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 154 172 } … … 161 179 } 162 180 163 void UntypedOffsetofExpr::print( std::ostream &os, Indenter indent) const { 164 os << "Untyped Offsetof Expression on member " << member << " of "; 165 type->print(os, indent+1); 166 Expression::print( os, indent ); 167 } 168 169 OffsetofExpr::OffsetofExpr( Type *type, DeclarationWithType *member ) : 170 Expression(), type(type), member(member) { 171 assert( member ); 172 assert( type ); 181 void UntypedOffsetofExpr::print( std::ostream &os, int indent) const { 182 os << std::string( indent, ' ' ) << "Untyped Offsetof Expression on member " << member << " of "; 183 184 if ( type ) { 185 type->print(os, indent + 2); 186 } else { 187 os << "<NULL>"; 188 } 189 190 os << std::endl; 191 Expression::print( os, indent ); 192 } 193 194 OffsetofExpr::OffsetofExpr( Type *type_, DeclarationWithType *member_, Expression *_aname ) : 195 Expression( _aname ), type(type_), member(member_) { 173 196 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 174 197 } … … 181 204 } 182 205 183 void OffsetofExpr::print( std::ostream &os, Indenter indent) const { 184 os << "Offsetof Expression on member " << member->name << " of "; 185 type->print(os, indent+1); 186 Expression::print( os, indent ); 187 } 188 189 OffsetPackExpr::OffsetPackExpr( StructInstType *type ) : Expression(), type( type ) { 190 assert( type ); 206 void OffsetofExpr::print( std::ostream &os, int indent) const { 207 os << std::string( indent, ' ' ) << "Offsetof Expression on member "; 208 209 if ( member ) { 210 os << member->get_name(); 211 } else { 212 os << "<NULL>"; 213 } 214 215 os << " of "; 216 217 if ( type ) { 218 type->print(os, indent + 2); 219 } else { 220 os << "<NULL>"; 221 } 222 223 os << std::endl; 224 Expression::print( os, indent ); 225 } 226 227 OffsetPackExpr::OffsetPackExpr( StructInstType *type_, Expression *aname_ ) : Expression( aname_ ), type( type_ ) { 191 228 set_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) ); 192 229 } … … 196 233 OffsetPackExpr::~OffsetPackExpr() { delete type; } 197 234 198 void OffsetPackExpr::print( std::ostream &os, Indenter indent ) const { 199 os << "Offset pack expression on "; 200 type->print(os, indent+1); 201 Expression::print( os, indent ); 202 } 203 204 AttrExpr::AttrExpr( Expression *attr, Expression *expr_ ) : 205 Expression(), attr( attr ), expr(expr_), type(0), isType(false) { 206 } 207 208 AttrExpr::AttrExpr( Expression *attr, Type *type_ ) : 209 Expression(), attr( attr ), expr(0), type(type_), isType(true) { 235 void OffsetPackExpr::print( std::ostream &os, int indent ) const { 236 os << std::string( indent, ' ' ) << "Offset pack expression on "; 237 238 if ( type ) { 239 type->print(os, indent + 2); 240 } else { 241 os << "<NULL>"; 242 } 243 244 os << std::endl; 245 Expression::print( os, indent ); 246 } 247 248 AttrExpr::AttrExpr( Expression *attr, Expression *expr_, Expression *_aname ) : 249 Expression( _aname ), attr( attr ), expr(expr_), type(0), isType(false) { 250 } 251 252 AttrExpr::AttrExpr( Expression *attr, Type *type_, Expression *_aname ) : 253 Expression( _aname ), attr( attr ), expr(0), type(type_), isType(true) { 210 254 } 211 255 … … 220 264 } 221 265 222 void AttrExpr::print( std::ostream &os, Indenterindent) const {266 void AttrExpr::print( std::ostream &os, int indent) const { 223 267 os << "Attr "; 224 attr->print( os, indent +1);268 attr->print( os, indent + 2 ); 225 269 if ( isType || expr ) { 226 270 os << "applied to: "; 227 if (isType) type->print(os, indent+1); 228 else expr->print(os, indent+1); 271 272 if (isType) 273 type->print(os, indent + 2); 274 else 275 expr->print(os, indent + 2); 229 276 } // if 230 Expression::print( os, indent ); 231 } 232 233 CastExpr::CastExpr( Expression *arg_, Type *toType ) : Expression(), arg(arg_) { 277 278 os << std::endl; 279 Expression::print( os, indent ); 280 } 281 282 CastExpr::CastExpr( Expression *arg_, Type *toType, Expression *_aname ) : Expression( _aname ), arg(arg_) { 234 283 set_result(toType); 235 284 } 236 285 237 CastExpr::CastExpr( Expression *arg_ ) : Expression(), arg(arg_) {286 CastExpr::CastExpr( Expression *arg_, Expression *_aname ) : Expression( _aname ), arg(arg_) { 238 287 set_result( new VoidType( Type::Qualifiers() ) ); 239 288 } … … 246 295 } 247 296 248 void CastExpr::print( std::ostream &os, Indenter indent ) const { 249 os << "Cast of:" << std::endl << indent+1; 250 arg->print(os, indent+1); 251 os << std::endl << indent << "... to:"; 297 void CastExpr::print( std::ostream &os, int indent ) const { 298 os << "Cast of:" << std::endl << std::string( indent+2, ' ' ); 299 arg->print(os, indent+2); 300 os << std::endl << std::string( indent, ' ' ) << "to:" << std::endl; 301 os << std::string( indent+2, ' ' ); 252 302 if ( result->isVoid() ) { 253 os << " 303 os << "nothing"; 254 304 } else { 255 os << std::endl << indent+1; 256 result->print( os, indent+1 ); 305 result->print( os, indent+2 ); 257 306 } // if 307 os << std::endl; 258 308 Expression::print( os, indent ); 259 309 } … … 270 320 } 271 321 272 void VirtualCastExpr::print( std::ostream &os, Indenter indent ) const { 273 os << "Virtual Cast of:" << std::endl << indent+1; 274 arg->print(os, indent+1); 275 os << std::endl << indent << "... to:"; 322 void VirtualCastExpr::print( std::ostream &os, int indent ) const { 323 os << "Virtual Cast of:" << std::endl << std::string( indent+2, ' ' ); 324 arg->print(os, indent+2); 325 os << std::endl << std::string( indent, ' ' ) << "to:" << std::endl; 326 os << std::string( indent+2, ' ' ); 276 327 if ( ! result ) { 277 os << " 328 os << "unknown"; 278 329 } else { 279 os << std::endl << indent+1; 280 result->print( os, indent+1 ); 330 result->print( os, indent+2 ); 281 331 } // if 282 Expression::print( os, indent ); 283 } 284 285 UntypedMemberExpr::UntypedMemberExpr( Expression * member, Expression *aggregate ) : 286 Expression(), member(member), aggregate(aggregate) { 287 assert( aggregate ); 288 } 332 os << std::endl; 333 Expression::print( os, indent ); 334 } 335 336 UntypedMemberExpr::UntypedMemberExpr( Expression * _member, Expression *_aggregate, Expression *_aname ) : 337 Expression( _aname ), member(_member), aggregate(_aggregate) {} 289 338 290 339 UntypedMemberExpr::UntypedMemberExpr( const UntypedMemberExpr &other ) : … … 297 346 } 298 347 299 void UntypedMemberExpr::print( std::ostream &os, Indenter indent ) const { 300 os << "Untyped Member Expression, with field: " << std::endl << indent+1; 301 member->print(os, indent+1 ); 302 os << indent << "... from aggregate: " << std::endl << indent+1; 303 aggregate->print(os, indent+1); 348 void UntypedMemberExpr::print( std::ostream &os, int indent ) const { 349 os << "Untyped Member Expression, with field: " << std::endl; 350 os << std::string( indent+2, ' ' ); 351 get_member()->print(os, indent+4); 352 os << std::string( indent+2, ' ' ); 353 354 Expression *agg = get_aggregate(); 355 os << "from aggregate: " << std::endl; 356 if (agg != 0) { 357 os << std::string( indent + 4, ' ' ); 358 agg->print(os, indent + 4); 359 } 360 os << std::string( indent+2, ' ' ); 304 361 Expression::print( os, indent ); 305 362 } … … 320 377 321 378 322 MemberExpr::MemberExpr( DeclarationWithType *member, Expression *aggregate ) : 323 Expression(), member(member), aggregate(aggregate) { 324 assert( member ); 325 assert( aggregate ); 379 MemberExpr::MemberExpr( DeclarationWithType *_member, Expression *_aggregate, Expression *_aname ) : 380 Expression( _aname ), member(_member), aggregate(_aggregate) { 326 381 327 382 TypeSubstitution sub( makeSub( aggregate->get_result() ) ); … … 341 396 } 342 397 343 void MemberExpr::print( std::ostream &os, Indenterindent ) const {398 void MemberExpr::print( std::ostream &os, int indent ) const { 344 399 os << "Member Expression, with field: " << std::endl; 345 os << indent+1; 346 member->print( os, indent+1 ); 347 os << std::endl << indent << "... from aggregate: " << std::endl << indent+1; 348 aggregate->print(os, indent + 1); 349 Expression::print( os, indent ); 350 } 351 352 UntypedExpr::UntypedExpr( Expression *function, const std::list<Expression *> &args ) : 353 Expression(), function(function), args(args) {} 400 401 assert( member ); 402 os << std::string( indent + 2, ' ' ); 403 member->print( os, indent + 2 ); 404 os << std::endl; 405 406 Expression *agg = get_aggregate(); 407 os << std::string( indent, ' ' ) << "from aggregate: " << std::endl; 408 if (agg != 0) { 409 os << std::string( indent + 2, ' ' ); 410 agg->print(os, indent + 2); 411 } 412 os << std::string( indent+2, ' ' ); 413 Expression::print( os, indent ); 414 } 415 416 UntypedExpr::UntypedExpr( Expression *_function, const std::list<Expression *> &_args, Expression *_aname ) : 417 Expression( _aname ), function(_function), args(_args) {} 354 418 355 419 UntypedExpr::UntypedExpr( const UntypedExpr &other ) : … … 392 456 393 457 394 void UntypedExpr::print( std::ostream &os, Indenterindent ) const {458 void UntypedExpr::print( std::ostream &os, int indent ) const { 395 459 os << "Applying untyped: " << std::endl; 396 os << indent+1; 397 function->print(os, indent+1); 398 os << std::endl << indent << "...to: " << std::endl; 399 printAll(args, os, indent+1); 400 Expression::print( os, indent ); 401 } 402 403 NameExpr::NameExpr( std::string name ) : Expression(), name(name) { 404 assertf(name != "0", "Zero is not a valid name"); 405 assertf(name != "1", "One is not a valid name"); 460 os << std::string( indent+2, ' ' ); 461 function->print(os, indent + 2); 462 os << std::string( indent, ' ' ) << "...to: " << std::endl; 463 printAll(args, os, indent + 2); 464 Expression::print( os, indent ); 465 } 466 467 void UntypedExpr::printArgs( std::ostream &os, int indent ) const { 468 std::list<Expression *>::const_iterator i; 469 for (i = args.begin(); i != args.end(); i++) { 470 os << std::string(indent, ' ' ); 471 (*i)->print(os, indent); 472 } 473 } 474 475 NameExpr::NameExpr( std::string _name, Expression *_aname ) : Expression( _aname ), name(_name) { 476 assertf(_name != "0", "Zero is not a valid name\n"); 477 assertf(_name != "1", "One is not a valid name\n"); 406 478 } 407 479 … … 411 483 NameExpr::~NameExpr() {} 412 484 413 void NameExpr::print( std::ostream &os, Indenterindent ) const {414 os << "Name: " << get_name() ;415 Expression::print( os, indent ); 416 } 417 418 LogicalExpr::LogicalExpr( Expression *arg1_, Expression *arg2_, bool andp ) :419 Expression( ), arg1(arg1_), arg2(arg2_), isAnd(andp) {485 void NameExpr::print( std::ostream &os, int indent ) const { 486 os << "Name: " << get_name() << std::endl; 487 Expression::print( os, indent ); 488 } 489 490 LogicalExpr::LogicalExpr( Expression *arg1_, Expression *arg2_, bool andp, Expression *_aname ) : 491 Expression( _aname ), arg1(arg1_), arg2(arg2_), isAnd(andp) { 420 492 set_result( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) ); 421 493 } … … 430 502 } 431 503 432 void LogicalExpr::print( std::ostream &os, Indenterindent )const {433 os << "Short-circuited operation (" << (isAnd ? "and" :"or") << ") on: ";504 void LogicalExpr::print( std::ostream &os, int indent )const { 505 os << "Short-circuited operation (" << (isAnd?"and":"or") << ") on: "; 434 506 arg1->print(os); 435 507 os << " and "; 436 508 arg2->print(os); 437 Expression::print( os, indent ); 438 } 439 440 ConditionalExpr::ConditionalExpr( Expression * arg1, Expression * arg2, Expression * arg3 ) : 441 Expression(), arg1(arg1), arg2(arg2), arg3(arg3) {} 509 os << std::endl; 510 Expression::print( os, indent ); 511 } 512 513 ConditionalExpr::ConditionalExpr( Expression *arg1_, Expression *arg2_, Expression *arg3_, Expression *_aname ) : 514 Expression( _aname ), arg1(arg1_), arg2(arg2_), arg3(arg3_) {} 442 515 443 516 ConditionalExpr::ConditionalExpr( const ConditionalExpr &other ) : … … 451 524 } 452 525 453 void ConditionalExpr::print( std::ostream &os, Indenter indent ) const { 454 os << "Conditional expression on: " << std::endl << indent+1; 455 arg1->print( os, indent+1 ); 456 os << indent << "First alternative:" << std::endl << indent+1; 457 arg2->print( os, indent+1 ); 458 os << indent << "Second alternative:" << std::endl << indent+1; 459 arg3->print( os, indent+1 ); 526 void ConditionalExpr::print( std::ostream &os, int indent ) const { 527 os << "Conditional expression on: " << std::endl; 528 os << std::string( indent+2, ' ' ); 529 arg1->print( os, indent+2 ); 530 os << std::string( indent, ' ' ) << "First alternative:" << std::endl; 531 os << std::string( indent+2, ' ' ); 532 arg2->print( os, indent+2 ); 533 os << std::string( indent, ' ' ) << "Second alternative:" << std::endl; 534 os << std::string( indent+2, ' ' ); 535 arg3->print( os, indent+2 ); 536 os << std::endl; 460 537 Expression::print( os, indent ); 461 538 } … … 464 541 465 542 466 void AsmExpr::print( std::ostream &os, Indenterindent ) const {543 void AsmExpr::print( std::ostream &os, int indent ) const { 467 544 os << "Asm Expression: " << std::endl; 468 if ( inout ) inout->print( os, indent +1);469 if ( constraint ) constraint->print( os, indent +1);470 if ( operand ) operand->print( os, indent +1);545 if ( inout ) inout->print( os, indent + 2 ); 546 if ( constraint ) constraint->print( os, indent + 2 ); 547 if ( operand ) operand->print( os, indent + 2 ); 471 548 } 472 549 … … 474 551 ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( ApplicationExpr * callExpr ) : callExpr( callExpr ) { 475 552 assert( callExpr ); 476 assert( callExpr-> result);553 assert( callExpr->has_result() ); 477 554 set_result( callExpr->get_result()->clone() ); 478 555 } … … 492 569 } 493 570 494 void ImplicitCopyCtorExpr::print( std::ostream &os, Indenter indent ) const { 495 os << "Implicit Copy Constructor Expression: " << std::endl << indent+1; 496 callExpr->print( os, indent+1 ); 497 os << std::endl << indent << "... with temporaries:" << std::endl; 498 printAll( tempDecls, os, indent+1 ); 499 os << std::endl << indent << "... with return temporaries:" << std::endl; 500 printAll( returnDecls, os, indent+1 ); 571 void ImplicitCopyCtorExpr::print( std::ostream &os, int indent ) const { 572 os << "Implicit Copy Constructor Expression: " << std::endl; 573 assert( callExpr ); 574 os << std::string( indent+2, ' ' ); 575 callExpr->print( os, indent + 2 ); 576 os << std::endl << std::string( indent, ' ' ) << "with temporaries:" << std::endl; 577 printAll(tempDecls, os, indent+2); 578 os << std::endl << std::string( indent, ' ' ) << "with return temporaries:" << std::endl; 579 printAll(returnDecls, os, indent+2); 501 580 Expression::print( os, indent ); 502 581 } … … 508 587 Expression * arg = InitTweak::getCallArg( callExpr, 0 ); 509 588 assert( arg ); 510 set_result( maybeClone( arg-> result) );589 set_result( maybeClone( arg->get_result() ) ); 511 590 } 512 591 … … 518 597 } 519 598 520 void ConstructorExpr::print( std::ostream &os, Indenter indent ) const { 521 os << "Constructor Expression: " << std::endl << indent+1; 599 void ConstructorExpr::print( std::ostream &os, int indent ) const { 600 os << "Constructor Expression: " << std::endl; 601 assert( callExpr ); 602 os << std::string( indent+2, ' ' ); 522 603 callExpr->print( os, indent + 2 ); 523 604 Expression::print( os, indent ); … … 537 618 } 538 619 539 void CompoundLiteralExpr::print( std::ostream &os, Indenter indent ) const { 540 os << "Compound Literal Expression: " << std::endl << indent+1; 541 result->print( os, indent+1 ); 542 os << indent+1; 543 initializer->print( os, indent+1 ); 620 void CompoundLiteralExpr::print( std::ostream &os, int indent ) const { 621 os << "Compound Literal Expression: " << std::endl; 622 os << std::string( indent+2, ' ' ); 623 get_result()->print( os, indent + 2 ); 624 os << std::string( indent+2, ' ' ); 625 initializer->print( os, indent + 2 ); 544 626 Expression::print( os, indent ); 545 627 } … … 547 629 RangeExpr::RangeExpr( Expression *low, Expression *high ) : low( low ), high( high ) {} 548 630 RangeExpr::RangeExpr( const RangeExpr &other ) : Expression( other ), low( other.low->clone() ), high( other.high->clone() ) {} 549 void RangeExpr::print( std::ostream &os, Indenterindent ) const {631 void RangeExpr::print( std::ostream &os, int indent ) const { 550 632 os << "Range Expression: "; 551 633 low->print( os, indent ); … … 577 659 deleteAll( returnDecls ); 578 660 } 579 void StmtExpr::print( std::ostream &os, Indenterindent ) const {580 os << "Statement Expression: " << std::endl << indent+1;581 statements->print( os, indent+ 1);661 void StmtExpr::print( std::ostream &os, int indent ) const { 662 os << "Statement Expression: " << std::endl << std::string( indent, ' ' ); 663 statements->print( os, indent+2 ); 582 664 if ( ! returnDecls.empty() ) { 583 os << indent+1 << "...with returnDecls: ";584 printAll( returnDecls, os, indent+ 1);665 os << std::string( indent+2, ' ' ) << "with returnDecls: "; 666 printAll( returnDecls, os, indent+2 ); 585 667 } 586 668 if ( ! dtors.empty() ) { 587 os << indent+1 << "...with dtors: ";588 printAll( dtors, os, indent+ 1);669 os << std::string( indent+2, ' ' ) << "with dtors: "; 670 printAll( dtors, os, indent+2 ); 589 671 } 590 672 Expression::print( os, indent ); … … 608 690 delete var; 609 691 } 610 void UniqueExpr::print( std::ostream &os, Indenterindent ) const {611 os << "Unique Expression with id:" << id << std::endl << indent+1;612 expr->print( os, indent+1);613 if ( object) {614 os << indent << "...with decl: ";615 get_object()->printShort( os, indent+ 1);692 void UniqueExpr::print( std::ostream &os, int indent ) const { 693 os << "Unique Expression with id:" << id << std::endl << std::string( indent+2, ' ' ); 694 get_expr()->print( os, indent+2 ); 695 if ( get_object() ) { 696 os << std::string( indent+2, ' ' ) << "with decl: "; 697 get_object()->printShort( os, indent+2 ); 616 698 } 617 699 Expression::print( os, indent ); … … 631 713 } 632 714 633 void UntypedInitExpr::print( std::ostream & os, Indenterindent ) const {634 os << "Untyped Init Expression" << std::endl << indent+1;635 expr->print( os, indent+ 1);715 void UntypedInitExpr::print( std::ostream & os, int indent ) const { 716 os << "Untyped Init Expression" << std::endl << std::string( indent+2, ' ' ); 717 expr->print( os, indent+2 ); 636 718 if ( ! initAlts.empty() ) { 637 719 for ( const InitAlternative & alt : initAlts ) { 638 os << indent+1<< "InitAlternative: ";639 alt.type->print( os, indent+ 1);640 alt.designation->print( os, indent+ 1);720 os << std::string( indent+2, ' ' ) << "InitAlternative: "; 721 alt.type->print( os, indent+2 ); 722 alt.designation->print( os, indent+2 ); 641 723 } 642 724 } … … 652 734 } 653 735 654 void InitExpr::print( std::ostream & os, Indenterindent ) const {655 os << "Init Expression" << std::endl << indent+1;656 expr->print( os, indent+ 1);657 os << indent+1 << "...with designation: ";658 designation->print( os, indent+ 1);736 void InitExpr::print( std::ostream & os, int indent ) const { 737 os << "Init Expression" << std::endl << std::string( indent+2, ' ' ); 738 expr->print( os, indent+2 ); 739 os << std::string( indent+2, ' ' ) << "with designation: "; 740 designation->print( os, indent+2 ); 659 741 } 660 742
Note: See TracChangeset
for help on using the changeset viewer.