Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    re04ef3a r630a82a  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jun 13 16:03:39 2016
    13 // Update Count     : 42
     12// Last Modified On : Fri Apr  8 17:16:23 2016
     13// Update Count     : 40
    1414//
    1515
     
    3232Expression::Expression( Expression *_aname ) : env( 0 ), argName( _aname ) {}
    3333
    34 Expression::Expression( const Expression &other ) : env( maybeClone( other.env ) ), argName( maybeClone( other.get_argName() ) ), extension( other.extension ) {
     34Expression::Expression( const Expression &other ) : env( maybeClone( other.env ) ), argName( maybeClone( other.get_argName() ) ) {
    3535        cloneAll( other.results, results );
    3636}
     
    6060                argName->print( os, indent+2 );
    6161        } // if
    62 
    63         if ( extension ) {
    64                 os << std::string( indent, ' ' ) << "with extension:";
    65         } // if
    6662}
    6763
     
    7672
    7773void ConstantExpr::print( std::ostream &os, int indent ) const {
    78         os << "constant expression " ;
     74        os << std::string( indent, ' ' ) << "constant expression " ;
    7975        constant.print( os );
    8076        Expression::print( os, indent );
     77        os << std::endl;
    8178}
    8279
    8380VariableExpr::VariableExpr( DeclarationWithType *_var, Expression *_aname ) : Expression( _aname ), var( _var ) {
    84         assert( var );
    85         assert( var->get_type() );
    8681        add_result( var->get_type()->clone() );
    8782        for ( std::list< Type* >::iterator i = get_results().begin(); i != get_results().end(); ++i ) {
     
    9893
    9994void VariableExpr::print( std::ostream &os, int indent ) const {
    100         os << "Variable Expression: ";
     95        os << std::string( indent, ' ' ) << "Variable Expression: ";
    10196
    10297        Declaration *decl = get_var();
     
    127122
    128123void SizeofExpr::print( std::ostream &os, int indent) const {
    129         os << "Sizeof Expression on: ";
     124        os << std::string( indent, ' ' ) << "Sizeof Expression on: ";
    130125
    131126        if (isType)
     
    228223}
    229224
    230 OffsetPackExpr::OffsetPackExpr( StructInstType *type_, Expression *aname_ ) : Expression( aname_ ), type( type_ ) {
    231         add_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) );
    232 }
    233 
    234 OffsetPackExpr::OffsetPackExpr( const OffsetPackExpr &other ) : Expression( other ), type( maybeClone( other.type ) ) {}
    235 
    236 OffsetPackExpr::~OffsetPackExpr() { delete type; }
    237 
    238 void OffsetPackExpr::print( std::ostream &os, int indent ) const {
    239         os << std::string( indent, ' ' ) << "Offset pack expression on ";
    240 
    241         if ( type ) {
    242                 type->print(os, indent + 2);
    243         } else {
    244                 os << "<NULL>";
    245         }
    246 
    247         os << std::endl;
    248         Expression::print( os, indent );
    249 }
    250 
    251225AttrExpr::AttrExpr( Expression *attr, Expression *expr_, Expression *_aname ) :
    252226                Expression( _aname ), attr( attr ), expr(expr_), type(0), isType(false) {
     
    300274
    301275void CastExpr::print( std::ostream &os, int indent ) const {
    302         os << "Cast of:" << std::endl << std::string( indent+2, ' ' );
     276        os << std::string( indent, ' ' ) << "Cast of:" << std::endl;
    303277        arg->print(os, indent+2);
    304278        os << std::endl << std::string( indent, ' ' ) << "to:" << std::endl;
     
    323297
    324298void UntypedMemberExpr::print( std::ostream &os, int indent ) const {
    325         os << "Untyped Member Expression, with field: " << get_member();
     299        os << std::string( indent, ' ' ) << "Member Expression, with field: " << get_member();
    326300
    327301        Expression *agg = get_aggregate();
    328         os << ", from aggregate: ";
    329         if (agg != 0) {
    330                 os << std::string( indent + 2, ' ' );
    331                 agg->print(os, indent + 2);
    332         }
    333         os << std::string( indent+2, ' ' );
     302        os << std::string( indent, ' ' ) << "from aggregate: ";
     303        if (agg != 0) agg->print(os, indent + 2);
    334304        Expression::print( os, indent );
    335305}
     
    354324
    355325void MemberExpr::print( std::ostream &os, int indent ) const {
    356         os << "Member Expression, with field: " << std::endl;
     326        os << std::string( indent, ' ' ) << "Member Expression, with field: " << std::endl;
    357327
    358328        assert( member );
     
    363333        Expression *agg = get_aggregate();
    364334        os << std::string( indent, ' ' ) << "from aggregate: " << std::endl;
    365         if (agg != 0) {
    366                 os << std::string( indent + 2, ' ' );
    367                 agg->print(os, indent + 2);
    368         }
    369         os << std::string( indent+2, ' ' );
     335        if (agg != 0) agg->print(os, indent + 2);
    370336        Expression::print( os, indent );
    371337}
     
    385351
    386352void UntypedExpr::print( std::ostream &os, int indent ) const {
    387         os << "Applying untyped: " << std::endl;
    388         os << std::string( indent+2, ' ' );
    389         function->print(os, indent + 2);
     353        os << std::string( indent, ' ' ) << "Applying untyped: " << std::endl;
     354        function->print(os, indent + 4);
    390355        os << std::string( indent, ' ' ) << "...to: " << std::endl;
    391         printAll(args, os, indent + 2);
     356        printArgs(os, indent + 4);
    392357        Expression::print( os, indent );
    393358}
     
    395360void UntypedExpr::printArgs( std::ostream &os, int indent ) const {
    396361        std::list<Expression *>::const_iterator i;
    397         for (i = args.begin(); i != args.end(); i++) {
    398                 os << std::string(indent, ' ' );
     362        for (i = args.begin(); i != args.end(); i++)
    399363                (*i)->print(os, indent);
    400         }
    401364}
    402365
     
    409372
    410373void NameExpr::print( std::ostream &os, int indent ) const {
    411         os << "Name: " << get_name() << std::endl;
     374        os << std::string( indent, ' ' ) << "Name: " << get_name() << std::endl;
    412375        Expression::print( os, indent );
    413376}
     
    470433}
    471434
    472 
    473 ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( ApplicationExpr * callExpr ) : callExpr( callExpr ) {
    474         assert( callExpr );
    475         cloneAll( callExpr->get_results(), results );
    476 }
    477 
    478 ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other ) : Expression( other ), callExpr( maybeClone( other.callExpr ) ) {
    479         cloneAll( other.tempDecls, tempDecls );
    480         cloneAll( other.returnDecls, returnDecls );
    481         cloneAll( other.dtors, dtors );
    482 }
    483 
    484 ImplicitCopyCtorExpr::~ImplicitCopyCtorExpr() {
    485         delete callExpr;
    486         deleteAll( tempDecls );
    487         deleteAll( returnDecls );
    488         deleteAll( dtors );
    489 }
    490 
    491 void ImplicitCopyCtorExpr::print( std::ostream &os, int indent ) const {
    492         os << std::string( indent, ' ' ) <<  "Implicit Copy Constructor Expression: " << std::endl;
    493         assert( callExpr );
    494         callExpr->print( os, indent + 2 );
    495         os << std::endl << std::string( indent, ' ' ) << "with temporaries:" << std::endl;
    496         printAll(tempDecls, os, indent+2);
    497         os << std::endl << std::string( indent, ' ' ) << "with return temporaries:" << std::endl;
    498         printAll(returnDecls, os, indent+2);
    499         Expression::print( os, indent );
    500 }
    501 
    502435UntypedValofExpr::UntypedValofExpr( const UntypedValofExpr & other ) : Expression( other ), body ( maybeClone( other.body ) ) {}
    503436
Note: See TracChangeset for help on using the changeset viewer.