Changes in src/SynTree/Expression.cc [3b58d91:b6fe7e6]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Expression.cc
r3b58d91 rb6fe7e6 28 28 #include "TypeSubstitution.h" 29 29 #include "Common/utility.h" 30 #include "InitTweak/InitTweak.h" 30 31 31 32 … … 310 311 } 311 312 312 UntypedMemberExpr::UntypedMemberExpr( Expression *_member, Expression *_aggregate, Expression *_aname ) :313 UntypedMemberExpr::UntypedMemberExpr( std::string _member, Expression *_aggregate, Expression *_aname ) : 313 314 Expression( _aname ), member(_member), aggregate(_aggregate) {} 314 315 315 316 UntypedMemberExpr::UntypedMemberExpr( const UntypedMemberExpr &other ) : 316 Expression( other ), member( maybeClone( other.member )), aggregate( maybeClone( other.aggregate ) ) {317 Expression( other ), member( other.member ), aggregate( maybeClone( other.aggregate ) ) { 317 318 } 318 319 319 320 UntypedMemberExpr::~UntypedMemberExpr() { 320 321 delete aggregate; 321 delete member;322 322 } 323 323 324 324 void UntypedMemberExpr::print( std::ostream &os, int indent ) const { 325 os << "Untyped Member Expression, with field: " << std::endl; 326 get_member()->print(os, indent+4); 327 os << std::string( indent+2, ' ' ); 325 os << "Untyped Member Expression, with field: " << get_member(); 328 326 329 327 Expression *agg = get_aggregate(); 330 os << " from aggregate: " << std::endl;328 os << ", from aggregate: "; 331 329 if (agg != 0) { 332 os << std::string( indent + 4, ' ' );333 agg->print(os, indent + 4);330 os << std::string( indent + 2, ' ' ); 331 agg->print(os, indent + 2); 334 332 } 335 333 os << std::string( indent+2, ' ' ); … … 496 494 497 495 void ImplicitCopyCtorExpr::print( std::ostream &os, int indent ) const { 498 os << std::string( indent, ' ' ) <<"Implicit Copy Constructor Expression: " << std::endl;496 os << "Implicit Copy Constructor Expression: " << std::endl; 499 497 assert( callExpr ); 500 498 callExpr->print( os, indent + 2 ); … … 506 504 } 507 505 506 507 ConstructorExpr::ConstructorExpr( Expression * callExpr ) : callExpr( callExpr ) { 508 // allow resolver to type a constructor used as an expression as if it has the same type as its first argument 509 assert( callExpr ); 510 Expression * arg = InitTweak::getCallArg( callExpr, 0 ); 511 assert( arg ); 512 cloneAll( arg->get_results(), results ); 513 } 514 515 ConstructorExpr::ConstructorExpr( const ConstructorExpr & other ) : Expression( other ), callExpr( maybeClone( other.callExpr ) ) { 516 } 517 518 ConstructorExpr::~ConstructorExpr() { 519 delete callExpr; 520 } 521 522 void ConstructorExpr::print( std::ostream &os, int indent ) const { 523 os << "Constructor Expression: " << std::endl; 524 assert( callExpr ); 525 os << std::string( indent+2, ' ' ); 526 callExpr->print( os, indent + 2 ); 527 Expression::print( os, indent ); 528 } 529 530 531 CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : type( type ), initializer( initializer ) { 532 add_result( type->clone() ); 533 } 534 535 CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), type( maybeClone( other.type ) ), initializer( maybeClone( other.initializer ) ) {} 536 537 CompoundLiteralExpr::~CompoundLiteralExpr() { 538 delete initializer; 539 delete type; 540 } 541 542 void CompoundLiteralExpr::print( std::ostream &os, int indent ) const { 543 os << "Compound Literal Expression: " << std::endl; 544 if ( type ) type->print( os, indent + 2 ); 545 if ( initializer ) initializer->print( os, indent + 2 ); 546 } 547 508 548 UntypedValofExpr::UntypedValofExpr( const UntypedValofExpr & other ) : Expression( other ), body ( maybeClone( other.body ) ) {} 509 549 … … 514 554 if ( get_body() != 0 ) 515 555 get_body()->print( os, indent + 2 ); 516 }517 518 519 CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : type( type ), initializer( initializer ) {520 add_result( type->clone() );521 }522 523 CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), type( maybeClone( other.type ) ), initializer( maybeClone( other.initializer ) ) {}524 525 CompoundLiteralExpr::~CompoundLiteralExpr() {526 delete initializer;527 delete type;528 }529 530 void CompoundLiteralExpr::print( std::ostream &os, int indent ) const {531 os << "Compound Literal Expression: " << std::endl;532 if ( type ) type->print( os, indent + 2 );533 if ( initializer ) initializer->print( os, indent + 2 );534 556 } 535 557
Note:
See TracChangeset
for help on using the changeset viewer.