Changes in src/SynTree/Expression.cc [e4d829b:af5c204a]
- File:
-
- 1 edited
-
src/SynTree/Expression.cc (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Expression.cc
re4d829b raf5c204a 92 92 93 93 Declaration *decl = get_var(); 94 // if ( decl != 0) decl->print(os, indent + 2); 94 95 if ( decl != 0) decl->printShort(os, indent + 2); 95 96 os << std::endl; … … 286 287 delete arg; 287 288 } 288 289 // CastExpr *CastExpr::clone() const { return 0; }290 289 291 290 void CastExpr::print( std::ostream &os, int indent ) const { … … 354 353 } 355 354 356 //// is this right? It's cloning the member, but the member is a declaration so probably shouldn't be cloned...357 355 MemberExpr::MemberExpr( const MemberExpr &other ) : 358 356 Expression( other ), member( other.member ), aggregate( maybeClone( other.aggregate ) ) { … … 360 358 361 359 MemberExpr::~MemberExpr() { 362 // d elete member;360 // don't delete the member declaration, since it points somewhere else in the tree 363 361 delete aggregate; 364 362 } … … 590 588 } 591 589 592 UntypedValofExpr::UntypedValofExpr( const UntypedValofExpr & other ) : Expression( other ), body ( maybeClone( other.body ) ) {}593 594 UntypedValofExpr::~UntypedValofExpr() { delete body; }595 596 void UntypedValofExpr::print( std::ostream &os, int indent ) const {597 os << std::string( indent, ' ' ) << "Valof Expression: " << std::endl;598 if ( get_body() != 0 )599 get_body()->print( os, indent + 2 );600 }601 602 590 RangeExpr::RangeExpr( Expression *low, Expression *high ) : low( low ), high( high ) {} 603 591 RangeExpr::RangeExpr( const RangeExpr &other ) : Expression( other ), low( other.low->clone() ), high( other.high->clone() ) {} … … 669 657 } 670 658 671 InitAlternative::InitAlternative( Type * type, Designation * designation ) : type( type ), designation( designation ) {}672 InitAlternative::InitAlternative( const InitAlternative & other ) : type( maybeClone( other.type ) ), designation( maybeClone( other.designation ) ) {}673 InitAlternative::~InitAlternative() {674 delete type;675 delete designation;676 }677 678 UntypedInitExpr::UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts ) : expr( expr ), initAlts( initAlts ) {}679 UntypedInitExpr::UntypedInitExpr( const UntypedInitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), initAlts( other.initAlts ) {}680 UntypedInitExpr::~UntypedInitExpr() {681 delete expr;682 }683 684 void UntypedInitExpr::print( std::ostream & os, int indent ) const {685 os << "Untyped Init Expression" << std::endl << std::string( indent+2, ' ' );686 expr->print( os, indent+2 );687 if ( ! initAlts.empty() ) {688 for ( const InitAlternative & alt : initAlts ) {689 os << std::string( indent+2, ' ' ) << "InitAlternative: ";690 alt.type->print( os, indent+2 );691 alt.designation->print( os, indent+2 );692 }693 }694 }695 696 InitExpr::InitExpr( Expression * expr, Type * type, Designation * designation ) : expr( expr ), designation( designation ) {697 set_result( type );698 }699 InitExpr::InitExpr( const InitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), designation( maybeClone( other.designation) ) {}700 InitExpr::~InitExpr() {701 delete expr;702 delete designation;703 }704 705 void InitExpr::print( std::ostream & os, int indent ) const {706 os << "Init Expression" << std::endl << std::string( indent+2, ' ' );707 expr->print( os, indent+2 );708 os << std::string( indent+2, ' ' ) << "with designation: ";709 designation->print( os, indent+2 );710 }711 712 713 659 std::ostream & operator<<( std::ostream & out, const Expression * expr ) { 714 660 if ( expr ) {
Note:
See TracChangeset
for help on using the changeset viewer.