Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    re4d829b raf5c204a  
    9292
    9393        Declaration *decl = get_var();
     94        // if ( decl != 0) decl->print(os, indent + 2);
    9495        if ( decl != 0) decl->printShort(os, indent + 2);
    9596        os << std::endl;
     
    286287        delete arg;
    287288}
    288 
    289 // CastExpr *CastExpr::clone() const { return 0; }
    290289
    291290void CastExpr::print( std::ostream &os, int indent ) const {
     
    354353}
    355354
    356 //// is this right? It's cloning the member, but the member is a declaration so probably shouldn't be cloned...
    357355MemberExpr::MemberExpr( const MemberExpr &other ) :
    358356                Expression( other ), member( other.member ), aggregate( maybeClone( other.aggregate ) ) {
     
    360358
    361359MemberExpr::~MemberExpr() {
    362         // delete member;
     360        // don't delete the member declaration, since it points somewhere else in the tree
    363361        delete aggregate;
    364362}
     
    590588}
    591589
    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 
    602590RangeExpr::RangeExpr( Expression *low, Expression *high ) : low( low ), high( high ) {}
    603591RangeExpr::RangeExpr( const RangeExpr &other ) : Expression( other ), low( other.low->clone() ), high( other.high->clone() ) {}
     
    669657}
    670658
    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 
    713659std::ostream & operator<<( std::ostream & out, const Expression * expr ) {
    714660        if ( expr ) {
Note: See TracChangeset for help on using the changeset viewer.