Changes in src/SynTree/Expression.cc [62423350:4b0f997]
- File:
-
- 1 edited
-
src/SynTree/Expression.cc (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Expression.cc
r62423350 r4b0f997 21 21 #include <iterator> 22 22 23 #include "Type.h" 24 #include "Initializer.h" 25 #include "Expression.h" 23 26 #include "Declaration.h" 24 #include "Expression.h"25 #include "Initializer.h"26 27 #include "Statement.h" 27 #include "Type.h"28 28 #include "TypeSubstitution.h" 29 #include "VarExprReplacer.h"30 31 29 #include "Common/utility.h" 32 #include "Common/PassVisitor.h"33 34 30 #include "InitTweak/InitTweak.h" 35 31 … … 96 92 97 93 Declaration *decl = get_var(); 94 // if ( decl != 0) decl->print(os, indent + 2); 98 95 if ( decl != 0) decl->printShort(os, indent + 2); 99 96 os << std::endl; … … 290 287 delete arg; 291 288 } 289 290 // CastExpr *CastExpr::clone() const { return 0; } 292 291 293 292 void CastExpr::print( std::ostream &os, int indent ) const { … … 356 355 } 357 356 357 //// is this right? It's cloning the member, but the member is a declaration so probably shouldn't be cloned... 358 358 MemberExpr::MemberExpr( const MemberExpr &other ) : 359 359 Expression( other ), member( other.member ), aggregate( maybeClone( other.aggregate ) ) { … … 361 361 362 362 MemberExpr::~MemberExpr() { 363 // d on't delete the member declaration, since it points somewhere else in the tree363 // delete member; 364 364 delete aggregate; 365 365 } … … 591 591 } 592 592 593 UntypedValofExpr::UntypedValofExpr( const UntypedValofExpr & other ) : Expression( other ), body ( maybeClone( other.body ) ) {} 594 595 UntypedValofExpr::~UntypedValofExpr() { delete body; } 596 597 void UntypedValofExpr::print( std::ostream &os, int indent ) const { 598 os << std::string( indent, ' ' ) << "Valof Expression: " << std::endl; 599 if ( get_body() != 0 ) 600 get_body()->print( os, indent + 2 ); 601 } 602 593 603 RangeExpr::RangeExpr( Expression *low, Expression *high ) : low( low ), high( high ) {} 594 604 RangeExpr::RangeExpr( const RangeExpr &other ) : Expression( other ), low( other.low->clone() ), high( other.high->clone() ) {} … … 660 670 } 661 671 662 InitAlternative::InitAlternative( Type * type, Designation * designation ) : type( type ), designation( designation ) {}663 InitAlternative::InitAlternative( const InitAlternative & other ) : type( maybeClone( other.type ) ), designation( maybeClone( other.designation ) ) {}664 InitAlternative::~InitAlternative() {665 delete type;666 delete designation;667 }668 669 UntypedInitExpr::UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts ) : expr( expr ), initAlts( initAlts ) {}670 UntypedInitExpr::UntypedInitExpr( const UntypedInitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), initAlts( other.initAlts ) {}671 UntypedInitExpr::~UntypedInitExpr() {672 delete expr;673 }674 675 void UntypedInitExpr::print( std::ostream & os, int indent ) const {676 os << "Untyped Init Expression" << std::endl << std::string( indent+2, ' ' );677 expr->print( os, indent+2 );678 if ( ! initAlts.empty() ) {679 for ( const InitAlternative & alt : initAlts ) {680 os << std::string( indent+2, ' ' ) << "InitAlternative: ";681 alt.type->print( os, indent+2 );682 alt.designation->print( os, indent+2 );683 }684 }685 }686 687 InitExpr::InitExpr( Expression * expr, Designation * designation ) : expr( expr ), designation( designation ) {688 set_result( expr->get_result()->clone() );689 }690 InitExpr::InitExpr( const InitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), designation( maybeClone( other.designation) ) {}691 InitExpr::~InitExpr() {692 delete expr;693 delete designation;694 }695 696 void InitExpr::print( std::ostream & os, int indent ) const {697 os << "Init Expression" << std::endl << std::string( indent+2, ' ' );698 expr->print( os, indent+2 );699 os << std::string( indent+2, ' ' ) << "with designation: ";700 designation->print( os, indent+2 );701 }702 703 704 672 std::ostream & operator<<( std::ostream & out, const Expression * expr ) { 705 673 if ( expr ) {
Note:
See TracChangeset
for help on using the changeset viewer.