Ignore:
Timestamp:
Nov 8, 2017, 5:43:33 PM (8 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
954908d
Parents:
78315272 (diff), e35f30a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    r78315272 r3f7e12cb  
    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 ) {
     35void printInferParams( const InferredParams & inferParams, std::ostream &os, Indenter indent, int level ) {
     36        if ( ! inferParams.empty() ) {
     37                os << indent << "with inferred parameters " << level << ":" << std::endl;
     38                for ( InferredParams::const_iterator i = inferParams.begin(); i != inferParams.end(); ++i ) {
     39                        os << indent+1;
     40                        Declaration::declFromId( i->second.decl )->printShort( os, indent+1 );
     41                        os << std::endl;
     42                        printInferParams( *i->second.inferParams, os, indent+1, level+1 );
     43                } // for
     44        } // if
     45}
     46
     47Expression::Expression() : result( 0 ), env( 0 ) {}
     48
     49Expression::Expression( const Expression &other ) : BaseSyntaxNode( other ), result( maybeClone( other.result ) ), env( maybeClone( other.env ) ), extension( other.extension ), inferParams( other.inferParams ) {
    3850}
    3951
    4052Expression::~Expression() {
    4153        delete env;
    42         delete argName; // xxx -- there's a problem in cloning ConstantExpr I still don't know how to fix
    4354        delete result;
    4455}
    4556
    46 void Expression::print( std::ostream &os, int indent ) const {
     57void Expression::print( std::ostream &os, Indenter indent ) const {
     58        printInferParams( inferParams, os, indent+1, 0 );
     59
    4760        if ( env ) {
    48                 os << std::string( indent, ' ' ) << "with environment:" << std::endl;
    49                 env->print( os, indent+2 );
     61                os << std::endl << indent << "... with environment:" << std::endl;
     62                env->print( os, indent+1 );
    5063        } // if
    5164
    52         if ( argName ) {
    53                 os << std::string( indent, ' ' ) << "with designator:";
    54                 argName->print( os, indent+2 );
     65        if ( extension ) {
     66                os << std::endl << indent << "... with extension:";
    5567        } // 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 ) {
     68}
     69
     70ConstantExpr::ConstantExpr( Constant _c ) : Expression(), constant( _c ) {
    6371        set_result( constant.get_type()->clone() );
    6472}
     
    6977ConstantExpr::~ConstantExpr() {}
    7078
    71 void ConstantExpr::print( std::ostream &os, int indent ) const {
     79void ConstantExpr::print( std::ostream &os, Indenter indent ) const {
    7280        os << "constant expression " ;
    7381        constant.print( os );
     
    7583}
    7684
    77 VariableExpr::VariableExpr( DeclarationWithType *_var, Expression *_aname ) : Expression( _aname ), var( _var ) {
     85VariableExpr::VariableExpr( DeclarationWithType *_var ) : Expression(), var( _var ) {
    7886        assert( var );
    7987        assert( var->get_type() );
     
    96104}
    97105
    98 void VariableExpr::print( std::ostream &os, int indent ) const {
     106void VariableExpr::print( std::ostream &os, Indenter indent ) const {
    99107        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) {
     108        var->printShort(os, indent);
     109        Expression::print( os, indent );
     110}
     111
     112SizeofExpr::SizeofExpr( Expression *expr_ ) :
     113                Expression(), expr(expr_), type(0), isType(false) {
    109114        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    110115}
    111116
    112 SizeofExpr::SizeofExpr( Type *type_, Expression *_aname ) :
    113                 Expression( _aname ), expr(0), type(type_), isType(true) {
     117SizeofExpr::SizeofExpr( Type *type_ ) :
     118                Expression(), expr(0), type(type_), isType(true) {
    114119        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    115120}
     
    124129}
    125130
    126 void SizeofExpr::print( std::ostream &os, int indent) const {
     131void SizeofExpr::print( std::ostream &os, Indenter indent) const {
    127132        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) {
     133        if (isType) type->print(os, indent+1);
     134        else expr->print(os, indent+1);
     135        Expression::print( os, indent );
     136}
     137
     138AlignofExpr::AlignofExpr( Expression *expr_ ) :
     139                Expression(), expr(expr_), type(0), isType(false) {
    140140        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    141141}
    142142
    143 AlignofExpr::AlignofExpr( Type *type_, Expression *_aname ) :
    144                 Expression( _aname ), expr(0), type(type_), isType(true) {
     143AlignofExpr::AlignofExpr( Type *type_ ) :
     144                Expression(), expr(0), type(type_), isType(true) {
    145145        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    146146}
     
    155155}
    156156
    157 void AlignofExpr::print( std::ostream &os, int indent) const {
     157void AlignofExpr::print( std::ostream &os, Indenter indent) const {
    158158        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_) {
     159        if (isType) type->print(os, indent+1);
     160        else expr->print(os, indent+1);
     161        Expression::print( os, indent );
     162}
     163
     164UntypedOffsetofExpr::UntypedOffsetofExpr( Type *type, const std::string &member ) :
     165                Expression(), type(type), member(member) {
     166        assert( type );
    171167        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    172168}
     
    179175}
    180176
    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_) {
     177void UntypedOffsetofExpr::print( std::ostream &os, Indenter indent) const {
     178        os << "Untyped Offsetof Expression on member " << member << " of ";
     179        type->print(os, indent+1);
     180        Expression::print( os, indent );
     181}
     182
     183OffsetofExpr::OffsetofExpr( Type *type, DeclarationWithType *member ) :
     184                Expression(), type(type), member(member) {
     185        assert( member );
     186        assert( type );
    196187        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    197188}
     
    204195}
    205196
    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_ ) {
     197void OffsetofExpr::print( std::ostream &os, Indenter indent) const {
     198        os << "Offsetof Expression on member " << member->name << " of ";
     199        type->print(os, indent+1);
     200        Expression::print( os, indent );
     201}
     202
     203OffsetPackExpr::OffsetPackExpr( StructInstType *type ) : Expression(), type( type ) {
     204        assert( type );
    228205        set_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) );
    229206}
     
    233210OffsetPackExpr::~OffsetPackExpr() { delete type; }
    234211
    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) {
     212void OffsetPackExpr::print( std::ostream &os, Indenter indent ) const {
     213        os << "Offset pack expression on ";
     214        type->print(os, indent+1);
     215        Expression::print( os, indent );
     216}
     217
     218AttrExpr::AttrExpr( Expression *attr, Expression *expr_ ) :
     219                Expression(), attr( attr ), expr(expr_), type(0), isType(false) {
     220}
     221
     222AttrExpr::AttrExpr( Expression *attr, Type *type_ ) :
     223                Expression(), attr( attr ), expr(0), type(type_), isType(true) {
    254224}
    255225
     
    264234}
    265235
    266 void AttrExpr::print( std::ostream &os, int indent) const {
     236void AttrExpr::print( std::ostream &os, Indenter indent) const {
    267237        os << "Attr ";
    268         attr->print( os, indent + 2 );
     238        attr->print( os, indent+1);
    269239        if ( isType || expr ) {
    270240                os << "applied to: ";
    271 
    272                 if (isType)
    273                         type->print(os, indent + 2);
    274                 else
    275                         expr->print(os, indent + 2);
     241                if (isType) type->print(os, indent+1);
     242                else expr->print(os, indent+1);
    276243        } // 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_) {
     244        Expression::print( os, indent );
     245}
     246
     247CastExpr::CastExpr( Expression *arg_, Type *toType ) : Expression(), arg(arg_) {
    283248        set_result(toType);
    284249}
    285250
    286 CastExpr::CastExpr( Expression *arg_, Expression *_aname ) : Expression( _aname ), arg(arg_) {
     251CastExpr::CastExpr( Expression *arg_ ) : Expression(), arg(arg_) {
    287252        set_result( new VoidType( Type::Qualifiers() ) );
    288253}
     
    295260}
    296261
    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, ' ' );
     262void CastExpr::print( std::ostream &os, Indenter indent ) const {
     263        os << "Cast of:" << std::endl << indent+1;
     264        arg->print(os, indent+1);
     265        os << std::endl << indent << "... to:";
    302266        if ( result->isVoid() ) {
    303                 os << "nothing";
     267                os << " nothing";
    304268        } else {
    305                 result->print( os, indent+2 );
     269                os << std::endl << indent+1;
     270                result->print( os, indent+1 );
    306271        } // if
    307         os << std::endl;
    308272        Expression::print( os, indent );
    309273}
     
    320284}
    321285
    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, ' ' );
     286void VirtualCastExpr::print( std::ostream &os, Indenter indent ) const {
     287        os << "Virtual Cast of:" << std::endl << indent+1;
     288        arg->print(os, indent+1);
     289        os << std::endl << indent << "... to:";
    327290        if ( ! result ) {
    328                 os << "unknown";
     291                os << " unknown";
    329292        } else {
    330                 result->print( os, indent+2 );
     293                os << std::endl << indent+1;
     294                result->print( os, indent+1 );
    331295        } // 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) {}
     296        Expression::print( os, indent );
     297}
     298
     299UntypedMemberExpr::UntypedMemberExpr( Expression * member, Expression *aggregate ) :
     300                Expression(), member(member), aggregate(aggregate) {
     301        assert( aggregate );
     302}
    338303
    339304UntypedMemberExpr::UntypedMemberExpr( const UntypedMemberExpr &other ) :
     
    346311}
    347312
    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, ' ' );
     313void UntypedMemberExpr::print( std::ostream &os, Indenter indent ) const {
     314        os << "Untyped Member Expression, with field: " << std::endl << indent+1;
     315        member->print(os, indent+1 );
     316        os << indent << "... from aggregate: " << std::endl << indent+1;
     317        aggregate->print(os, indent+1);
    361318        Expression::print( os, indent );
    362319}
     
    377334
    378335
    379 MemberExpr::MemberExpr( DeclarationWithType *_member, Expression *_aggregate, Expression *_aname ) :
    380                 Expression( _aname ), member(_member), aggregate(_aggregate) {
     336MemberExpr::MemberExpr( DeclarationWithType *member, Expression *aggregate ) :
     337                Expression(), member(member), aggregate(aggregate) {
     338        assert( member );
     339        assert( aggregate );
    381340
    382341        TypeSubstitution sub( makeSub( aggregate->get_result() ) );
     
    396355}
    397356
    398 void MemberExpr::print( std::ostream &os, int indent ) const {
     357void MemberExpr::print( std::ostream &os, Indenter indent ) const {
    399358        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) {}
     359        os << indent+1;
     360        member->print( os, indent+1 );
     361        os << std::endl << indent << "... from aggregate: " << std::endl << indent+1;
     362        aggregate->print(os, indent + 1);
     363        Expression::print( os, indent );
     364}
     365
     366UntypedExpr::UntypedExpr( Expression *function, const std::list<Expression *> &args ) :
     367                Expression(), function(function), args(args) {}
    418368
    419369UntypedExpr::UntypedExpr( const UntypedExpr &other ) :
     
    456406
    457407
    458 void UntypedExpr::print( std::ostream &os, int indent ) const {
     408void UntypedExpr::print( std::ostream &os, Indenter indent ) const {
    459409        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");
     410        os << indent+1;
     411        function->print(os, indent+1);
     412        os << std::endl << indent << "...to: " << std::endl;
     413        printAll(args, os, indent+1);
     414        Expression::print( os, indent );
     415}
     416
     417NameExpr::NameExpr( std::string name ) : Expression(), name(name) {
     418        assertf(name != "0", "Zero is not a valid name");
     419        assertf(name != "1", "One is not a valid name");
    478420}
    479421
     
    483425NameExpr::~NameExpr() {}
    484426
    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) {
     427void NameExpr::print( std::ostream &os, Indenter indent ) const {
     428        os << "Name: " << get_name();
     429        Expression::print( os, indent );
     430}
     431
     432LogicalExpr::LogicalExpr( Expression *arg1_, Expression *arg2_, bool andp ) :
     433                Expression(), arg1(arg1_), arg2(arg2_), isAnd(andp) {
    492434        set_result( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );
    493435}
     
    502444}
    503445
    504 void LogicalExpr::print( std::ostream &os, int indent )const {
    505         os << "Short-circuited operation (" << (isAnd?"and":"or") << ") on: ";
     446void LogicalExpr::print( std::ostream &os, Indenter indent )const {
     447        os << "Short-circuited operation (" << (isAnd ? "and" : "or") << ") on: ";
    506448        arg1->print(os);
    507449        os << " and ";
    508450        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_) {}
     451        Expression::print( os, indent );
     452}
     453
     454ConditionalExpr::ConditionalExpr( Expression * arg1, Expression * arg2, Expression * arg3 ) :
     455                Expression(), arg1(arg1), arg2(arg2), arg3(arg3) {}
    515456
    516457ConditionalExpr::ConditionalExpr( const ConditionalExpr &other ) :
     
    524465}
    525466
    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;
     467void ConditionalExpr::print( std::ostream &os, Indenter indent ) const {
     468        os << "Conditional expression on: " << std::endl << indent+1;
     469        arg1->print( os, indent+1 );
     470        os << indent << "First alternative:" << std::endl << indent+1;
     471        arg2->print( os, indent+1 );
     472        os << indent << "Second alternative:" << std::endl << indent+1;
     473        arg3->print( os, indent+1 );
    537474        Expression::print( os, indent );
    538475}
     
    541478
    542479
    543 void AsmExpr::print( std::ostream &os, int indent ) const {
     480void AsmExpr::print( std::ostream &os, Indenter indent ) const {
    544481        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 );
     482        if ( inout ) inout->print( os, indent+1 );
     483        if ( constraint ) constraint->print( os, indent+1 );
     484        if ( operand ) operand->print( os, indent+1 );
    548485}
    549486
     
    551488ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( ApplicationExpr * callExpr ) : callExpr( callExpr ) {
    552489        assert( callExpr );
    553         assert( callExpr->has_result() );
     490        assert( callExpr->result );
    554491        set_result( callExpr->get_result()->clone() );
    555492}
     
    569506}
    570507
    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);
     508void ImplicitCopyCtorExpr::print( std::ostream &os, Indenter indent ) const {
     509        os <<  "Implicit Copy Constructor Expression: " << std::endl << indent+1;
     510        callExpr->print( os, indent+1 );
     511        os << std::endl << indent << "... with temporaries:" << std::endl;
     512        printAll( tempDecls, os, indent+1 );
     513        os << std::endl << indent << "... with return temporaries:" << std::endl;
     514        printAll( returnDecls, os, indent+1 );
    580515        Expression::print( os, indent );
    581516}
     
    587522        Expression * arg = InitTweak::getCallArg( callExpr, 0 );
    588523        assert( arg );
    589         set_result( maybeClone( arg->get_result() ) );
     524        set_result( maybeClone( arg->result ) );
    590525}
    591526
     
    597532}
    598533
    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, ' ' );
     534void ConstructorExpr::print( std::ostream &os, Indenter indent ) const {
     535        os <<  "Constructor Expression: " << std::endl << indent+1;
    603536        callExpr->print( os, indent + 2 );
    604537        Expression::print( os, indent );
     
    618551}
    619552
    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 );
     553void CompoundLiteralExpr::print( std::ostream &os, Indenter indent ) const {
     554        os << "Compound Literal Expression: " << std::endl << indent+1;
     555        result->print( os, indent+1 );
     556        os << indent+1;
     557        initializer->print( os, indent+1 );
    626558        Expression::print( os, indent );
    627559}
     
    629561RangeExpr::RangeExpr( Expression *low, Expression *high ) : low( low ), high( high ) {}
    630562RangeExpr::RangeExpr( const RangeExpr &other ) : Expression( other ), low( other.low->clone() ), high( other.high->clone() ) {}
    631 void RangeExpr::print( std::ostream &os, int indent ) const {
     563void RangeExpr::print( std::ostream &os, Indenter indent ) const {
    632564        os << "Range Expression: ";
    633565        low->print( os, indent );
     
    659591        deleteAll( returnDecls );
    660592}
    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 );
     593void StmtExpr::print( std::ostream &os, Indenter indent ) const {
     594        os << "Statement Expression: " << std::endl << indent+1;
     595        statements->print( os, indent+1 );
    664596        if ( ! returnDecls.empty() ) {
    665                 os << std::string( indent+2, ' ' ) << "with returnDecls: ";
    666                 printAll( returnDecls, os, indent+2 );
     597                os << indent+1 << "... with returnDecls: ";
     598                printAll( returnDecls, os, indent+1 );
    667599        }
    668600        if ( ! dtors.empty() ) {
    669                 os << std::string( indent+2, ' ' ) << "with dtors: ";
    670                 printAll( dtors, os, indent+2 );
     601                os << indent+1 << "... with dtors: ";
     602                printAll( dtors, os, indent+1 );
    671603        }
    672604        Expression::print( os, indent );
     
    690622        delete var;
    691623}
    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 );
     624void UniqueExpr::print( std::ostream &os, Indenter indent ) const {
     625        os << "Unique Expression with id:" << id << std::endl << indent+1;
     626        expr->print( os, indent+1 );
     627        if ( object ) {
     628                os << indent << "... with decl: ";
     629                get_object()->printShort( os, indent+1 );
    698630        }
    699631        Expression::print( os, indent );
     
    713645}
    714646
    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 );
     647void UntypedInitExpr::print( std::ostream & os, Indenter indent ) const {
     648        os << "Untyped Init Expression" << std::endl << indent+1;
     649        expr->print( os, indent+1 );
    718650        if ( ! initAlts.empty() ) {
    719651                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 );
     652                        os << indent+1 <<  "InitAlternative: ";
     653                        alt.type->print( os, indent+1 );
     654                        alt.designation->print( os, indent+1 );
    723655                }
    724656        }
     
    734666}
    735667
    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 );
    741 }
    742 
    743 
    744 std::ostream & operator<<( std::ostream & out, const Expression * expr ) {
    745         if ( expr ) {
    746                 expr->print( out );
    747         } else {
    748                 out << "nullptr";
    749         }
    750         return out;
     668void InitExpr::print( std::ostream & os, Indenter indent ) const {
     669        os << "Init Expression" << std::endl << indent+1;
     670        expr->print( os, indent+1 );
     671        os << indent+1 << "... with designation: ";
     672        designation->print( os, indent+1 );
    751673}
    752674
Note: See TracChangeset for help on using the changeset viewer.