Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    rd807ca28 rb4f8808  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jul 25 14:15:47 2017
    13 // Update Count     : 54
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Thr Aug 15 13:43:00 2019
     13// Update Count     : 64
    1414//
    1515
     
    1919#include <iostream>                  // for ostream, operator<<, basic_ostream
    2020#include <list>                      // for list, _List_iterator, list<>::co...
     21#include <set>                       // for set
    2122
    2223#include "Common/utility.h"          // for maybeClone, cloneAll, deleteAll
     
    3334#include "GenPoly/Lvalue.h"
    3435
    35 void printInferParams( const InferredParams & inferParams, std::ostream &os, Indenter indent, int level ) {
     36void printInferParams( const InferredParams & inferParams, std::ostream & os, Indenter indent, int level ) {
    3637        if ( ! inferParams.empty() ) {
    3738                os << indent << "with inferred parameters " << level << ":" << std::endl;
    3839                for ( InferredParams::const_iterator i = inferParams.begin(); i != inferParams.end(); ++i ) {
    3940                        os << indent+1;
    40                         Declaration::declFromId( i->second.decl )->printShort( os, indent+1 );
     41                        assert(i->second.declptr);
     42                        i->second.declptr->printShort( os, indent+1 );
    4143                        os << std::endl;
    42                         printInferParams( *i->second.inferParams, os, indent+1, level+1 );
     44                        printInferParams( i->second.expr->inferParams, os, indent+1, level+1 );
    4345                } // for
    4446        } // if
     
    4749Expression::Expression() : result( 0 ), env( 0 ) {}
    4850
    49 Expression::Expression( const Expression &other ) : BaseSyntaxNode( other ), result( maybeClone( other.result ) ), env( maybeClone( other.env ) ), extension( other.extension ), inferParams( other.inferParams ) {
    50 }
     51Expression::Expression( const Expression & other ) : BaseSyntaxNode( other ), result( maybeClone( other.result ) ), env( maybeClone( other.env ) ), extension( other.extension ), inferParams( other.inferParams ), resnSlots( other.resnSlots ) {}
    5152
    5253void Expression::spliceInferParams( Expression * other ) {
     
    5556                inferParams[p.first] = std::move( p.second );
    5657        }
     58        resnSlots.insert( resnSlots.end(), other->resnSlots.begin(), other->resnSlots.end() );
    5759}
    5860
     
    6264}
    6365
    64 void Expression::print( std::ostream &os, Indenter indent ) const {
     66bool Expression::get_lvalue() const {
     67        return false;
     68}
     69
     70void Expression::print( std::ostream & os, Indenter indent ) const {
    6571        printInferParams( inferParams, os, indent+1, 0 );
    6672
     
    7985}
    8086
    81 ConstantExpr::ConstantExpr( const ConstantExpr &other) : Expression( other ), constant( other.constant ) {
     87ConstantExpr::ConstantExpr( const ConstantExpr & other) : Expression( other ), constant( other.constant ) {
    8288}
    8389
    8490ConstantExpr::~ConstantExpr() {}
    8591
    86 void ConstantExpr::print( std::ostream &os, Indenter indent ) const {
     92void ConstantExpr::print( std::ostream & os, Indenter indent ) const {
    8793        os << "constant expression " ;
    8894        constant.print( os );
     
    103109}
    104110
     111VariableExpr::VariableExpr() : Expression(), var( nullptr ) {}
     112
    105113VariableExpr::VariableExpr( DeclarationWithType *_var ) : Expression(), var( _var ) {
    106114        assert( var );
    107115        assert( var->get_type() );
    108116        Type * type = var->get_type()->clone();
    109         type->set_lvalue( true );
    110117
    111118        // xxx - doesn't quite work yet - get different alternatives with the same cost
     
    117124        //      long long int value;
    118125        //      if ( decl->valueOf( var, value ) ) {
    119         //              type->set_lvalue( false );
     126        //              type->set_lvalue( false ); // Would have to move to get_lvalue.
    120127        //      }
    121128        // }
     
    124131}
    125132
    126 VariableExpr::VariableExpr( const VariableExpr &other ) : Expression( other ), var( other.var ) {
     133VariableExpr::VariableExpr( const VariableExpr & other ) : Expression( other ), var( other.var ) {
    127134}
    128135
    129136VariableExpr::~VariableExpr() {
    130137        // don't delete the declaration, since it points somewhere else in the tree
     138}
     139
     140bool VariableExpr::get_lvalue() const {
     141        // It isn't always an lvalue, but it is never an rvalue.
     142        return true;
    131143}
    132144
     
    137149}
    138150
    139 void VariableExpr::print( std::ostream &os, Indenter indent ) const {
     151void VariableExpr::print( std::ostream & os, Indenter indent ) const {
    140152        os << "Variable Expression: ";
    141153        var->printShort(os, indent);
     
    143155}
    144156
    145 SizeofExpr::SizeofExpr( Expression *expr_ ) :
     157SizeofExpr::SizeofExpr( Expression * expr_ ) :
    146158                Expression(), expr(expr_), type(0), isType(false) {
    147159        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    148160}
    149161
    150 SizeofExpr::SizeofExpr( Type *type_ ) :
     162SizeofExpr::SizeofExpr( Type * type_ ) :
    151163                Expression(), expr(0), type(type_), isType(true) {
    152164        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    153165}
    154166
    155 SizeofExpr::SizeofExpr( const SizeofExpr &other ) :
     167SizeofExpr::SizeofExpr( const SizeofExpr & other ) :
    156168        Expression( other ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) {
    157169}
     
    162174}
    163175
    164 void SizeofExpr::print( std::ostream &os, Indenter indent) const {
     176void SizeofExpr::print( std::ostream & os, Indenter indent) const {
    165177        os << "Sizeof Expression on: ";
    166178        if (isType) type->print(os, indent+1);
     
    169181}
    170182
    171 AlignofExpr::AlignofExpr( Expression *expr_ ) :
     183AlignofExpr::AlignofExpr( Expression * expr_ ) :
    172184                Expression(), expr(expr_), type(0), isType(false) {
    173185        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    174186}
    175187
    176 AlignofExpr::AlignofExpr( Type *type_ ) :
     188AlignofExpr::AlignofExpr( Type * type_ ) :
    177189                Expression(), expr(0), type(type_), isType(true) {
    178190        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    179191}
    180192
    181 AlignofExpr::AlignofExpr( const AlignofExpr &other ) :
     193AlignofExpr::AlignofExpr( const AlignofExpr & other ) :
    182194        Expression( other ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) {
    183195}
     
    188200}
    189201
    190 void AlignofExpr::print( std::ostream &os, Indenter indent) const {
     202void AlignofExpr::print( std::ostream & os, Indenter indent) const {
    191203        os << "Alignof Expression on: ";
    192204        if (isType) type->print(os, indent+1);
     
    195207}
    196208
    197 UntypedOffsetofExpr::UntypedOffsetofExpr( Type *type, const std::string &member ) :
     209UntypedOffsetofExpr::UntypedOffsetofExpr( Type * type, const std::string & member ) :
    198210                Expression(), type(type), member(member) {
    199211        assert( type );
     
    201213}
    202214
    203 UntypedOffsetofExpr::UntypedOffsetofExpr( const UntypedOffsetofExpr &other ) :
     215UntypedOffsetofExpr::UntypedOffsetofExpr( const UntypedOffsetofExpr & other ) :
    204216        Expression( other ), type( maybeClone( other.type ) ), member( other.member ) {}
    205217
     
    208220}
    209221
    210 void UntypedOffsetofExpr::print( std::ostream &os, Indenter indent) const {
     222void UntypedOffsetofExpr::print( std::ostream & os, Indenter indent) const {
    211223        os << "Untyped Offsetof Expression on member " << member << " of ";
    212224        type->print(os, indent+1);
     
    214226}
    215227
    216 OffsetofExpr::OffsetofExpr( Type *type, DeclarationWithType *member ) :
     228OffsetofExpr::OffsetofExpr( Type * type, DeclarationWithType * member ) :
    217229                Expression(), type(type), member(member) {
    218230        assert( member );
     
    221233}
    222234
    223 OffsetofExpr::OffsetofExpr( const OffsetofExpr &other ) :
     235OffsetofExpr::OffsetofExpr( const OffsetofExpr & other ) :
    224236        Expression( other ), type( maybeClone( other.type ) ), member( other.member ) {}
    225237
     
    228240}
    229241
    230 void OffsetofExpr::print( std::ostream &os, Indenter indent) const {
     242void OffsetofExpr::print( std::ostream & os, Indenter indent) const {
    231243        os << "Offsetof Expression on member " << member->name << " of ";
    232244        type->print(os, indent+1);
     
    234246}
    235247
    236 OffsetPackExpr::OffsetPackExpr( StructInstType *type ) : Expression(), type( type ) {
     248OffsetPackExpr::OffsetPackExpr( StructInstType * type ) : Expression(), type( type ) {
    237249        assert( type );
    238250        set_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) );
    239251}
    240252
    241 OffsetPackExpr::OffsetPackExpr( const OffsetPackExpr &other ) : Expression( other ), type( maybeClone( other.type ) ) {}
     253OffsetPackExpr::OffsetPackExpr( const OffsetPackExpr & other ) : Expression( other ), type( maybeClone( other.type ) ) {}
    242254
    243255OffsetPackExpr::~OffsetPackExpr() { delete type; }
    244256
    245 void OffsetPackExpr::print( std::ostream &os, Indenter indent ) const {
     257void OffsetPackExpr::print( std::ostream & os, Indenter indent ) const {
    246258        os << "Offset pack expression on ";
    247259        type->print(os, indent+1);
     
    249261}
    250262
    251 AttrExpr::AttrExpr( Expression *attr, Expression *expr_ ) :
    252                 Expression(), attr( attr ), expr(expr_), type(0), isType(false) {
    253 }
    254 
    255 AttrExpr::AttrExpr( Expression *attr, Type *type_ ) :
    256                 Expression(), attr( attr ), expr(0), type(type_), isType(true) {
    257 }
    258 
    259 AttrExpr::AttrExpr( const AttrExpr &other ) :
    260                 Expression( other ), attr( maybeClone( other.attr ) ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) {
    261 }
    262 
    263 AttrExpr::~AttrExpr() {
    264         delete attr;
    265         delete expr;
    266         delete type;
    267 }
    268 
    269 void AttrExpr::print( std::ostream &os, Indenter indent) const {
    270         os << "Attr ";
    271         attr->print( os, indent+1);
    272         if ( isType || expr ) {
    273                 os << "applied to: ";
    274                 if (isType) type->print(os, indent+1);
    275                 else expr->print(os, indent+1);
    276         } // if
    277         Expression::print( os, indent );
    278 }
    279 
    280 CastExpr::CastExpr( Expression *arg, Type *toType, bool isGenerated ) : Expression(), arg(arg), isGenerated( isGenerated ) {
     263CastExpr::CastExpr( Expression * arg, Type * toType, bool isGenerated ) : arg(arg), isGenerated( isGenerated ) {
    281264        set_result(toType);
    282265}
    283266
    284 CastExpr::CastExpr( Expression *arg, bool isGenerated ) : Expression(), arg(arg), isGenerated( isGenerated ) {
     267CastExpr::CastExpr( Expression * arg, bool isGenerated ) : arg(arg), isGenerated( isGenerated ) {
    285268        set_result( new VoidType( Type::Qualifiers() ) );
    286269}
    287270
    288 CastExpr::CastExpr( const CastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ), isGenerated( other.isGenerated ) {
     271CastExpr::CastExpr( const CastExpr & other ) : Expression( other ), arg( maybeClone( other.arg ) ), isGenerated( other.isGenerated ) {
    289272}
    290273
     
    293276}
    294277
    295 void CastExpr::print( std::ostream &os, Indenter indent ) const {
    296         os << "Cast of:" << std::endl << indent+1;
     278bool CastExpr::get_lvalue() const {
     279        // This is actually wrong by C, but it works with our current set-up.
     280        return arg->get_lvalue();
     281}
     282
     283void CastExpr::print( std::ostream & os, Indenter indent ) const {
     284        os << (isGenerated ? "Generated " : "Explicit ") << "Cast of:" << std::endl << indent+1;
    297285        arg->print(os, indent+1);
    298286        os << std::endl << indent << "... to:";
     
    306294}
    307295
    308 KeywordCastExpr::KeywordCastExpr( Expression *arg, Target target ) : Expression(), arg(arg), target( target ) {
    309 }
    310 
    311 KeywordCastExpr::KeywordCastExpr( const KeywordCastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ), target( other.target ) {
     296KeywordCastExpr::KeywordCastExpr( Expression * arg, Target target ) : Expression(), arg(arg), target( target ) {
     297}
     298
     299KeywordCastExpr::KeywordCastExpr( const KeywordCastExpr & other ) : Expression( other ), arg( maybeClone( other.arg ) ), target( other.target ) {
    312300}
    313301
     
    327315}
    328316
    329 void KeywordCastExpr::print( std::ostream &os, Indenter indent ) const {
     317void KeywordCastExpr::print( std::ostream & os, Indenter indent ) const {
    330318        os << "Keyword Cast of:" << std::endl << indent+1;
    331319        arg->print(os, indent+1);
     
    335323}
    336324
    337 VirtualCastExpr::VirtualCastExpr( Expression *arg_, Type *toType ) : Expression(), arg(arg_) {
     325VirtualCastExpr::VirtualCastExpr( Expression * arg_, Type * toType ) : Expression(), arg(arg_) {
    338326        set_result(toType);
    339327}
    340328
    341 VirtualCastExpr::VirtualCastExpr( const VirtualCastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ) {
     329VirtualCastExpr::VirtualCastExpr( const VirtualCastExpr & other ) : Expression( other ), arg( maybeClone( other.arg ) ) {
    342330}
    343331
     
    346334}
    347335
    348 void VirtualCastExpr::print( std::ostream &os, Indenter indent ) const {
     336void VirtualCastExpr::print( std::ostream & os, Indenter indent ) const {
    349337        os << "Virtual Cast of:" << std::endl << indent+1;
    350338        arg->print(os, indent+1);
     
    359347}
    360348
    361 UntypedMemberExpr::UntypedMemberExpr( Expression * member, Expression *aggregate ) :
     349UntypedMemberExpr::UntypedMemberExpr( Expression * member, Expression * aggregate ) :
    362350                Expression(), member(member), aggregate(aggregate) {
    363351        assert( aggregate );
    364352}
    365353
    366 UntypedMemberExpr::UntypedMemberExpr( const UntypedMemberExpr &other ) :
     354UntypedMemberExpr::UntypedMemberExpr( const UntypedMemberExpr & other ) :
    367355                Expression( other ), member( maybeClone( other.member ) ), aggregate( maybeClone( other.aggregate ) ) {
    368356}
     
    373361}
    374362
    375 void UntypedMemberExpr::print( std::ostream &os, Indenter indent ) const {
     363bool UntypedMemberExpr::get_lvalue() const {
     364        return aggregate->get_lvalue();
     365}
     366
     367void UntypedMemberExpr::print( std::ostream & os, Indenter indent ) const {
    376368        os << "Untyped Member Expression, with field: " << std::endl << indent+1;
    377369        member->print(os, indent+1 );
    378         os << indent << "... from aggregate: " << std::endl << indent+1;
     370        os << indent << "... from aggregate:" << std::endl << indent+1;
    379371        aggregate->print(os, indent+1);
    380372        Expression::print( os, indent );
    381373}
    382374
    383 MemberExpr::MemberExpr( DeclarationWithType *member, Expression *aggregate ) :
     375MemberExpr::MemberExpr( DeclarationWithType * member, Expression * aggregate ) :
    384376                Expression(), member(member), aggregate(aggregate) {
    385377        assert( member );
     
    391383        sub.apply( res );
    392384        result = res;
    393         result->set_lvalue( true );
    394385        result->get_qualifiers() |= aggregate->result->get_qualifiers();
    395386}
    396387
    397 MemberExpr::MemberExpr( const MemberExpr &other ) :
     388MemberExpr::MemberExpr( const MemberExpr & other ) :
    398389                Expression( other ), member( other.member ), aggregate( maybeClone( other.aggregate ) ) {
    399390}
     
    404395}
    405396
    406 void MemberExpr::print( std::ostream &os, Indenter indent ) const {
    407         os << "Member Expression, with field: " << std::endl;
     397bool MemberExpr::get_lvalue() const {
     398        // This is actually wrong by C, but it works with our current set-up.
     399        return true;
     400}
     401
     402void MemberExpr::print( std::ostream & os, Indenter indent ) const {
     403        os << "Member Expression, with field:" << std::endl;
    408404        os << indent+1;
    409405        member->print( os, indent+1 );
    410         os << std::endl << indent << "... from aggregate: " << std::endl << indent+1;
     406        os << std::endl << indent << "... from aggregate:" << std::endl << indent+1;
    411407        aggregate->print(os, indent + 1);
    412408        Expression::print( os, indent );
    413409}
    414410
    415 UntypedExpr::UntypedExpr( Expression *function, const std::list<Expression *> &args ) :
     411UntypedExpr::UntypedExpr( Expression * function, const std::list<Expression *> & args ) :
    416412                Expression(), function(function), args(args) {}
    417413
    418 UntypedExpr::UntypedExpr( const UntypedExpr &other ) :
     414UntypedExpr::UntypedExpr( const UntypedExpr & other ) :
    419415                Expression( other ), function( maybeClone( other.function ) ) {
    420416        cloneAll( other.args, args );
     
    435431                        // if references are still allowed in the AST, dereference returns a reference
    436432                        ret->set_result( new ReferenceType( Type::Qualifiers(), ret->get_result() ) );
    437                 } else {
    438                         // references have been removed, in which case dereference returns an lvalue of the base type.
    439                         ret->result->set_lvalue( true );
    440433                }
    441434        }
     
    454447}
    455448
    456 
    457 void UntypedExpr::print( std::ostream &os, Indenter indent ) const {
    458         os << "Applying untyped: " << std::endl;
     449bool UntypedExpr::get_lvalue() const {
     450        // from src/GenPoly/Lvalue.cc: isIntrinsicReference
     451        static std::set<std::string> lvalueFunctions = { "*?", "?[?]" };
     452        std::string fname = InitTweak::getFunctionName( const_cast< UntypedExpr * >( this ) );
     453        return lvalueFunctions.count(fname);
     454}
     455
     456void UntypedExpr::print( std::ostream & os, Indenter indent ) const {
     457        os << "Applying untyped:" << std::endl;
    459458        os << indent+1;
    460459        function->print(os, indent+1);
    461         os << std::endl << indent << "...to: " << std::endl;
     460        os << std::endl << indent << "...to:" << std::endl;
    462461        printAll(args, os, indent+1);
    463462        Expression::print( os, indent );
     
    469468}
    470469
    471 NameExpr::NameExpr( const NameExpr &other ) : Expression( other ), name( other.name ) {
     470NameExpr::NameExpr( const NameExpr & other ) : Expression( other ), name( other.name ) {
    472471}
    473472
    474473NameExpr::~NameExpr() {}
    475474
    476 void NameExpr::print( std::ostream &os, Indenter indent ) const {
     475void NameExpr::print( std::ostream & os, Indenter indent ) const {
    477476        os << "Name: " << get_name();
    478477        Expression::print( os, indent );
    479478}
    480479
    481 LogicalExpr::LogicalExpr( Expression *arg1_, Expression *arg2_, bool andp ) :
     480LogicalExpr::LogicalExpr( Expression * arg1_, Expression * arg2_, bool andp ) :
    482481                Expression(), arg1(arg1_), arg2(arg2_), isAnd(andp) {
    483482        set_result( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );
    484483}
    485484
    486 LogicalExpr::LogicalExpr( const LogicalExpr &other ) :
     485LogicalExpr::LogicalExpr( const LogicalExpr & other ) :
    487486                Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), isAnd( other.isAnd ) {
    488487}
     
    493492}
    494493
    495 void LogicalExpr::print( std::ostream &os, Indenter indent )const {
     494void LogicalExpr::print( std::ostream & os, Indenter indent )const {
    496495        os << "Short-circuited operation (" << (isAnd ? "and" : "or") << ") on: ";
    497496        arg1->print(os);
     
    504503                Expression(), arg1(arg1), arg2(arg2), arg3(arg3) {}
    505504
    506 ConditionalExpr::ConditionalExpr( const ConditionalExpr &other ) :
     505ConditionalExpr::ConditionalExpr( const ConditionalExpr & other ) :
    507506                Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), arg3( maybeClone( other.arg3 ) ) {
    508507}
     
    514513}
    515514
    516 void ConditionalExpr::print( std::ostream &os, Indenter indent ) const {
     515bool ConditionalExpr::get_lvalue() const {
     516        return false;
     517}
     518
     519void ConditionalExpr::print( std::ostream & os, Indenter indent ) const {
    517520        os << "Conditional expression on: " << std::endl << indent+1;
    518521        arg1->print( os, indent+1 );
     
    527530
    528531
    529 void AsmExpr::print( std::ostream &os, Indenter indent ) const {
     532void AsmExpr::print( std::ostream & os, Indenter indent ) const {
    530533        os << "Asm Expression: " << std::endl;
    531534        if ( inout ) inout->print( os, indent+1 );
     
    538541        assert( callExpr );
    539542        assert( callExpr->result );
    540         set_result( callExpr->get_result()->clone() );
     543        set_result( callExpr->result->clone() );
    541544}
    542545
    543546ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other ) : Expression( other ), callExpr( maybeClone( other.callExpr ) ) {
    544         cloneAll( other.tempDecls, tempDecls );
    545         cloneAll( other.returnDecls, returnDecls );
    546         cloneAll( other.dtors, dtors );
    547547}
    548548
     
    550550        set_env( nullptr ); // ImplicitCopyCtorExpr does not take ownership of an environment
    551551        delete callExpr;
    552         deleteAll( tempDecls );
    553         deleteAll( returnDecls );
    554         deleteAll( dtors );
    555 }
    556 
    557 void ImplicitCopyCtorExpr::print( std::ostream &os, Indenter indent ) const {
     552}
     553
     554void ImplicitCopyCtorExpr::print( std::ostream & os, Indenter indent ) const {
    558555        os <<  "Implicit Copy Constructor Expression: " << std::endl << indent+1;
    559556        callExpr->print( os, indent+1 );
    560         os << std::endl << indent << "... with temporaries:" << std::endl;
    561         printAll( tempDecls, os, indent+1 );
    562         os << std::endl << indent << "... with return temporaries:" << std::endl;
    563         printAll( returnDecls, os, indent+1 );
    564         Expression::print( os, indent );
    565557}
    566558
     
    581573}
    582574
    583 void ConstructorExpr::print( std::ostream &os, Indenter indent ) const {
     575bool ConstructorExpr::get_lvalue() const {
     576        return false;
     577}
     578
     579void ConstructorExpr::print( std::ostream & os, Indenter indent ) const {
    584580        os <<  "Constructor Expression: " << std::endl << indent+1;
    585581        callExpr->print( os, indent + 2 );
     
    590586CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : initializer( initializer ) {
    591587        assert( type && initializer );
    592         type->set_lvalue( true );
    593588        set_result( type );
    594589}
    595590
    596 CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), initializer( other.initializer->clone() ) {}
     591CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr & other ) : Expression( other ), initializer( other.initializer->clone() ) {}
    597592
    598593CompoundLiteralExpr::~CompoundLiteralExpr() {
     
    600595}
    601596
    602 void CompoundLiteralExpr::print( std::ostream &os, Indenter indent ) const {
     597bool CompoundLiteralExpr::get_lvalue() const {
     598        return true;
     599}
     600
     601void CompoundLiteralExpr::print( std::ostream & os, Indenter indent ) const {
    603602        os << "Compound Literal Expression: " << std::endl << indent+1;
    604603        result->print( os, indent+1 );
     
    608607}
    609608
    610 RangeExpr::RangeExpr( Expression *low, Expression *high ) : low( low ), high( high ) {}
    611 RangeExpr::RangeExpr( const RangeExpr &other ) : Expression( other ), low( other.low->clone() ), high( other.high->clone() ) {}
    612 void RangeExpr::print( std::ostream &os, Indenter indent ) const {
     609RangeExpr::RangeExpr( Expression * low, Expression * high ) : low( low ), high( high ) {}
     610RangeExpr::RangeExpr( const RangeExpr & other ) : Expression( other ), low( other.low->clone() ), high( other.high->clone() ) {}
     611void RangeExpr::print( std::ostream & os, Indenter indent ) const {
    613612        os << "Range Expression: ";
    614613        low->print( os, indent );
     
    618617}
    619618
    620 StmtExpr::StmtExpr( CompoundStmt *statements ) : statements( statements ) {
     619StmtExpr::StmtExpr( CompoundStmt * statements ) : statements( statements ) {
    621620        computeResult();
    622621}
    623 StmtExpr::StmtExpr( const StmtExpr &other ) : Expression( other ), statements( other.statements->clone() ) {
     622StmtExpr::StmtExpr( const StmtExpr & other ) : Expression( other ), statements( other.statements->clone() ), resultExpr( other.resultExpr ) {
    624623        cloneAll( other.returnDecls, returnDecls );
    625624        cloneAll( other.dtors, dtors );
     
    650649        }
    651650}
    652 void StmtExpr::print( std::ostream &os, Indenter indent ) const {
     651bool StmtExpr::get_lvalue() const {
     652        return false;
     653}
     654void StmtExpr::print( std::ostream & os, Indenter indent ) const {
    653655        os << "Statement Expression: " << std::endl << indent+1;
    654656        statements->print( os, indent+1 );
     
    666668
    667669long long UniqueExpr::count = 0;
    668 UniqueExpr::UniqueExpr( Expression *expr, long long idVal ) : expr( expr ), object( nullptr ), var( nullptr ), id( idVal ) {
     670UniqueExpr::UniqueExpr( Expression * expr, long long idVal ) : expr( expr ), object( nullptr ), var( nullptr ), id( idVal ) {
    669671        assert( expr );
    670672        assert( count != -1 );
     
    674676        }
    675677}
    676 UniqueExpr::UniqueExpr( const UniqueExpr &other ) : Expression( other ), expr( maybeClone( other.expr ) ), object( maybeClone( other.object ) ), var( maybeClone( other.var ) ), id( other.id ) {
     678UniqueExpr::UniqueExpr( const UniqueExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), object( maybeClone( other.object ) ), var( maybeClone( other.var ) ), id( other.id ) {
    677679}
    678680UniqueExpr::~UniqueExpr() {
     
    681683        delete var;
    682684}
    683 void UniqueExpr::print( std::ostream &os, Indenter indent ) const {
     685void UniqueExpr::print( std::ostream & os, Indenter indent ) const {
    684686        os << "Unique Expression with id:" << id << std::endl << indent+1;
    685687        expr->print( os, indent+1 );
     
    732734}
    733735
    734 DeletedExpr::DeletedExpr( Expression * expr, BaseSyntaxNode * deleteStmt ) : expr( expr ), deleteStmt( deleteStmt ) {
     736DeletedExpr::DeletedExpr( Expression * expr, Declaration * deleteStmt ) : expr( expr ), deleteStmt( deleteStmt ) {
    735737        assert( expr->result );
    736738        result = expr->result->clone();
     
    746748        os << std::endl << indent+1 << "... deleted by: ";
    747749        deleteStmt->print( os, indent+1 );
     750}
     751
     752
     753DefaultArgExpr::DefaultArgExpr( Expression * expr ) : expr( expr ) {
     754        assert( expr->result );
     755        result = expr->result->clone();
     756}
     757DefaultArgExpr::DefaultArgExpr( const DefaultArgExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ) {}
     758DefaultArgExpr::~DefaultArgExpr() {
     759        delete expr;
     760}
     761
     762void DefaultArgExpr::print( std::ostream & os, Indenter indent ) const {
     763        os << "Default Argument Expression" << std::endl << indent+1;
     764        expr->print( os, indent+1 );
    748765}
    749766
Note: See TracChangeset for help on using the changeset viewer.