Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    rbf4b4cf rd67cdb7  
    3333#include "GenPoly/Lvalue.h"
    3434
    35 Expression::Expression() : result( 0 ), env( 0 ) {}
    36 
    37 Expression::Expression( const Expression &other ) : BaseSyntaxNode( other ), result( maybeClone( other.result ) ), env( maybeClone( other.env ) ), extension( other.extension ) {
     35Expression::Expression( Expression *_aname ) : result( 0 ), env( 0 ), argName( _aname ) {}
     36
     37Expression::Expression( const Expression &other ) : BaseSyntaxNode( other ), result( maybeClone( other.result ) ), env( maybeClone( other.env ) ), argName( maybeClone( other.get_argName() ) ), extension( other.extension ) {
    3838}
    3939
    4040Expression::~Expression() {
    4141        delete env;
     42        delete argName; // xxx -- there's a problem in cloning ConstantExpr I still don't know how to fix
    4243        delete result;
    4344}
    4445
    45 void Expression::print( std::ostream &os, Indenter indent ) const {
     46void Expression::print( std::ostream &os, int indent ) const {
    4647        if ( env ) {
    47                 os << std::endl << indent << "... with environment:" << std::endl;
    48                 env->print( os, indent+1 );
     48                os << std::string( indent, ' ' ) << "with environment:" << std::endl;
     49                env->print( os, indent+2 );
    4950        } // if
    5051
     52        if ( argName ) {
     53                os << std::string( indent, ' ' ) << "with designator:";
     54                argName->print( os, indent+2 );
     55        } // if
     56
    5157        if ( extension ) {
    52                 os << std::endl << indent << "... with extension:";
     58                os << std::string( indent, ' ' ) << "with extension:";
    5359        } // if
    5460}
    5561
    56 ConstantExpr::ConstantExpr( Constant _c ) : Expression(), constant( _c ) {
     62ConstantExpr::ConstantExpr( Constant _c, Expression *_aname ) : Expression( _aname ), constant( _c ) {
    5763        set_result( constant.get_type()->clone() );
    5864}
     
    6369ConstantExpr::~ConstantExpr() {}
    6470
    65 void ConstantExpr::print( std::ostream &os, Indenter indent ) const {
     71void ConstantExpr::print( std::ostream &os, int indent ) const {
    6672        os << "constant expression " ;
    6773        constant.print( os );
     
    6975}
    7076
    71 VariableExpr::VariableExpr( DeclarationWithType *_var ) : Expression(), var( _var ) {
     77VariableExpr::VariableExpr( DeclarationWithType *_var, Expression *_aname ) : Expression( _aname ), var( _var ) {
    7278        assert( var );
    7379        assert( var->get_type() );
     
    9096}
    9197
    92 void VariableExpr::print( std::ostream &os, Indenter indent ) const {
     98void VariableExpr::print( std::ostream &os, int indent ) const {
    9399        os << "Variable Expression: ";
    94         var->printShort(os, indent);
    95         Expression::print( os, indent );
    96 }
    97 
    98 SizeofExpr::SizeofExpr( Expression *expr_ ) :
    99                 Expression(), expr(expr_), type(0), isType(false) {
     100
     101        Declaration *decl = get_var();
     102        if ( decl != 0) decl->printShort(os, indent + 2);
     103        os << std::endl;
     104        Expression::print( os, indent );
     105}
     106
     107SizeofExpr::SizeofExpr( Expression *expr_, Expression *_aname ) :
     108                Expression( _aname ), expr(expr_), type(0), isType(false) {
    100109        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    101110}
    102111
    103 SizeofExpr::SizeofExpr( Type *type_ ) :
    104                 Expression(), expr(0), type(type_), isType(true) {
     112SizeofExpr::SizeofExpr( Type *type_, Expression *_aname ) :
     113                Expression( _aname ), expr(0), type(type_), isType(true) {
    105114        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    106115}
     
    115124}
    116125
    117 void SizeofExpr::print( std::ostream &os, Indenter indent) const {
     126void SizeofExpr::print( std::ostream &os, int indent) const {
    118127        os << "Sizeof Expression on: ";
    119         if (isType) type->print(os, indent+1);
    120         else expr->print(os, indent+1);
    121         Expression::print( os, indent );
    122 }
    123 
    124 AlignofExpr::AlignofExpr( Expression *expr_ ) :
    125                 Expression(), expr(expr_), type(0), isType(false) {
     128
     129        if (isType)
     130                type->print(os, indent + 2);
     131        else
     132                expr->print(os, indent + 2);
     133
     134        os << std::endl;
     135        Expression::print( os, indent );
     136}
     137
     138AlignofExpr::AlignofExpr( Expression *expr_, Expression *_aname ) :
     139                Expression( _aname ), expr(expr_), type(0), isType(false) {
    126140        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    127141}
    128142
    129 AlignofExpr::AlignofExpr( Type *type_ ) :
    130                 Expression(), expr(0), type(type_), isType(true) {
     143AlignofExpr::AlignofExpr( Type *type_, Expression *_aname ) :
     144                Expression( _aname ), expr(0), type(type_), isType(true) {
    131145        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    132146}
     
    141155}
    142156
    143 void AlignofExpr::print( std::ostream &os, Indenter indent) const {
     157void AlignofExpr::print( std::ostream &os, int indent) const {
    144158        os << "Alignof Expression on: ";
    145         if (isType) type->print(os, indent+1);
    146         else expr->print(os, indent+1);
    147         Expression::print( os, indent );
    148 }
    149 
    150 UntypedOffsetofExpr::UntypedOffsetofExpr( Type *type, const std::string &member ) :
    151                 Expression(), type(type), member(member) {
    152         assert( type );
     159
     160        if (isType)
     161                type->print(os, indent + 2);
     162        else
     163                expr->print(os, indent + 2);
     164
     165        os << std::endl;
     166        Expression::print( os, indent );
     167}
     168
     169UntypedOffsetofExpr::UntypedOffsetofExpr( Type *type_, const std::string &member_, Expression *_aname ) :
     170                Expression( _aname ), type(type_), member(member_) {
    153171        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    154172}
     
    161179}
    162180
    163 void UntypedOffsetofExpr::print( std::ostream &os, Indenter indent) const {
    164         os << "Untyped Offsetof Expression on member " << member << " of ";
    165         type->print(os, indent+1);
    166         Expression::print( os, indent );
    167 }
    168 
    169 OffsetofExpr::OffsetofExpr( Type *type, DeclarationWithType *member ) :
    170                 Expression(), type(type), member(member) {
    171         assert( member );
    172         assert( type );
     181void UntypedOffsetofExpr::print( std::ostream &os, int indent) const {
     182        os << std::string( indent, ' ' ) << "Untyped Offsetof Expression on member " << member << " of ";
     183
     184        if ( type ) {
     185                type->print(os, indent + 2);
     186        } else {
     187                os << "<NULL>";
     188        }
     189
     190        os << std::endl;
     191        Expression::print( os, indent );
     192}
     193
     194OffsetofExpr::OffsetofExpr( Type *type_, DeclarationWithType *member_, Expression *_aname ) :
     195                Expression( _aname ), type(type_), member(member_) {
    173196        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    174197}
     
    181204}
    182205
    183 void OffsetofExpr::print( std::ostream &os, Indenter indent) const {
    184         os << "Offsetof Expression on member " << member->name << " of ";
    185         type->print(os, indent+1);
    186         Expression::print( os, indent );
    187 }
    188 
    189 OffsetPackExpr::OffsetPackExpr( StructInstType *type ) : Expression(), type( type ) {
    190         assert( type );
     206void OffsetofExpr::print( std::ostream &os, int indent) const {
     207        os << std::string( indent, ' ' ) << "Offsetof Expression on member ";
     208
     209        if ( member ) {
     210                os << member->get_name();
     211        } else {
     212                os << "<NULL>";
     213        }
     214
     215        os << " of ";
     216
     217        if ( type ) {
     218                type->print(os, indent + 2);
     219        } else {
     220                os << "<NULL>";
     221        }
     222
     223        os << std::endl;
     224        Expression::print( os, indent );
     225}
     226
     227OffsetPackExpr::OffsetPackExpr( StructInstType *type_, Expression *aname_ ) : Expression( aname_ ), type( type_ ) {
    191228        set_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) );
    192229}
     
    196233OffsetPackExpr::~OffsetPackExpr() { delete type; }
    197234
    198 void OffsetPackExpr::print( std::ostream &os, Indenter indent ) const {
    199         os << "Offset pack expression on ";
    200         type->print(os, indent+1);
    201         Expression::print( os, indent );
    202 }
    203 
    204 AttrExpr::AttrExpr( Expression *attr, Expression *expr_ ) :
    205                 Expression(), attr( attr ), expr(expr_), type(0), isType(false) {
    206 }
    207 
    208 AttrExpr::AttrExpr( Expression *attr, Type *type_ ) :
    209                 Expression(), attr( attr ), expr(0), type(type_), isType(true) {
     235void OffsetPackExpr::print( std::ostream &os, int indent ) const {
     236        os << std::string( indent, ' ' ) << "Offset pack expression on ";
     237
     238        if ( type ) {
     239                type->print(os, indent + 2);
     240        } else {
     241                os << "<NULL>";
     242        }
     243
     244        os << std::endl;
     245        Expression::print( os, indent );
     246}
     247
     248AttrExpr::AttrExpr( Expression *attr, Expression *expr_, Expression *_aname ) :
     249                Expression( _aname ), attr( attr ), expr(expr_), type(0), isType(false) {
     250}
     251
     252AttrExpr::AttrExpr( Expression *attr, Type *type_, Expression *_aname ) :
     253                Expression( _aname ), attr( attr ), expr(0), type(type_), isType(true) {
    210254}
    211255
     
    220264}
    221265
    222 void AttrExpr::print( std::ostream &os, Indenter indent) const {
     266void AttrExpr::print( std::ostream &os, int indent) const {
    223267        os << "Attr ";
    224         attr->print( os, indent+1);
     268        attr->print( os, indent + 2 );
    225269        if ( isType || expr ) {
    226270                os << "applied to: ";
    227                 if (isType) type->print(os, indent+1);
    228                 else expr->print(os, indent+1);
     271
     272                if (isType)
     273                        type->print(os, indent + 2);
     274                else
     275                        expr->print(os, indent + 2);
    229276        } // if
    230         Expression::print( os, indent );
    231 }
    232 
    233 CastExpr::CastExpr( Expression *arg_, Type *toType ) : Expression(), arg(arg_) {
     277
     278        os << std::endl;
     279        Expression::print( os, indent );
     280}
     281
     282CastExpr::CastExpr( Expression *arg_, Type *toType, Expression *_aname ) : Expression( _aname ), arg(arg_) {
    234283        set_result(toType);
    235284}
    236285
    237 CastExpr::CastExpr( Expression *arg_ ) : Expression(), arg(arg_) {
     286CastExpr::CastExpr( Expression *arg_, Expression *_aname ) : Expression( _aname ), arg(arg_) {
    238287        set_result( new VoidType( Type::Qualifiers() ) );
    239288}
     
    246295}
    247296
    248 void CastExpr::print( std::ostream &os, Indenter indent ) const {
    249         os << "Cast of:" << std::endl << indent+1;
    250         arg->print(os, indent+1);
    251         os << std::endl << indent << "... to:";
     297void CastExpr::print( std::ostream &os, int indent ) const {
     298        os << "Cast of:" << std::endl << std::string( indent+2, ' ' );
     299        arg->print(os, indent+2);
     300        os << std::endl << std::string( indent, ' ' ) << "to:" << std::endl;
     301        os << std::string( indent+2, ' ' );
    252302        if ( result->isVoid() ) {
    253                 os << " nothing";
     303                os << "nothing";
    254304        } else {
    255                 os << std::endl << indent+1;
    256                 result->print( os, indent+1 );
     305                result->print( os, indent+2 );
    257306        } // if
     307        os << std::endl;
    258308        Expression::print( os, indent );
    259309}
     
    270320}
    271321
    272 void VirtualCastExpr::print( std::ostream &os, Indenter indent ) const {
    273         os << "Virtual Cast of:" << std::endl << indent+1;
    274         arg->print(os, indent+1);
    275         os << std::endl << indent << "... to:";
     322void VirtualCastExpr::print( std::ostream &os, int indent ) const {
     323        os << "Virtual Cast of:" << std::endl << std::string( indent+2, ' ' );
     324        arg->print(os, indent+2);
     325        os << std::endl << std::string( indent, ' ' ) << "to:" << std::endl;
     326        os << std::string( indent+2, ' ' );
    276327        if ( ! result ) {
    277                 os << " unknown";
     328                os << "unknown";
    278329        } else {
    279                 os << std::endl << indent+1;
    280                 result->print( os, indent+1 );
     330                result->print( os, indent+2 );
    281331        } // if
    282         Expression::print( os, indent );
    283 }
    284 
    285 UntypedMemberExpr::UntypedMemberExpr( Expression * member, Expression *aggregate ) :
    286                 Expression(), member(member), aggregate(aggregate) {
    287         assert( aggregate );
    288 }
     332        os << std::endl;
     333        Expression::print( os, indent );
     334}
     335
     336UntypedMemberExpr::UntypedMemberExpr( Expression * _member, Expression *_aggregate, Expression *_aname ) :
     337                Expression( _aname ), member(_member), aggregate(_aggregate) {}
    289338
    290339UntypedMemberExpr::UntypedMemberExpr( const UntypedMemberExpr &other ) :
     
    297346}
    298347
    299 void UntypedMemberExpr::print( std::ostream &os, Indenter indent ) const {
    300         os << "Untyped Member Expression, with field: " << std::endl << indent+1;
    301         member->print(os, indent+1 );
    302         os << indent << "... from aggregate: " << std::endl << indent+1;
    303         aggregate->print(os, indent+1);
     348void UntypedMemberExpr::print( std::ostream &os, int indent ) const {
     349        os << "Untyped Member Expression, with field: " << std::endl;
     350        os << std::string( indent+2, ' ' );
     351        get_member()->print(os, indent+4);
     352        os << std::string( indent+2, ' ' );
     353
     354        Expression *agg = get_aggregate();
     355        os << "from aggregate: " << std::endl;
     356        if (agg != 0) {
     357                os << std::string( indent + 4, ' ' );
     358                agg->print(os, indent + 4);
     359        }
     360        os << std::string( indent+2, ' ' );
    304361        Expression::print( os, indent );
    305362}
     
    320377
    321378
    322 MemberExpr::MemberExpr( DeclarationWithType *member, Expression *aggregate ) :
    323                 Expression(), member(member), aggregate(aggregate) {
    324         assert( member );
    325         assert( aggregate );
     379MemberExpr::MemberExpr( DeclarationWithType *_member, Expression *_aggregate, Expression *_aname ) :
     380                Expression( _aname ), member(_member), aggregate(_aggregate) {
    326381
    327382        TypeSubstitution sub( makeSub( aggregate->get_result() ) );
     
    341396}
    342397
    343 void MemberExpr::print( std::ostream &os, Indenter indent ) const {
     398void MemberExpr::print( std::ostream &os, int indent ) const {
    344399        os << "Member Expression, with field: " << std::endl;
    345         os << indent+1;
    346         member->print( os, indent+1 );
    347         os << std::endl << indent << "... from aggregate: " << std::endl << indent+1;
    348         aggregate->print(os, indent + 1);
    349         Expression::print( os, indent );
    350 }
    351 
    352 UntypedExpr::UntypedExpr( Expression *function, const std::list<Expression *> &args ) :
    353                 Expression(), function(function), args(args) {}
     400
     401        assert( member );
     402        os << std::string( indent + 2, ' ' );
     403        member->print( os, indent + 2 );
     404        os << std::endl;
     405
     406        Expression *agg = get_aggregate();
     407        os << std::string( indent, ' ' ) << "from aggregate: " << std::endl;
     408        if (agg != 0) {
     409                os << std::string( indent + 2, ' ' );
     410                agg->print(os, indent + 2);
     411        }
     412        os << std::string( indent+2, ' ' );
     413        Expression::print( os, indent );
     414}
     415
     416UntypedExpr::UntypedExpr( Expression *_function, const std::list<Expression *> &_args, Expression *_aname ) :
     417                Expression( _aname ), function(_function), args(_args) {}
    354418
    355419UntypedExpr::UntypedExpr( const UntypedExpr &other ) :
     
    392456
    393457
    394 void UntypedExpr::print( std::ostream &os, Indenter indent ) const {
     458void UntypedExpr::print( std::ostream &os, int indent ) const {
    395459        os << "Applying untyped: " << std::endl;
    396         os << indent+1;
    397         function->print(os, indent+1);
    398         os << std::endl << indent << "...to: " << std::endl;
    399         printAll(args, os, indent+1);
    400         Expression::print( os, indent );
    401 }
    402 
    403 NameExpr::NameExpr( std::string name ) : Expression(), name(name) {
    404         assertf(name != "0", "Zero is not a valid name");
    405         assertf(name != "1", "One is not a valid name");
     460        os << std::string( indent+2, ' ' );
     461        function->print(os, indent + 2);
     462        os << std::string( indent, ' ' ) << "...to: " << std::endl;
     463        printAll(args, os, indent + 2);
     464        Expression::print( os, indent );
     465}
     466
     467void UntypedExpr::printArgs( std::ostream &os, int indent ) const {
     468        std::list<Expression *>::const_iterator i;
     469        for (i = args.begin(); i != args.end(); i++) {
     470                os << std::string(indent, ' ' );
     471                (*i)->print(os, indent);
     472        }
     473}
     474
     475NameExpr::NameExpr( std::string _name, Expression *_aname ) : Expression( _aname ), name(_name) {
     476        assertf(_name != "0", "Zero is not a valid name\n");
     477        assertf(_name != "1", "One is not a valid name\n");
    406478}
    407479
     
    411483NameExpr::~NameExpr() {}
    412484
    413 void NameExpr::print( std::ostream &os, Indenter indent ) const {
    414         os << "Name: " << get_name();
    415         Expression::print( os, indent );
    416 }
    417 
    418 LogicalExpr::LogicalExpr( Expression *arg1_, Expression *arg2_, bool andp ) :
    419                 Expression(), arg1(arg1_), arg2(arg2_), isAnd(andp) {
     485void NameExpr::print( std::ostream &os, int indent ) const {
     486        os << "Name: " << get_name() << std::endl;
     487        Expression::print( os, indent );
     488}
     489
     490LogicalExpr::LogicalExpr( Expression *arg1_, Expression *arg2_, bool andp, Expression *_aname ) :
     491                Expression( _aname ), arg1(arg1_), arg2(arg2_), isAnd(andp) {
    420492        set_result( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );
    421493}
     
    430502}
    431503
    432 void LogicalExpr::print( std::ostream &os, Indenter indent )const {
    433         os << "Short-circuited operation (" << (isAnd ? "and" : "or") << ") on: ";
     504void LogicalExpr::print( std::ostream &os, int indent )const {
     505        os << "Short-circuited operation (" << (isAnd?"and":"or") << ") on: ";
    434506        arg1->print(os);
    435507        os << " and ";
    436508        arg2->print(os);
    437         Expression::print( os, indent );
    438 }
    439 
    440 ConditionalExpr::ConditionalExpr( Expression * arg1, Expression * arg2, Expression * arg3 ) :
    441                 Expression(), arg1(arg1), arg2(arg2), arg3(arg3) {}
     509        os << std::endl;
     510        Expression::print( os, indent );
     511}
     512
     513ConditionalExpr::ConditionalExpr( Expression *arg1_, Expression *arg2_, Expression *arg3_, Expression *_aname ) :
     514                Expression( _aname ), arg1(arg1_), arg2(arg2_), arg3(arg3_) {}
    442515
    443516ConditionalExpr::ConditionalExpr( const ConditionalExpr &other ) :
     
    451524}
    452525
    453 void ConditionalExpr::print( std::ostream &os, Indenter indent ) const {
    454         os << "Conditional expression on: " << std::endl << indent+1;
    455         arg1->print( os, indent+1 );
    456         os << indent << "First alternative:" << std::endl << indent+1;
    457         arg2->print( os, indent+1 );
    458         os << indent << "Second alternative:" << std::endl << indent+1;
    459         arg3->print( os, indent+1 );
     526void ConditionalExpr::print( std::ostream &os, int indent ) const {
     527        os << "Conditional expression on: " << std::endl;
     528        os << std::string( indent+2, ' ' );
     529        arg1->print( os, indent+2 );
     530        os << std::string( indent, ' ' ) << "First alternative:" << std::endl;
     531        os << std::string( indent+2, ' ' );
     532        arg2->print( os, indent+2 );
     533        os << std::string( indent, ' ' ) << "Second alternative:" << std::endl;
     534        os << std::string( indent+2, ' ' );
     535        arg3->print( os, indent+2 );
     536        os << std::endl;
    460537        Expression::print( os, indent );
    461538}
     
    464541
    465542
    466 void AsmExpr::print( std::ostream &os, Indenter indent ) const {
     543void AsmExpr::print( std::ostream &os, int indent ) const {
    467544        os << "Asm Expression: " << std::endl;
    468         if ( inout ) inout->print( os, indent+1 );
    469         if ( constraint ) constraint->print( os, indent+1 );
    470         if ( operand ) operand->print( os, indent+1 );
     545        if ( inout ) inout->print( os, indent + 2 );
     546        if ( constraint ) constraint->print( os, indent + 2 );
     547        if ( operand ) operand->print( os, indent + 2 );
    471548}
    472549
     
    474551ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( ApplicationExpr * callExpr ) : callExpr( callExpr ) {
    475552        assert( callExpr );
    476         assert( callExpr->result );
     553        assert( callExpr->has_result() );
    477554        set_result( callExpr->get_result()->clone() );
    478555}
     
    492569}
    493570
    494 void ImplicitCopyCtorExpr::print( std::ostream &os, Indenter indent ) const {
    495         os <<  "Implicit Copy Constructor Expression: " << std::endl << indent+1;
    496         callExpr->print( os, indent+1 );
    497         os << std::endl << indent << "... with temporaries:" << std::endl;
    498         printAll( tempDecls, os, indent+1 );
    499         os << std::endl << indent << "... with return temporaries:" << std::endl;
    500         printAll( returnDecls, os, indent+1 );
     571void ImplicitCopyCtorExpr::print( std::ostream &os, int indent ) const {
     572        os <<  "Implicit Copy Constructor Expression: " << std::endl;
     573        assert( callExpr );
     574        os << std::string( indent+2, ' ' );
     575        callExpr->print( os, indent + 2 );
     576        os << std::endl << std::string( indent, ' ' ) << "with temporaries:" << std::endl;
     577        printAll(tempDecls, os, indent+2);
     578        os << std::endl << std::string( indent, ' ' ) << "with return temporaries:" << std::endl;
     579        printAll(returnDecls, os, indent+2);
    501580        Expression::print( os, indent );
    502581}
     
    508587        Expression * arg = InitTweak::getCallArg( callExpr, 0 );
    509588        assert( arg );
    510         set_result( maybeClone( arg->result ) );
     589        set_result( maybeClone( arg->get_result() ) );
    511590}
    512591
     
    518597}
    519598
    520 void ConstructorExpr::print( std::ostream &os, Indenter indent ) const {
    521         os <<  "Constructor Expression: " << std::endl << indent+1;
     599void ConstructorExpr::print( std::ostream &os, int indent ) const {
     600        os <<  "Constructor Expression: " << std::endl;
     601        assert( callExpr );
     602        os << std::string( indent+2, ' ' );
    522603        callExpr->print( os, indent + 2 );
    523604        Expression::print( os, indent );
     
    537618}
    538619
    539 void CompoundLiteralExpr::print( std::ostream &os, Indenter indent ) const {
    540         os << "Compound Literal Expression: " << std::endl << indent+1;
    541         result->print( os, indent+1 );
    542         os << indent+1;
    543         initializer->print( os, indent+1 );
     620void CompoundLiteralExpr::print( std::ostream &os, int indent ) const {
     621        os << "Compound Literal Expression: " << std::endl;
     622        os << std::string( indent+2, ' ' );
     623        get_result()->print( os, indent + 2 );
     624        os << std::string( indent+2, ' ' );
     625        initializer->print( os, indent + 2 );
    544626        Expression::print( os, indent );
    545627}
     
    547629RangeExpr::RangeExpr( Expression *low, Expression *high ) : low( low ), high( high ) {}
    548630RangeExpr::RangeExpr( const RangeExpr &other ) : Expression( other ), low( other.low->clone() ), high( other.high->clone() ) {}
    549 void RangeExpr::print( std::ostream &os, Indenter indent ) const {
     631void RangeExpr::print( std::ostream &os, int indent ) const {
    550632        os << "Range Expression: ";
    551633        low->print( os, indent );
     
    577659        deleteAll( returnDecls );
    578660}
    579 void StmtExpr::print( std::ostream &os, Indenter indent ) const {
    580         os << "Statement Expression: " << std::endl << indent+1;
    581         statements->print( os, indent+1 );
     661void StmtExpr::print( std::ostream &os, int indent ) const {
     662        os << "Statement Expression: " << std::endl << std::string( indent, ' ' );
     663        statements->print( os, indent+2 );
    582664        if ( ! returnDecls.empty() ) {
    583                 os << indent+1 << "... with returnDecls: ";
    584                 printAll( returnDecls, os, indent+1 );
     665                os << std::string( indent+2, ' ' ) << "with returnDecls: ";
     666                printAll( returnDecls, os, indent+2 );
    585667        }
    586668        if ( ! dtors.empty() ) {
    587                 os << indent+1 << "... with dtors: ";
    588                 printAll( dtors, os, indent+1 );
     669                os << std::string( indent+2, ' ' ) << "with dtors: ";
     670                printAll( dtors, os, indent+2 );
    589671        }
    590672        Expression::print( os, indent );
     
    608690        delete var;
    609691}
    610 void UniqueExpr::print( std::ostream &os, Indenter indent ) const {
    611         os << "Unique Expression with id:" << id << std::endl << indent+1;
    612         expr->print( os, indent+1 );
    613         if ( object ) {
    614                 os << indent << "... with decl: ";
    615                 get_object()->printShort( os, indent+1 );
     692void UniqueExpr::print( std::ostream &os, int indent ) const {
     693        os << "Unique Expression with id:" << id << std::endl << std::string( indent+2, ' ' );
     694        get_expr()->print( os, indent+2 );
     695        if ( get_object() ) {
     696                os << std::string( indent+2, ' ' ) << "with decl: ";
     697                get_object()->printShort( os, indent+2 );
    616698        }
    617699        Expression::print( os, indent );
     
    631713}
    632714
    633 void UntypedInitExpr::print( std::ostream & os, Indenter indent ) const {
    634         os << "Untyped Init Expression" << std::endl << indent+1;
    635         expr->print( os, indent+1 );
     715void UntypedInitExpr::print( std::ostream & os, int indent ) const {
     716        os << "Untyped Init Expression" << std::endl << std::string( indent+2, ' ' );
     717        expr->print( os, indent+2 );
    636718        if ( ! initAlts.empty() ) {
    637719                for ( const InitAlternative & alt : initAlts ) {
    638                         os << indent+1 <<  "InitAlternative: ";
    639                         alt.type->print( os, indent+1 );
    640                         alt.designation->print( os, indent+1 );
     720                        os << std::string( indent+2, ' ' ) <<  "InitAlternative: ";
     721                        alt.type->print( os, indent+2 );
     722                        alt.designation->print( os, indent+2 );
    641723                }
    642724        }
     
    652734}
    653735
    654 void InitExpr::print( std::ostream & os, Indenter indent ) const {
    655         os << "Init Expression" << std::endl << indent+1;
    656         expr->print( os, indent+1 );
    657         os << indent+1 << "... with designation: ";
    658         designation->print( os, indent+1 );
     736void InitExpr::print( std::ostream & os, int indent ) const {
     737        os << "Init Expression" << std::endl << std::string( indent+2, ' ' );
     738        expr->print( os, indent+2 );
     739        os << std::string( indent+2, ' ' ) << "with designation: ";
     740        designation->print( os, indent+2 );
    659741}
    660742
Note: See TracChangeset for help on using the changeset viewer.