Changeset 3f7e12cb for src/SynTree/Expression.cc
- Timestamp:
- Nov 8, 2017, 5:43:33 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 954908d
- Parents:
- 78315272 (diff), e35f30a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Expression.cc
r78315272 r3f7e12cb 33 33 #include "GenPoly/Lvalue.h" 34 34 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 ) { 35 void printInferParams( const InferredParams & inferParams, std::ostream &os, Indenter indent, int level ) { 36 if ( ! inferParams.empty() ) { 37 os << indent << "with inferred parameters " << level << ":" << std::endl; 38 for ( InferredParams::const_iterator i = inferParams.begin(); i != inferParams.end(); ++i ) { 39 os << indent+1; 40 Declaration::declFromId( i->second.decl )->printShort( os, indent+1 ); 41 os << std::endl; 42 printInferParams( *i->second.inferParams, os, indent+1, level+1 ); 43 } // for 44 } // if 45 } 46 47 Expression::Expression() : result( 0 ), env( 0 ) {} 48 49 Expression::Expression( const Expression &other ) : BaseSyntaxNode( other ), result( maybeClone( other.result ) ), env( maybeClone( other.env ) ), extension( other.extension ), inferParams( other.inferParams ) { 38 50 } 39 51 40 52 Expression::~Expression() { 41 53 delete env; 42 delete argName; // xxx -- there's a problem in cloning ConstantExpr I still don't know how to fix43 54 delete result; 44 55 } 45 56 46 void Expression::print( std::ostream &os, int indent ) const { 57 void Expression::print( std::ostream &os, Indenter indent ) const { 58 printInferParams( inferParams, os, indent+1, 0 ); 59 47 60 if ( env ) { 48 os << std:: string( indent, ' ' ) << "with environment:" << std::endl;49 env->print( os, indent+ 2);61 os << std::endl << indent << "... with environment:" << std::endl; 62 env->print( os, indent+1 ); 50 63 } // if 51 64 52 if ( argName ) { 53 os << std::string( indent, ' ' ) << "with designator:"; 54 argName->print( os, indent+2 ); 65 if ( extension ) { 66 os << std::endl << indent << "... with extension:"; 55 67 } // if 56 57 if ( extension ) { 58 os << std::string( indent, ' ' ) << "with extension:"; 59 } // if 60 } 61 62 ConstantExpr::ConstantExpr( Constant _c, Expression *_aname ) : Expression( _aname ), constant( _c ) { 68 } 69 70 ConstantExpr::ConstantExpr( Constant _c ) : Expression(), constant( _c ) { 63 71 set_result( constant.get_type()->clone() ); 64 72 } … … 69 77 ConstantExpr::~ConstantExpr() {} 70 78 71 void ConstantExpr::print( std::ostream &os, intindent ) const {79 void ConstantExpr::print( std::ostream &os, Indenter indent ) const { 72 80 os << "constant expression " ; 73 81 constant.print( os ); … … 75 83 } 76 84 77 VariableExpr::VariableExpr( DeclarationWithType *_var , Expression *_aname ) : Expression( _aname), var( _var ) {85 VariableExpr::VariableExpr( DeclarationWithType *_var ) : Expression(), var( _var ) { 78 86 assert( var ); 79 87 assert( var->get_type() ); … … 96 104 } 97 105 98 void VariableExpr::print( std::ostream &os, intindent ) const {106 void VariableExpr::print( std::ostream &os, Indenter indent ) const { 99 107 os << "Variable Expression: "; 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) { 108 var->printShort(os, indent); 109 Expression::print( os, indent ); 110 } 111 112 SizeofExpr::SizeofExpr( Expression *expr_ ) : 113 Expression(), expr(expr_), type(0), isType(false) { 109 114 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 110 115 } 111 116 112 SizeofExpr::SizeofExpr( Type *type_ , Expression *_aname) :113 Expression( _aname), expr(0), type(type_), isType(true) {117 SizeofExpr::SizeofExpr( Type *type_ ) : 118 Expression(), expr(0), type(type_), isType(true) { 114 119 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 115 120 } … … 124 129 } 125 130 126 void SizeofExpr::print( std::ostream &os, intindent) const {131 void SizeofExpr::print( std::ostream &os, Indenter indent) const { 127 132 os << "Sizeof Expression on: "; 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) { 133 if (isType) type->print(os, indent+1); 134 else expr->print(os, indent+1); 135 Expression::print( os, indent ); 136 } 137 138 AlignofExpr::AlignofExpr( Expression *expr_ ) : 139 Expression(), expr(expr_), type(0), isType(false) { 140 140 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 141 141 } 142 142 143 AlignofExpr::AlignofExpr( Type *type_ , Expression *_aname) :144 Expression( _aname), expr(0), type(type_), isType(true) {143 AlignofExpr::AlignofExpr( Type *type_ ) : 144 Expression(), expr(0), type(type_), isType(true) { 145 145 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 146 146 } … … 155 155 } 156 156 157 void AlignofExpr::print( std::ostream &os, intindent) const {157 void AlignofExpr::print( std::ostream &os, Indenter indent) const { 158 158 os << "Alignof Expression on: "; 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_) { 159 if (isType) type->print(os, indent+1); 160 else expr->print(os, indent+1); 161 Expression::print( os, indent ); 162 } 163 164 UntypedOffsetofExpr::UntypedOffsetofExpr( Type *type, const std::string &member ) : 165 Expression(), type(type), member(member) { 166 assert( type ); 171 167 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 172 168 } … … 179 175 } 180 176 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_) { 177 void UntypedOffsetofExpr::print( std::ostream &os, Indenter indent) const { 178 os << "Untyped Offsetof Expression on member " << member << " of "; 179 type->print(os, indent+1); 180 Expression::print( os, indent ); 181 } 182 183 OffsetofExpr::OffsetofExpr( Type *type, DeclarationWithType *member ) : 184 Expression(), type(type), member(member) { 185 assert( member ); 186 assert( type ); 196 187 set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) ); 197 188 } … … 204 195 } 205 196 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_ ) { 197 void OffsetofExpr::print( std::ostream &os, Indenter indent) const { 198 os << "Offsetof Expression on member " << member->name << " of "; 199 type->print(os, indent+1); 200 Expression::print( os, indent ); 201 } 202 203 OffsetPackExpr::OffsetPackExpr( StructInstType *type ) : Expression(), type( type ) { 204 assert( type ); 228 205 set_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) ); 229 206 } … … 233 210 OffsetPackExpr::~OffsetPackExpr() { delete type; } 234 211 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) { 212 void OffsetPackExpr::print( std::ostream &os, Indenter indent ) const { 213 os << "Offset pack expression on "; 214 type->print(os, indent+1); 215 Expression::print( os, indent ); 216 } 217 218 AttrExpr::AttrExpr( Expression *attr, Expression *expr_ ) : 219 Expression(), attr( attr ), expr(expr_), type(0), isType(false) { 220 } 221 222 AttrExpr::AttrExpr( Expression *attr, Type *type_ ) : 223 Expression(), attr( attr ), expr(0), type(type_), isType(true) { 254 224 } 255 225 … … 264 234 } 265 235 266 void AttrExpr::print( std::ostream &os, intindent) const {236 void AttrExpr::print( std::ostream &os, Indenter indent) const { 267 237 os << "Attr "; 268 attr->print( os, indent + 2);238 attr->print( os, indent+1); 269 239 if ( isType || expr ) { 270 240 os << "applied to: "; 271 272 if (isType) 273 type->print(os, indent + 2); 274 else 275 expr->print(os, indent + 2); 241 if (isType) type->print(os, indent+1); 242 else expr->print(os, indent+1); 276 243 } // if 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_) { 244 Expression::print( os, indent ); 245 } 246 247 CastExpr::CastExpr( Expression *arg_, Type *toType ) : Expression(), arg(arg_) { 283 248 set_result(toType); 284 249 } 285 250 286 CastExpr::CastExpr( Expression *arg_ , Expression *_aname ) : Expression( _aname), arg(arg_) {251 CastExpr::CastExpr( Expression *arg_ ) : Expression(), arg(arg_) { 287 252 set_result( new VoidType( Type::Qualifiers() ) ); 288 253 } … … 295 260 } 296 261 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, ' ' ); 262 void CastExpr::print( std::ostream &os, Indenter indent ) const { 263 os << "Cast of:" << std::endl << indent+1; 264 arg->print(os, indent+1); 265 os << std::endl << indent << "... to:"; 302 266 if ( result->isVoid() ) { 303 os << " nothing";267 os << " nothing"; 304 268 } else { 305 result->print( os, indent+2 ); 269 os << std::endl << indent+1; 270 result->print( os, indent+1 ); 306 271 } // if 307 os << std::endl;308 272 Expression::print( os, indent ); 309 273 } … … 320 284 } 321 285 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, ' ' ); 286 void VirtualCastExpr::print( std::ostream &os, Indenter indent ) const { 287 os << "Virtual Cast of:" << std::endl << indent+1; 288 arg->print(os, indent+1); 289 os << std::endl << indent << "... to:"; 327 290 if ( ! result ) { 328 os << " unknown";291 os << " unknown"; 329 292 } else { 330 result->print( os, indent+2 ); 293 os << std::endl << indent+1; 294 result->print( os, indent+1 ); 331 295 } // if 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) {} 296 Expression::print( os, indent ); 297 } 298 299 UntypedMemberExpr::UntypedMemberExpr( Expression * member, Expression *aggregate ) : 300 Expression(), member(member), aggregate(aggregate) { 301 assert( aggregate ); 302 } 338 303 339 304 UntypedMemberExpr::UntypedMemberExpr( const UntypedMemberExpr &other ) : … … 346 311 } 347 312 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, ' ' ); 313 void UntypedMemberExpr::print( std::ostream &os, Indenter indent ) const { 314 os << "Untyped Member Expression, with field: " << std::endl << indent+1; 315 member->print(os, indent+1 ); 316 os << indent << "... from aggregate: " << std::endl << indent+1; 317 aggregate->print(os, indent+1); 361 318 Expression::print( os, indent ); 362 319 } … … 377 334 378 335 379 MemberExpr::MemberExpr( DeclarationWithType *_member, Expression *_aggregate, Expression *_aname ) : 380 Expression( _aname ), member(_member), aggregate(_aggregate) { 336 MemberExpr::MemberExpr( DeclarationWithType *member, Expression *aggregate ) : 337 Expression(), member(member), aggregate(aggregate) { 338 assert( member ); 339 assert( aggregate ); 381 340 382 341 TypeSubstitution sub( makeSub( aggregate->get_result() ) ); … … 396 355 } 397 356 398 void MemberExpr::print( std::ostream &os, intindent ) const {357 void MemberExpr::print( std::ostream &os, Indenter indent ) const { 399 358 os << "Member Expression, with field: " << std::endl; 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) {} 359 os << indent+1; 360 member->print( os, indent+1 ); 361 os << std::endl << indent << "... from aggregate: " << std::endl << indent+1; 362 aggregate->print(os, indent + 1); 363 Expression::print( os, indent ); 364 } 365 366 UntypedExpr::UntypedExpr( Expression *function, const std::list<Expression *> &args ) : 367 Expression(), function(function), args(args) {} 418 368 419 369 UntypedExpr::UntypedExpr( const UntypedExpr &other ) : … … 456 406 457 407 458 void UntypedExpr::print( std::ostream &os, intindent ) const {408 void UntypedExpr::print( std::ostream &os, Indenter indent ) const { 459 409 os << "Applying untyped: " << std::endl; 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"); 410 os << indent+1; 411 function->print(os, indent+1); 412 os << std::endl << indent << "...to: " << std::endl; 413 printAll(args, os, indent+1); 414 Expression::print( os, indent ); 415 } 416 417 NameExpr::NameExpr( std::string name ) : Expression(), name(name) { 418 assertf(name != "0", "Zero is not a valid name"); 419 assertf(name != "1", "One is not a valid name"); 478 420 } 479 421 … … 483 425 NameExpr::~NameExpr() {} 484 426 485 void NameExpr::print( std::ostream &os, intindent ) 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) {427 void NameExpr::print( std::ostream &os, Indenter indent ) const { 428 os << "Name: " << get_name(); 429 Expression::print( os, indent ); 430 } 431 432 LogicalExpr::LogicalExpr( Expression *arg1_, Expression *arg2_, bool andp ) : 433 Expression(), arg1(arg1_), arg2(arg2_), isAnd(andp) { 492 434 set_result( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) ); 493 435 } … … 502 444 } 503 445 504 void LogicalExpr::print( std::ostream &os, intindent )const {505 os << "Short-circuited operation (" << (isAnd ?"and":"or") << ") on: ";446 void LogicalExpr::print( std::ostream &os, Indenter indent )const { 447 os << "Short-circuited operation (" << (isAnd ? "and" : "or") << ") on: "; 506 448 arg1->print(os); 507 449 os << " and "; 508 450 arg2->print(os); 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_) {} 451 Expression::print( os, indent ); 452 } 453 454 ConditionalExpr::ConditionalExpr( Expression * arg1, Expression * arg2, Expression * arg3 ) : 455 Expression(), arg1(arg1), arg2(arg2), arg3(arg3) {} 515 456 516 457 ConditionalExpr::ConditionalExpr( const ConditionalExpr &other ) : … … 524 465 } 525 466 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; 467 void ConditionalExpr::print( std::ostream &os, Indenter indent ) const { 468 os << "Conditional expression on: " << std::endl << indent+1; 469 arg1->print( os, indent+1 ); 470 os << indent << "First alternative:" << std::endl << indent+1; 471 arg2->print( os, indent+1 ); 472 os << indent << "Second alternative:" << std::endl << indent+1; 473 arg3->print( os, indent+1 ); 537 474 Expression::print( os, indent ); 538 475 } … … 541 478 542 479 543 void AsmExpr::print( std::ostream &os, intindent ) const {480 void AsmExpr::print( std::ostream &os, Indenter indent ) const { 544 481 os << "Asm Expression: " << std::endl; 545 if ( inout ) inout->print( os, indent + 2);546 if ( constraint ) constraint->print( os, indent + 2);547 if ( operand ) operand->print( os, indent + 2);482 if ( inout ) inout->print( os, indent+1 ); 483 if ( constraint ) constraint->print( os, indent+1 ); 484 if ( operand ) operand->print( os, indent+1 ); 548 485 } 549 486 … … 551 488 ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( ApplicationExpr * callExpr ) : callExpr( callExpr ) { 552 489 assert( callExpr ); 553 assert( callExpr-> has_result());490 assert( callExpr->result ); 554 491 set_result( callExpr->get_result()->clone() ); 555 492 } … … 569 506 } 570 507 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); 508 void ImplicitCopyCtorExpr::print( std::ostream &os, Indenter indent ) const { 509 os << "Implicit Copy Constructor Expression: " << std::endl << indent+1; 510 callExpr->print( os, indent+1 ); 511 os << std::endl << indent << "... with temporaries:" << std::endl; 512 printAll( tempDecls, os, indent+1 ); 513 os << std::endl << indent << "... with return temporaries:" << std::endl; 514 printAll( returnDecls, os, indent+1 ); 580 515 Expression::print( os, indent ); 581 516 } … … 587 522 Expression * arg = InitTweak::getCallArg( callExpr, 0 ); 588 523 assert( arg ); 589 set_result( maybeClone( arg-> get_result()) );524 set_result( maybeClone( arg->result ) ); 590 525 } 591 526 … … 597 532 } 598 533 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, ' ' ); 534 void ConstructorExpr::print( std::ostream &os, Indenter indent ) const { 535 os << "Constructor Expression: " << std::endl << indent+1; 603 536 callExpr->print( os, indent + 2 ); 604 537 Expression::print( os, indent ); … … 618 551 } 619 552 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 ); 553 void CompoundLiteralExpr::print( std::ostream &os, Indenter indent ) const { 554 os << "Compound Literal Expression: " << std::endl << indent+1; 555 result->print( os, indent+1 ); 556 os << indent+1; 557 initializer->print( os, indent+1 ); 626 558 Expression::print( os, indent ); 627 559 } … … 629 561 RangeExpr::RangeExpr( Expression *low, Expression *high ) : low( low ), high( high ) {} 630 562 RangeExpr::RangeExpr( const RangeExpr &other ) : Expression( other ), low( other.low->clone() ), high( other.high->clone() ) {} 631 void RangeExpr::print( std::ostream &os, intindent ) const {563 void RangeExpr::print( std::ostream &os, Indenter indent ) const { 632 564 os << "Range Expression: "; 633 565 low->print( os, indent ); … … 659 591 deleteAll( returnDecls ); 660 592 } 661 void StmtExpr::print( std::ostream &os, intindent ) const {662 os << "Statement Expression: " << std::endl << std::string( indent, ' ' );663 statements->print( os, indent+ 2);593 void StmtExpr::print( std::ostream &os, Indenter indent ) const { 594 os << "Statement Expression: " << std::endl << indent+1; 595 statements->print( os, indent+1 ); 664 596 if ( ! returnDecls.empty() ) { 665 os << std::string( indent+2, ' ' ) << "with returnDecls: ";666 printAll( returnDecls, os, indent+ 2);597 os << indent+1 << "... with returnDecls: "; 598 printAll( returnDecls, os, indent+1 ); 667 599 } 668 600 if ( ! dtors.empty() ) { 669 os << std::string( indent+2, ' ' ) << "with dtors: ";670 printAll( dtors, os, indent+ 2);601 os << indent+1 << "... with dtors: "; 602 printAll( dtors, os, indent+1 ); 671 603 } 672 604 Expression::print( os, indent ); … … 690 622 delete var; 691 623 } 692 void UniqueExpr::print( std::ostream &os, intindent ) 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);624 void UniqueExpr::print( std::ostream &os, Indenter indent ) const { 625 os << "Unique Expression with id:" << id << std::endl << indent+1; 626 expr->print( os, indent+1 ); 627 if ( object ) { 628 os << indent << "... with decl: "; 629 get_object()->printShort( os, indent+1 ); 698 630 } 699 631 Expression::print( os, indent ); … … 713 645 } 714 646 715 void UntypedInitExpr::print( std::ostream & os, intindent ) const {716 os << "Untyped Init Expression" << std::endl << std::string( indent+2, ' ' );717 expr->print( os, indent+ 2);647 void UntypedInitExpr::print( std::ostream & os, Indenter indent ) const { 648 os << "Untyped Init Expression" << std::endl << indent+1; 649 expr->print( os, indent+1 ); 718 650 if ( ! initAlts.empty() ) { 719 651 for ( const InitAlternative & alt : initAlts ) { 720 os << std::string( indent+2, ' ' )<< "InitAlternative: ";721 alt.type->print( os, indent+ 2);722 alt.designation->print( os, indent+ 2);652 os << indent+1 << "InitAlternative: "; 653 alt.type->print( os, indent+1 ); 654 alt.designation->print( os, indent+1 ); 723 655 } 724 656 } … … 734 666 } 735 667 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 ); 741 } 742 743 744 std::ostream & operator<<( std::ostream & out, const Expression * expr ) { 745 if ( expr ) { 746 expr->print( out ); 747 } else { 748 out << "nullptr"; 749 } 750 return out; 668 void InitExpr::print( std::ostream & os, Indenter indent ) const { 669 os << "Init Expression" << std::endl << indent+1; 670 expr->print( os, indent+1 ); 671 os << indent+1 << "... with designation: "; 672 designation->print( os, indent+1 ); 751 673 } 752 674
Note:
See TracChangeset
for help on using the changeset viewer.