Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    raf5c204a re4d829b  
    9292
    9393        Declaration *decl = get_var();
    94         // if ( decl != 0) decl->print(os, indent + 2);
    9594        if ( decl != 0) decl->printShort(os, indent + 2);
    9695        os << std::endl;
     
    287286        delete arg;
    288287}
     288
     289// CastExpr *CastExpr::clone() const { return 0; }
    289290
    290291void CastExpr::print( std::ostream &os, int indent ) const {
     
    353354}
    354355
     356//// is this right? It's cloning the member, but the member is a declaration so probably shouldn't be cloned...
    355357MemberExpr::MemberExpr( const MemberExpr &other ) :
    356358                Expression( other ), member( other.member ), aggregate( maybeClone( other.aggregate ) ) {
     
    358360
    359361MemberExpr::~MemberExpr() {
    360         // don't delete the member declaration, since it points somewhere else in the tree
     362        // delete member;
    361363        delete aggregate;
    362364}
     
    588590}
    589591
     592UntypedValofExpr::UntypedValofExpr( const UntypedValofExpr & other ) : Expression( other ), body ( maybeClone( other.body ) ) {}
     593
     594UntypedValofExpr::~UntypedValofExpr() { delete body; }
     595
     596void 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
    590602RangeExpr::RangeExpr( Expression *low, Expression *high ) : low( low ), high( high ) {}
    591603RangeExpr::RangeExpr( const RangeExpr &other ) : Expression( other ), low( other.low->clone() ), high( other.high->clone() ) {}
     
    657669}
    658670
     671InitAlternative::InitAlternative( Type * type, Designation * designation ) : type( type ), designation( designation ) {}
     672InitAlternative::InitAlternative( const InitAlternative & other ) : type( maybeClone( other.type ) ), designation( maybeClone( other.designation ) ) {}
     673InitAlternative::~InitAlternative() {
     674        delete type;
     675        delete designation;
     676}
     677
     678UntypedInitExpr::UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts ) : expr( expr ), initAlts( initAlts ) {}
     679UntypedInitExpr::UntypedInitExpr( const UntypedInitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), initAlts( other.initAlts ) {}
     680UntypedInitExpr::~UntypedInitExpr() {
     681        delete expr;
     682}
     683
     684void 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
     696InitExpr::InitExpr( Expression * expr, Type * type, Designation * designation ) : expr( expr ), designation( designation ) {
     697        set_result( type );
     698}
     699InitExpr::InitExpr( const InitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), designation( maybeClone( other.designation) ) {}
     700InitExpr::~InitExpr() {
     701        delete expr;
     702        delete designation;
     703}
     704
     705void 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
    659713std::ostream & operator<<( std::ostream & out, const Expression * expr ) {
    660714        if ( expr ) {
Note: See TracChangeset for help on using the changeset viewer.