Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    rd67cdb7 rbf4b4cf  
    3333#include "GenPoly/Lvalue.h"
    3434
    35 Expression::Expression( Expression *_aname ) : result( 0 ), env( 0 ), argName( _aname ) {}
    36 
    37 Expression::Expression( const Expression &other ) : BaseSyntaxNode( other ), result( maybeClone( other.result ) ), env( maybeClone( other.env ) ), argName( maybeClone( other.get_argName() ) ), extension( other.extension ) {
     35Expression::Expression() : result( 0 ), env( 0 ) {}
     36
     37Expression::Expression( const Expression &other ) : BaseSyntaxNode( other ), result( maybeClone( other.result ) ), env( maybeClone( other.env ) ), 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
    4342        delete result;
    4443}
    4544
    46 void Expression::print( std::ostream &os, int indent ) const {
     45void Expression::print( std::ostream &os, Indenter indent ) const {
    4746        if ( env ) {
    48                 os << std::string( indent, ' ' ) << "with environment:" << std::endl;
    49                 env->print( os, indent+2 );
     47                os << std::endl << indent << "... with environment:" << std::endl;
     48                env->print( os, indent+1 );
    5049        } // if
    5150
    52         if ( argName ) {
    53                 os << std::string( indent, ' ' ) << "with designator:";
    54                 argName->print( os, indent+2 );
     51        if ( extension ) {
     52                os << std::endl << indent << "... with extension:";
    5553        } // if
    56 
    57         if ( extension ) {
    58                 os << std::string( indent, ' ' ) << "with extension:";
    59         } // if
    60 }
    61 
    62 ConstantExpr::ConstantExpr( Constant _c, Expression *_aname ) : Expression( _aname ), constant( _c ) {
     54}
     55
     56ConstantExpr::ConstantExpr( Constant _c ) : Expression(), constant( _c ) {
    6357        set_result( constant.get_type()->clone() );
    6458}
     
    6963ConstantExpr::~ConstantExpr() {}
    7064
    71 void ConstantExpr::print( std::ostream &os, int indent ) const {
     65void ConstantExpr::print( std::ostream &os, Indenter indent ) const {
    7266        os << "constant expression " ;
    7367        constant.print( os );
     
    7569}
    7670
    77 VariableExpr::VariableExpr( DeclarationWithType *_var, Expression *_aname ) : Expression( _aname ), var( _var ) {
     71VariableExpr::VariableExpr( DeclarationWithType *_var ) : Expression(), var( _var ) {
    7872        assert( var );
    7973        assert( var->get_type() );
     
    9690}
    9791
    98 void VariableExpr::print( std::ostream &os, int indent ) const {
     92void VariableExpr::print( std::ostream &os, Indenter indent ) const {
    9993        os << "Variable Expression: ";
    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 
    107 SizeofExpr::SizeofExpr( Expression *expr_, Expression *_aname ) :
    108                 Expression( _aname ), expr(expr_), type(0), isType(false) {
     94        var->printShort(os, indent);
     95        Expression::print( os, indent );
     96}
     97
     98SizeofExpr::SizeofExpr( Expression *expr_ ) :
     99                Expression(), expr(expr_), type(0), isType(false) {
    109100        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    110101}
    111102
    112 SizeofExpr::SizeofExpr( Type *type_, Expression *_aname ) :
    113                 Expression( _aname ), expr(0), type(type_), isType(true) {
     103SizeofExpr::SizeofExpr( Type *type_ ) :
     104                Expression(), expr(0), type(type_), isType(true) {
    114105        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    115106}
     
    124115}
    125116
    126 void SizeofExpr::print( std::ostream &os, int indent) const {
     117void SizeofExpr::print( std::ostream &os, Indenter indent) const {
    127118        os << "Sizeof Expression on: ";
    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 
    138 AlignofExpr::AlignofExpr( Expression *expr_, Expression *_aname ) :
    139                 Expression( _aname ), expr(expr_), type(0), isType(false) {
     119        if (isType) type->print(os, indent+1);
     120        else expr->print(os, indent+1);
     121        Expression::print( os, indent );
     122}
     123
     124AlignofExpr::AlignofExpr( Expression *expr_ ) :
     125                Expression(), expr(expr_), type(0), isType(false) {
    140126        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    141127}
    142128
    143 AlignofExpr::AlignofExpr( Type *type_, Expression *_aname ) :
    144                 Expression( _aname ), expr(0), type(type_), isType(true) {
     129AlignofExpr::AlignofExpr( Type *type_ ) :
     130                Expression(), expr(0), type(type_), isType(true) {
    145131        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    146132}
     
    155141}
    156142
    157 void AlignofExpr::print( std::ostream &os, int indent) const {
     143void AlignofExpr::print( std::ostream &os, Indenter indent) const {
    158144        os << "Alignof Expression on: ";
    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 
    169 UntypedOffsetofExpr::UntypedOffsetofExpr( Type *type_, const std::string &member_, Expression *_aname ) :
    170                 Expression( _aname ), type(type_), member(member_) {
     145        if (isType) type->print(os, indent+1);
     146        else expr->print(os, indent+1);
     147        Expression::print( os, indent );
     148}
     149
     150UntypedOffsetofExpr::UntypedOffsetofExpr( Type *type, const std::string &member ) :
     151                Expression(), type(type), member(member) {
     152        assert( type );
    171153        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    172154}
     
    179161}
    180162
    181 void 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 
    194 OffsetofExpr::OffsetofExpr( Type *type_, DeclarationWithType *member_, Expression *_aname ) :
    195                 Expression( _aname ), type(type_), member(member_) {
     163void 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
     169OffsetofExpr::OffsetofExpr( Type *type, DeclarationWithType *member ) :
     170                Expression(), type(type), member(member) {
     171        assert( member );
     172        assert( type );
    196173        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    197174}
     
    204181}
    205182
    206 void 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 
    227 OffsetPackExpr::OffsetPackExpr( StructInstType *type_, Expression *aname_ ) : Expression( aname_ ), type( type_ ) {
     183void 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
     189OffsetPackExpr::OffsetPackExpr( StructInstType *type ) : Expression(), type( type ) {
     190        assert( type );
    228191        set_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) );
    229192}
     
    233196OffsetPackExpr::~OffsetPackExpr() { delete type; }
    234197
    235 void 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 
    248 AttrExpr::AttrExpr( Expression *attr, Expression *expr_, Expression *_aname ) :
    249                 Expression( _aname ), attr( attr ), expr(expr_), type(0), isType(false) {
    250 }
    251 
    252 AttrExpr::AttrExpr( Expression *attr, Type *type_, Expression *_aname ) :
    253                 Expression( _aname ), attr( attr ), expr(0), type(type_), isType(true) {
     198void 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
     204AttrExpr::AttrExpr( Expression *attr, Expression *expr_ ) :
     205                Expression(), attr( attr ), expr(expr_), type(0), isType(false) {
     206}
     207
     208AttrExpr::AttrExpr( Expression *attr, Type *type_ ) :
     209                Expression(), attr( attr ), expr(0), type(type_), isType(true) {
    254210}
    255211
     
    264220}
    265221
    266 void AttrExpr::print( std::ostream &os, int indent) const {
     222void AttrExpr::print( std::ostream &os, Indenter indent) const {
    267223        os << "Attr ";
    268         attr->print( os, indent + 2 );
     224        attr->print( os, indent+1);
    269225        if ( isType || expr ) {
    270226                os << "applied to: ";
    271 
    272                 if (isType)
    273                         type->print(os, indent + 2);
    274                 else
    275                         expr->print(os, indent + 2);
     227                if (isType) type->print(os, indent+1);
     228                else expr->print(os, indent+1);
    276229        } // if
    277 
    278         os << std::endl;
    279         Expression::print( os, indent );
    280 }
    281 
    282 CastExpr::CastExpr( Expression *arg_, Type *toType, Expression *_aname ) : Expression( _aname ), arg(arg_) {
     230        Expression::print( os, indent );
     231}
     232
     233CastExpr::CastExpr( Expression *arg_, Type *toType ) : Expression(), arg(arg_) {
    283234        set_result(toType);
    284235}
    285236
    286 CastExpr::CastExpr( Expression *arg_, Expression *_aname ) : Expression( _aname ), arg(arg_) {
     237CastExpr::CastExpr( Expression *arg_ ) : Expression(), arg(arg_) {
    287238        set_result( new VoidType( Type::Qualifiers() ) );
    288239}
     
    295246}
    296247
    297 void 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, ' ' );
     248void 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:";
    302252        if ( result->isVoid() ) {
    303                 os << "nothing";
     253                os << " nothing";
    304254        } else {
    305                 result->print( os, indent+2 );
     255                os << std::endl << indent+1;
     256                result->print( os, indent+1 );
    306257        } // if
    307         os << std::endl;
    308258        Expression::print( os, indent );
    309259}
     
    320270}
    321271
    322 void 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, ' ' );
     272void 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:";
    327276        if ( ! result ) {
    328                 os << "unknown";
     277                os << " unknown";
    329278        } else {
    330                 result->print( os, indent+2 );
     279                os << std::endl << indent+1;
     280                result->print( os, indent+1 );
    331281        } // if
    332         os << std::endl;
    333         Expression::print( os, indent );
    334 }
    335 
    336 UntypedMemberExpr::UntypedMemberExpr( Expression * _member, Expression *_aggregate, Expression *_aname ) :
    337                 Expression( _aname ), member(_member), aggregate(_aggregate) {}
     282        Expression::print( os, indent );
     283}
     284
     285UntypedMemberExpr::UntypedMemberExpr( Expression * member, Expression *aggregate ) :
     286                Expression(), member(member), aggregate(aggregate) {
     287        assert( aggregate );
     288}
    338289
    339290UntypedMemberExpr::UntypedMemberExpr( const UntypedMemberExpr &other ) :
     
    346297}
    347298
    348 void 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, ' ' );
     299void 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);
    361304        Expression::print( os, indent );
    362305}
     
    377320
    378321
    379 MemberExpr::MemberExpr( DeclarationWithType *_member, Expression *_aggregate, Expression *_aname ) :
    380                 Expression( _aname ), member(_member), aggregate(_aggregate) {
     322MemberExpr::MemberExpr( DeclarationWithType *member, Expression *aggregate ) :
     323                Expression(), member(member), aggregate(aggregate) {
     324        assert( member );
     325        assert( aggregate );
    381326
    382327        TypeSubstitution sub( makeSub( aggregate->get_result() ) );
     
    396341}
    397342
    398 void MemberExpr::print( std::ostream &os, int indent ) const {
     343void MemberExpr::print( std::ostream &os, Indenter indent ) const {
    399344        os << "Member Expression, with field: " << std::endl;
    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 
    416 UntypedExpr::UntypedExpr( Expression *_function, const std::list<Expression *> &_args, Expression *_aname ) :
    417                 Expression( _aname ), function(_function), args(_args) {}
     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
     352UntypedExpr::UntypedExpr( Expression *function, const std::list<Expression *> &args ) :
     353                Expression(), function(function), args(args) {}
    418354
    419355UntypedExpr::UntypedExpr( const UntypedExpr &other ) :
     
    456392
    457393
    458 void UntypedExpr::print( std::ostream &os, int indent ) const {
     394void UntypedExpr::print( std::ostream &os, Indenter indent ) const {
    459395        os << "Applying untyped: " << std::endl;
    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 
    467 void 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 
    475 NameExpr::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");
     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
     403NameExpr::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");
    478406}
    479407
     
    483411NameExpr::~NameExpr() {}
    484412
    485 void NameExpr::print( std::ostream &os, int indent ) const {
    486         os << "Name: " << get_name() << std::endl;
    487         Expression::print( os, indent );
    488 }
    489 
    490 LogicalExpr::LogicalExpr( Expression *arg1_, Expression *arg2_, bool andp, Expression *_aname ) :
    491                 Expression( _aname ), arg1(arg1_), arg2(arg2_), isAnd(andp) {
     413void NameExpr::print( std::ostream &os, Indenter indent ) const {
     414        os << "Name: " << get_name();
     415        Expression::print( os, indent );
     416}
     417
     418LogicalExpr::LogicalExpr( Expression *arg1_, Expression *arg2_, bool andp ) :
     419                Expression(), arg1(arg1_), arg2(arg2_), isAnd(andp) {
    492420        set_result( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );
    493421}
     
    502430}
    503431
    504 void LogicalExpr::print( std::ostream &os, int indent )const {
    505         os << "Short-circuited operation (" << (isAnd?"and":"or") << ") on: ";
     432void LogicalExpr::print( std::ostream &os, Indenter indent )const {
     433        os << "Short-circuited operation (" << (isAnd ? "and" : "or") << ") on: ";
    506434        arg1->print(os);
    507435        os << " and ";
    508436        arg2->print(os);
    509         os << std::endl;
    510         Expression::print( os, indent );
    511 }
    512 
    513 ConditionalExpr::ConditionalExpr( Expression *arg1_, Expression *arg2_, Expression *arg3_, Expression *_aname ) :
    514                 Expression( _aname ), arg1(arg1_), arg2(arg2_), arg3(arg3_) {}
     437        Expression::print( os, indent );
     438}
     439
     440ConditionalExpr::ConditionalExpr( Expression * arg1, Expression * arg2, Expression * arg3 ) :
     441                Expression(), arg1(arg1), arg2(arg2), arg3(arg3) {}
    515442
    516443ConditionalExpr::ConditionalExpr( const ConditionalExpr &other ) :
     
    524451}
    525452
    526 void 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;
     453void 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 );
    537460        Expression::print( os, indent );
    538461}
     
    541464
    542465
    543 void AsmExpr::print( std::ostream &os, int indent ) const {
     466void AsmExpr::print( std::ostream &os, Indenter indent ) const {
    544467        os << "Asm Expression: " << std::endl;
    545         if ( inout ) inout->print( os, indent + 2 );
    546         if ( constraint ) constraint->print( os, indent + 2 );
    547         if ( operand ) operand->print( os, indent + 2 );
     468        if ( inout ) inout->print( os, indent+1 );
     469        if ( constraint ) constraint->print( os, indent+1 );
     470        if ( operand ) operand->print( os, indent+1 );
    548471}
    549472
     
    551474ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( ApplicationExpr * callExpr ) : callExpr( callExpr ) {
    552475        assert( callExpr );
    553         assert( callExpr->has_result() );
     476        assert( callExpr->result );
    554477        set_result( callExpr->get_result()->clone() );
    555478}
     
    569492}
    570493
    571 void 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);
     494void 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 );
    580501        Expression::print( os, indent );
    581502}
     
    587508        Expression * arg = InitTweak::getCallArg( callExpr, 0 );
    588509        assert( arg );
    589         set_result( maybeClone( arg->get_result() ) );
     510        set_result( maybeClone( arg->result ) );
    590511}
    591512
     
    597518}
    598519
    599 void ConstructorExpr::print( std::ostream &os, int indent ) const {
    600         os <<  "Constructor Expression: " << std::endl;
    601         assert( callExpr );
    602         os << std::string( indent+2, ' ' );
     520void ConstructorExpr::print( std::ostream &os, Indenter indent ) const {
     521        os <<  "Constructor Expression: " << std::endl << indent+1;
    603522        callExpr->print( os, indent + 2 );
    604523        Expression::print( os, indent );
     
    618537}
    619538
    620 void 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 );
     539void 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 );
    626544        Expression::print( os, indent );
    627545}
     
    629547RangeExpr::RangeExpr( Expression *low, Expression *high ) : low( low ), high( high ) {}
    630548RangeExpr::RangeExpr( const RangeExpr &other ) : Expression( other ), low( other.low->clone() ), high( other.high->clone() ) {}
    631 void RangeExpr::print( std::ostream &os, int indent ) const {
     549void RangeExpr::print( std::ostream &os, Indenter indent ) const {
    632550        os << "Range Expression: ";
    633551        low->print( os, indent );
     
    659577        deleteAll( returnDecls );
    660578}
    661 void StmtExpr::print( std::ostream &os, int indent ) const {
    662         os << "Statement Expression: " << std::endl << std::string( indent, ' ' );
    663         statements->print( os, indent+2 );
     579void StmtExpr::print( std::ostream &os, Indenter indent ) const {
     580        os << "Statement Expression: " << std::endl << indent+1;
     581        statements->print( os, indent+1 );
    664582        if ( ! returnDecls.empty() ) {
    665                 os << std::string( indent+2, ' ' ) << "with returnDecls: ";
    666                 printAll( returnDecls, os, indent+2 );
     583                os << indent+1 << "... with returnDecls: ";
     584                printAll( returnDecls, os, indent+1 );
    667585        }
    668586        if ( ! dtors.empty() ) {
    669                 os << std::string( indent+2, ' ' ) << "with dtors: ";
    670                 printAll( dtors, os, indent+2 );
     587                os << indent+1 << "... with dtors: ";
     588                printAll( dtors, os, indent+1 );
    671589        }
    672590        Expression::print( os, indent );
     
    690608        delete var;
    691609}
    692 void 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 );
     610void 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 );
    698616        }
    699617        Expression::print( os, indent );
     
    713631}
    714632
    715 void 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 );
     633void UntypedInitExpr::print( std::ostream & os, Indenter indent ) const {
     634        os << "Untyped Init Expression" << std::endl << indent+1;
     635        expr->print( os, indent+1 );
    718636        if ( ! initAlts.empty() ) {
    719637                for ( const InitAlternative & alt : initAlts ) {
    720                         os << std::string( indent+2, ' ' ) <<  "InitAlternative: ";
    721                         alt.type->print( os, indent+2 );
    722                         alt.designation->print( os, indent+2 );
     638                        os << indent+1 <<  "InitAlternative: ";
     639                        alt.type->print( os, indent+1 );
     640                        alt.designation->print( os, indent+1 );
    723641                }
    724642        }
     
    734652}
    735653
    736 void 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 );
     654void 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 );
    741659}
    742660
Note: See TracChangeset for help on using the changeset viewer.