Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Alternative.cc

    r50377a4 rea6332d  
    3434                : cost( cost ), cvtCost( cvtCost ), expr( expr ), env( env ) {}
    3535
    36         Alternative::Alternative( const Alternative &other ) : cost( other.cost ), cvtCost( other.cvtCost ), expr( maybeClone( other.expr ) ), env( other.env ) {
     36        Alternative::Alternative( const Alternative &other ) {
     37                initialize( other, *this );
    3738        }
    3839
    3940        Alternative &Alternative::operator=( const Alternative &other ) {
    4041                if ( &other == this ) return *this;
    41                 delete expr;
    42                 cost = other.cost;
    43                 cvtCost = other.cvtCost;
    44                 expr = maybeClone( other.expr );
    45                 env = other.env;
     42                initialize( other, *this );
    4643                return *this;
    4744        }
     
    6259        }
    6360
     61        void Alternative::initialize( const Alternative &src, Alternative &dest ) {
     62                dest.cost = src.cost;
     63                dest.cvtCost = src.cvtCost;
     64                dest.expr = maybeClone( src.expr );
     65                dest.env = src.env;
     66        }
     67
    6468        Alternative::~Alternative() {
    6569                delete expr;
    6670        }
    6771
    68         void Alternative::print( std::ostream &os, Indenter indent ) const {
    69                 os << "Cost " << cost << ": ";
     72        void Alternative::print( std::ostream &os, int indent ) const {
     73                os << std::string( indent, ' ' ) << "Cost " << cost << ": ";
    7074                if ( expr ) {
    71                         expr->print( os, indent+1 );
    72                         os << std::endl << indent << "(types:" << std::endl;
    73                         os << indent+1;
    74                         expr->result->print( os, indent+1 );
    75                         os << std::endl << indent << ")" << std::endl;
     75                        expr->print( os, indent );
     76                        os << "(types:" << std::endl;
     77                        os << std::string( indent+4, ' ' );
     78                        expr->get_result()->print( os, indent + 4 );
     79                        os << std::endl << ")" << std::endl;
    7680                } else {
    7781                        os << "Null expression!" << std::endl;
    7882                } // if
    79                 os << indent << "Environment: ";
    80                 env.print( os, indent+1 );
     83                os << std::string( indent, ' ' ) << "Environment: ";
     84                env.print( os, indent+2 );
    8185                os << std::endl;
    8286        }
Note: See TracChangeset for help on using the changeset viewer.