Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    rb4f8808 rd807ca28  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Thr Aug 15 13:43:00 2019
    13 // Update Count     : 64
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Tue Jul 25 14:15:47 2017
     13// Update Count     : 54
    1414//
    1515
     
    1919#include <iostream>                  // for ostream, operator<<, basic_ostream
    2020#include <list>                      // for list, _List_iterator, list<>::co...
    21 #include <set>                       // for set
    2221
    2322#include "Common/utility.h"          // for maybeClone, cloneAll, deleteAll
     
    3433#include "GenPoly/Lvalue.h"
    3534
    36 void printInferParams( const InferredParams & inferParams, std::ostream & os, Indenter indent, int level ) {
     35void printInferParams( const InferredParams & inferParams, std::ostream &os, Indenter indent, int level ) {
    3736        if ( ! inferParams.empty() ) {
    3837                os << indent << "with inferred parameters " << level << ":" << std::endl;
    3938                for ( InferredParams::const_iterator i = inferParams.begin(); i != inferParams.end(); ++i ) {
    4039                        os << indent+1;
    41                         assert(i->second.declptr);
    42                         i->second.declptr->printShort( os, indent+1 );
     40                        Declaration::declFromId( i->second.decl )->printShort( os, indent+1 );
    4341                        os << std::endl;
    44                         printInferParams( i->second.expr->inferParams, os, indent+1, level+1 );
     42                        printInferParams( *i->second.inferParams, os, indent+1, level+1 );
    4543                } // for
    4644        } // if
     
    4947Expression::Expression() : result( 0 ), env( 0 ) {}
    5048
    51 Expression::Expression( const Expression & other ) : BaseSyntaxNode( other ), result( maybeClone( other.result ) ), env( maybeClone( other.env ) ), extension( other.extension ), inferParams( other.inferParams ), resnSlots( other.resnSlots ) {}
     49Expression::Expression( const Expression &other ) : BaseSyntaxNode( other ), result( maybeClone( other.result ) ), env( maybeClone( other.env ) ), extension( other.extension ), inferParams( other.inferParams ) {
     50}
    5251
    5352void Expression::spliceInferParams( Expression * other ) {
     
    5655                inferParams[p.first] = std::move( p.second );
    5756        }
    58         resnSlots.insert( resnSlots.end(), other->resnSlots.begin(), other->resnSlots.end() );
    5957}
    6058
     
    6462}
    6563
    66 bool Expression::get_lvalue() const {
    67         return false;
    68 }
    69 
    70 void Expression::print( std::ostream & os, Indenter indent ) const {
     64void Expression::print( std::ostream &os, Indenter indent ) const {
    7165        printInferParams( inferParams, os, indent+1, 0 );
    7266
     
    8579}
    8680
    87 ConstantExpr::ConstantExpr( const ConstantExpr & other) : Expression( other ), constant( other.constant ) {
     81ConstantExpr::ConstantExpr( const ConstantExpr &other) : Expression( other ), constant( other.constant ) {
    8882}
    8983
    9084ConstantExpr::~ConstantExpr() {}
    9185
    92 void ConstantExpr::print( std::ostream & os, Indenter indent ) const {
     86void ConstantExpr::print( std::ostream &os, Indenter indent ) const {
    9387        os << "constant expression " ;
    9488        constant.print( os );
     
    109103}
    110104
    111 VariableExpr::VariableExpr() : Expression(), var( nullptr ) {}
    112 
    113105VariableExpr::VariableExpr( DeclarationWithType *_var ) : Expression(), var( _var ) {
    114106        assert( var );
    115107        assert( var->get_type() );
    116108        Type * type = var->get_type()->clone();
     109        type->set_lvalue( true );
    117110
    118111        // xxx - doesn't quite work yet - get different alternatives with the same cost
     
    124117        //      long long int value;
    125118        //      if ( decl->valueOf( var, value ) ) {
    126         //              type->set_lvalue( false ); // Would have to move to get_lvalue.
     119        //              type->set_lvalue( false );
    127120        //      }
    128121        // }
     
    131124}
    132125
    133 VariableExpr::VariableExpr( const VariableExpr & other ) : Expression( other ), var( other.var ) {
     126VariableExpr::VariableExpr( const VariableExpr &other ) : Expression( other ), var( other.var ) {
    134127}
    135128
    136129VariableExpr::~VariableExpr() {
    137130        // don't delete the declaration, since it points somewhere else in the tree
    138 }
    139 
    140 bool VariableExpr::get_lvalue() const {
    141         // It isn't always an lvalue, but it is never an rvalue.
    142         return true;
    143131}
    144132
     
    149137}
    150138
    151 void VariableExpr::print( std::ostream & os, Indenter indent ) const {
     139void VariableExpr::print( std::ostream &os, Indenter indent ) const {
    152140        os << "Variable Expression: ";
    153141        var->printShort(os, indent);
     
    155143}
    156144
    157 SizeofExpr::SizeofExpr( Expression * expr_ ) :
     145SizeofExpr::SizeofExpr( Expression *expr_ ) :
    158146                Expression(), expr(expr_), type(0), isType(false) {
    159147        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    160148}
    161149
    162 SizeofExpr::SizeofExpr( Type * type_ ) :
     150SizeofExpr::SizeofExpr( Type *type_ ) :
    163151                Expression(), expr(0), type(type_), isType(true) {
    164152        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    165153}
    166154
    167 SizeofExpr::SizeofExpr( const SizeofExpr & other ) :
     155SizeofExpr::SizeofExpr( const SizeofExpr &other ) :
    168156        Expression( other ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) {
    169157}
     
    174162}
    175163
    176 void SizeofExpr::print( std::ostream & os, Indenter indent) const {
     164void SizeofExpr::print( std::ostream &os, Indenter indent) const {
    177165        os << "Sizeof Expression on: ";
    178166        if (isType) type->print(os, indent+1);
     
    181169}
    182170
    183 AlignofExpr::AlignofExpr( Expression * expr_ ) :
     171AlignofExpr::AlignofExpr( Expression *expr_ ) :
    184172                Expression(), expr(expr_), type(0), isType(false) {
    185173        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    186174}
    187175
    188 AlignofExpr::AlignofExpr( Type * type_ ) :
     176AlignofExpr::AlignofExpr( Type *type_ ) :
    189177                Expression(), expr(0), type(type_), isType(true) {
    190178        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    191179}
    192180
    193 AlignofExpr::AlignofExpr( const AlignofExpr & other ) :
     181AlignofExpr::AlignofExpr( const AlignofExpr &other ) :
    194182        Expression( other ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) {
    195183}
     
    200188}
    201189
    202 void AlignofExpr::print( std::ostream & os, Indenter indent) const {
     190void AlignofExpr::print( std::ostream &os, Indenter indent) const {
    203191        os << "Alignof Expression on: ";
    204192        if (isType) type->print(os, indent+1);
     
    207195}
    208196
    209 UntypedOffsetofExpr::UntypedOffsetofExpr( Type * type, const std::string & member ) :
     197UntypedOffsetofExpr::UntypedOffsetofExpr( Type *type, const std::string &member ) :
    210198                Expression(), type(type), member(member) {
    211199        assert( type );
     
    213201}
    214202
    215 UntypedOffsetofExpr::UntypedOffsetofExpr( const UntypedOffsetofExpr & other ) :
     203UntypedOffsetofExpr::UntypedOffsetofExpr( const UntypedOffsetofExpr &other ) :
    216204        Expression( other ), type( maybeClone( other.type ) ), member( other.member ) {}
    217205
     
    220208}
    221209
    222 void UntypedOffsetofExpr::print( std::ostream & os, Indenter indent) const {
     210void UntypedOffsetofExpr::print( std::ostream &os, Indenter indent) const {
    223211        os << "Untyped Offsetof Expression on member " << member << " of ";
    224212        type->print(os, indent+1);
     
    226214}
    227215
    228 OffsetofExpr::OffsetofExpr( Type * type, DeclarationWithType * member ) :
     216OffsetofExpr::OffsetofExpr( Type *type, DeclarationWithType *member ) :
    229217                Expression(), type(type), member(member) {
    230218        assert( member );
     
    233221}
    234222
    235 OffsetofExpr::OffsetofExpr( const OffsetofExpr & other ) :
     223OffsetofExpr::OffsetofExpr( const OffsetofExpr &other ) :
    236224        Expression( other ), type( maybeClone( other.type ) ), member( other.member ) {}
    237225
     
    240228}
    241229
    242 void OffsetofExpr::print( std::ostream & os, Indenter indent) const {
     230void OffsetofExpr::print( std::ostream &os, Indenter indent) const {
    243231        os << "Offsetof Expression on member " << member->name << " of ";
    244232        type->print(os, indent+1);
     
    246234}
    247235
    248 OffsetPackExpr::OffsetPackExpr( StructInstType * type ) : Expression(), type( type ) {
     236OffsetPackExpr::OffsetPackExpr( StructInstType *type ) : Expression(), type( type ) {
    249237        assert( type );
    250238        set_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) );
    251239}
    252240
    253 OffsetPackExpr::OffsetPackExpr( const OffsetPackExpr & other ) : Expression( other ), type( maybeClone( other.type ) ) {}
     241OffsetPackExpr::OffsetPackExpr( const OffsetPackExpr &other ) : Expression( other ), type( maybeClone( other.type ) ) {}
    254242
    255243OffsetPackExpr::~OffsetPackExpr() { delete type; }
    256244
    257 void OffsetPackExpr::print( std::ostream & os, Indenter indent ) const {
     245void OffsetPackExpr::print( std::ostream &os, Indenter indent ) const {
    258246        os << "Offset pack expression on ";
    259247        type->print(os, indent+1);
     
    261249}
    262250
    263 CastExpr::CastExpr( Expression * arg, Type * toType, bool isGenerated ) : arg(arg), isGenerated( isGenerated ) {
     251AttrExpr::AttrExpr( Expression *attr, Expression *expr_ ) :
     252                Expression(), attr( attr ), expr(expr_), type(0), isType(false) {
     253}
     254
     255AttrExpr::AttrExpr( Expression *attr, Type *type_ ) :
     256                Expression(), attr( attr ), expr(0), type(type_), isType(true) {
     257}
     258
     259AttrExpr::AttrExpr( const AttrExpr &other ) :
     260                Expression( other ), attr( maybeClone( other.attr ) ), expr( maybeClone( other.expr ) ), type( maybeClone( other.type ) ), isType( other.isType ) {
     261}
     262
     263AttrExpr::~AttrExpr() {
     264        delete attr;
     265        delete expr;
     266        delete type;
     267}
     268
     269void 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
     280CastExpr::CastExpr( Expression *arg, Type *toType, bool isGenerated ) : Expression(), arg(arg), isGenerated( isGenerated ) {
    264281        set_result(toType);
    265282}
    266283
    267 CastExpr::CastExpr( Expression * arg, bool isGenerated ) : arg(arg), isGenerated( isGenerated ) {
     284CastExpr::CastExpr( Expression *arg, bool isGenerated ) : Expression(), arg(arg), isGenerated( isGenerated ) {
    268285        set_result( new VoidType( Type::Qualifiers() ) );
    269286}
    270287
    271 CastExpr::CastExpr( const CastExpr & other ) : Expression( other ), arg( maybeClone( other.arg ) ), isGenerated( other.isGenerated ) {
     288CastExpr::CastExpr( const CastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ), isGenerated( other.isGenerated ) {
    272289}
    273290
     
    276293}
    277294
    278 bool 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 
    283 void CastExpr::print( std::ostream & os, Indenter indent ) const {
    284         os << (isGenerated ? "Generated " : "Explicit ") << "Cast of:" << std::endl << indent+1;
     295void CastExpr::print( std::ostream &os, Indenter indent ) const {
     296        os << "Cast of:" << std::endl << indent+1;
    285297        arg->print(os, indent+1);
    286298        os << std::endl << indent << "... to:";
     
    294306}
    295307
    296 KeywordCastExpr::KeywordCastExpr( Expression * arg, Target target ) : Expression(), arg(arg), target( target ) {
    297 }
    298 
    299 KeywordCastExpr::KeywordCastExpr( const KeywordCastExpr & other ) : Expression( other ), arg( maybeClone( other.arg ) ), target( other.target ) {
     308KeywordCastExpr::KeywordCastExpr( Expression *arg, Target target ) : Expression(), arg(arg), target( target ) {
     309}
     310
     311KeywordCastExpr::KeywordCastExpr( const KeywordCastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ), target( other.target ) {
    300312}
    301313
     
    315327}
    316328
    317 void KeywordCastExpr::print( std::ostream & os, Indenter indent ) const {
     329void KeywordCastExpr::print( std::ostream &os, Indenter indent ) const {
    318330        os << "Keyword Cast of:" << std::endl << indent+1;
    319331        arg->print(os, indent+1);
     
    323335}
    324336
    325 VirtualCastExpr::VirtualCastExpr( Expression * arg_, Type * toType ) : Expression(), arg(arg_) {
     337VirtualCastExpr::VirtualCastExpr( Expression *arg_, Type *toType ) : Expression(), arg(arg_) {
    326338        set_result(toType);
    327339}
    328340
    329 VirtualCastExpr::VirtualCastExpr( const VirtualCastExpr & other ) : Expression( other ), arg( maybeClone( other.arg ) ) {
     341VirtualCastExpr::VirtualCastExpr( const VirtualCastExpr &other ) : Expression( other ), arg( maybeClone( other.arg ) ) {
    330342}
    331343
     
    334346}
    335347
    336 void VirtualCastExpr::print( std::ostream & os, Indenter indent ) const {
     348void VirtualCastExpr::print( std::ostream &os, Indenter indent ) const {
    337349        os << "Virtual Cast of:" << std::endl << indent+1;
    338350        arg->print(os, indent+1);
     
    347359}
    348360
    349 UntypedMemberExpr::UntypedMemberExpr( Expression * member, Expression * aggregate ) :
     361UntypedMemberExpr::UntypedMemberExpr( Expression * member, Expression *aggregate ) :
    350362                Expression(), member(member), aggregate(aggregate) {
    351363        assert( aggregate );
    352364}
    353365
    354 UntypedMemberExpr::UntypedMemberExpr( const UntypedMemberExpr & other ) :
     366UntypedMemberExpr::UntypedMemberExpr( const UntypedMemberExpr &other ) :
    355367                Expression( other ), member( maybeClone( other.member ) ), aggregate( maybeClone( other.aggregate ) ) {
    356368}
     
    361373}
    362374
    363 bool UntypedMemberExpr::get_lvalue() const {
    364         return aggregate->get_lvalue();
    365 }
    366 
    367 void UntypedMemberExpr::print( std::ostream & os, Indenter indent ) const {
     375void UntypedMemberExpr::print( std::ostream &os, Indenter indent ) const {
    368376        os << "Untyped Member Expression, with field: " << std::endl << indent+1;
    369377        member->print(os, indent+1 );
    370         os << indent << "... from aggregate:" << std::endl << indent+1;
     378        os << indent << "... from aggregate: " << std::endl << indent+1;
    371379        aggregate->print(os, indent+1);
    372380        Expression::print( os, indent );
    373381}
    374382
    375 MemberExpr::MemberExpr( DeclarationWithType * member, Expression * aggregate ) :
     383MemberExpr::MemberExpr( DeclarationWithType *member, Expression *aggregate ) :
    376384                Expression(), member(member), aggregate(aggregate) {
    377385        assert( member );
     
    383391        sub.apply( res );
    384392        result = res;
     393        result->set_lvalue( true );
    385394        result->get_qualifiers() |= aggregate->result->get_qualifiers();
    386395}
    387396
    388 MemberExpr::MemberExpr( const MemberExpr & other ) :
     397MemberExpr::MemberExpr( const MemberExpr &other ) :
    389398                Expression( other ), member( other.member ), aggregate( maybeClone( other.aggregate ) ) {
    390399}
     
    395404}
    396405
    397 bool MemberExpr::get_lvalue() const {
    398         // This is actually wrong by C, but it works with our current set-up.
    399         return true;
    400 }
    401 
    402 void MemberExpr::print( std::ostream & os, Indenter indent ) const {
    403         os << "Member Expression, with field:" << std::endl;
     406void MemberExpr::print( std::ostream &os, Indenter indent ) const {
     407        os << "Member Expression, with field: " << std::endl;
    404408        os << indent+1;
    405409        member->print( os, indent+1 );
    406         os << std::endl << indent << "... from aggregate:" << std::endl << indent+1;
     410        os << std::endl << indent << "... from aggregate: " << std::endl << indent+1;
    407411        aggregate->print(os, indent + 1);
    408412        Expression::print( os, indent );
    409413}
    410414
    411 UntypedExpr::UntypedExpr( Expression * function, const std::list<Expression *> & args ) :
     415UntypedExpr::UntypedExpr( Expression *function, const std::list<Expression *> &args ) :
    412416                Expression(), function(function), args(args) {}
    413417
    414 UntypedExpr::UntypedExpr( const UntypedExpr & other ) :
     418UntypedExpr::UntypedExpr( const UntypedExpr &other ) :
    415419                Expression( other ), function( maybeClone( other.function ) ) {
    416420        cloneAll( other.args, args );
     
    431435                        // if references are still allowed in the AST, dereference returns a reference
    432436                        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 );
    433440                }
    434441        }
     
    447454}
    448455
    449 bool 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 
    456 void UntypedExpr::print( std::ostream & os, Indenter indent ) const {
    457         os << "Applying untyped:" << std::endl;
     456
     457void UntypedExpr::print( std::ostream &os, Indenter indent ) const {
     458        os << "Applying untyped: " << std::endl;
    458459        os << indent+1;
    459460        function->print(os, indent+1);
    460         os << std::endl << indent << "...to:" << std::endl;
     461        os << std::endl << indent << "...to: " << std::endl;
    461462        printAll(args, os, indent+1);
    462463        Expression::print( os, indent );
     
    468469}
    469470
    470 NameExpr::NameExpr( const NameExpr & other ) : Expression( other ), name( other.name ) {
     471NameExpr::NameExpr( const NameExpr &other ) : Expression( other ), name( other.name ) {
    471472}
    472473
    473474NameExpr::~NameExpr() {}
    474475
    475 void NameExpr::print( std::ostream & os, Indenter indent ) const {
     476void NameExpr::print( std::ostream &os, Indenter indent ) const {
    476477        os << "Name: " << get_name();
    477478        Expression::print( os, indent );
    478479}
    479480
    480 LogicalExpr::LogicalExpr( Expression * arg1_, Expression * arg2_, bool andp ) :
     481LogicalExpr::LogicalExpr( Expression *arg1_, Expression *arg2_, bool andp ) :
    481482                Expression(), arg1(arg1_), arg2(arg2_), isAnd(andp) {
    482483        set_result( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );
    483484}
    484485
    485 LogicalExpr::LogicalExpr( const LogicalExpr & other ) :
     486LogicalExpr::LogicalExpr( const LogicalExpr &other ) :
    486487                Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), isAnd( other.isAnd ) {
    487488}
     
    492493}
    493494
    494 void LogicalExpr::print( std::ostream & os, Indenter indent )const {
     495void LogicalExpr::print( std::ostream &os, Indenter indent )const {
    495496        os << "Short-circuited operation (" << (isAnd ? "and" : "or") << ") on: ";
    496497        arg1->print(os);
     
    503504                Expression(), arg1(arg1), arg2(arg2), arg3(arg3) {}
    504505
    505 ConditionalExpr::ConditionalExpr( const ConditionalExpr & other ) :
     506ConditionalExpr::ConditionalExpr( const ConditionalExpr &other ) :
    506507                Expression( other ), arg1( maybeClone( other.arg1 ) ), arg2( maybeClone( other.arg2 ) ), arg3( maybeClone( other.arg3 ) ) {
    507508}
     
    513514}
    514515
    515 bool ConditionalExpr::get_lvalue() const {
    516         return false;
    517 }
    518 
    519 void ConditionalExpr::print( std::ostream & os, Indenter indent ) const {
     516void ConditionalExpr::print( std::ostream &os, Indenter indent ) const {
    520517        os << "Conditional expression on: " << std::endl << indent+1;
    521518        arg1->print( os, indent+1 );
     
    530527
    531528
    532 void AsmExpr::print( std::ostream & os, Indenter indent ) const {
     529void AsmExpr::print( std::ostream &os, Indenter indent ) const {
    533530        os << "Asm Expression: " << std::endl;
    534531        if ( inout ) inout->print( os, indent+1 );
     
    541538        assert( callExpr );
    542539        assert( callExpr->result );
    543         set_result( callExpr->result->clone() );
     540        set_result( callExpr->get_result()->clone() );
    544541}
    545542
    546543ImplicitCopyCtorExpr::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 }
    553 
    554 void ImplicitCopyCtorExpr::print( std::ostream & os, Indenter indent ) const {
     552        deleteAll( tempDecls );
     553        deleteAll( returnDecls );
     554        deleteAll( dtors );
     555}
     556
     557void ImplicitCopyCtorExpr::print( std::ostream &os, Indenter indent ) const {
    555558        os <<  "Implicit Copy Constructor Expression: " << std::endl << indent+1;
    556559        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 );
    557565}
    558566
     
    573581}
    574582
    575 bool ConstructorExpr::get_lvalue() const {
    576         return false;
    577 }
    578 
    579 void ConstructorExpr::print( std::ostream & os, Indenter indent ) const {
     583void ConstructorExpr::print( std::ostream &os, Indenter indent ) const {
    580584        os <<  "Constructor Expression: " << std::endl << indent+1;
    581585        callExpr->print( os, indent + 2 );
     
    586590CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : initializer( initializer ) {
    587591        assert( type && initializer );
     592        type->set_lvalue( true );
    588593        set_result( type );
    589594}
    590595
    591 CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr & other ) : Expression( other ), initializer( other.initializer->clone() ) {}
     596CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), initializer( other.initializer->clone() ) {}
    592597
    593598CompoundLiteralExpr::~CompoundLiteralExpr() {
     
    595600}
    596601
    597 bool CompoundLiteralExpr::get_lvalue() const {
    598         return true;
    599 }
    600 
    601 void CompoundLiteralExpr::print( std::ostream & os, Indenter indent ) const {
     602void CompoundLiteralExpr::print( std::ostream &os, Indenter indent ) const {
    602603        os << "Compound Literal Expression: " << std::endl << indent+1;
    603604        result->print( os, indent+1 );
     
    607608}
    608609
    609 RangeExpr::RangeExpr( Expression * low, Expression * high ) : low( low ), high( high ) {}
    610 RangeExpr::RangeExpr( const RangeExpr & other ) : Expression( other ), low( other.low->clone() ), high( other.high->clone() ) {}
    611 void RangeExpr::print( std::ostream & os, Indenter indent ) const {
     610RangeExpr::RangeExpr( Expression *low, Expression *high ) : low( low ), high( high ) {}
     611RangeExpr::RangeExpr( const RangeExpr &other ) : Expression( other ), low( other.low->clone() ), high( other.high->clone() ) {}
     612void RangeExpr::print( std::ostream &os, Indenter indent ) const {
    612613        os << "Range Expression: ";
    613614        low->print( os, indent );
     
    617618}
    618619
    619 StmtExpr::StmtExpr( CompoundStmt * statements ) : statements( statements ) {
     620StmtExpr::StmtExpr( CompoundStmt *statements ) : statements( statements ) {
    620621        computeResult();
    621622}
    622 StmtExpr::StmtExpr( const StmtExpr & other ) : Expression( other ), statements( other.statements->clone() ), resultExpr( other.resultExpr ) {
     623StmtExpr::StmtExpr( const StmtExpr &other ) : Expression( other ), statements( other.statements->clone() ) {
    623624        cloneAll( other.returnDecls, returnDecls );
    624625        cloneAll( other.dtors, dtors );
     
    649650        }
    650651}
    651 bool StmtExpr::get_lvalue() const {
    652         return false;
    653 }
    654 void StmtExpr::print( std::ostream & os, Indenter indent ) const {
     652void StmtExpr::print( std::ostream &os, Indenter indent ) const {
    655653        os << "Statement Expression: " << std::endl << indent+1;
    656654        statements->print( os, indent+1 );
     
    668666
    669667long long UniqueExpr::count = 0;
    670 UniqueExpr::UniqueExpr( Expression * expr, long long idVal ) : expr( expr ), object( nullptr ), var( nullptr ), id( idVal ) {
     668UniqueExpr::UniqueExpr( Expression *expr, long long idVal ) : expr( expr ), object( nullptr ), var( nullptr ), id( idVal ) {
    671669        assert( expr );
    672670        assert( count != -1 );
     
    676674        }
    677675}
    678 UniqueExpr::UniqueExpr( const UniqueExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), object( maybeClone( other.object ) ), var( maybeClone( other.var ) ), id( other.id ) {
     676UniqueExpr::UniqueExpr( const UniqueExpr &other ) : Expression( other ), expr( maybeClone( other.expr ) ), object( maybeClone( other.object ) ), var( maybeClone( other.var ) ), id( other.id ) {
    679677}
    680678UniqueExpr::~UniqueExpr() {
     
    683681        delete var;
    684682}
    685 void UniqueExpr::print( std::ostream & os, Indenter indent ) const {
     683void UniqueExpr::print( std::ostream &os, Indenter indent ) const {
    686684        os << "Unique Expression with id:" << id << std::endl << indent+1;
    687685        expr->print( os, indent+1 );
     
    734732}
    735733
    736 DeletedExpr::DeletedExpr( Expression * expr, Declaration * deleteStmt ) : expr( expr ), deleteStmt( deleteStmt ) {
     734DeletedExpr::DeletedExpr( Expression * expr, BaseSyntaxNode * deleteStmt ) : expr( expr ), deleteStmt( deleteStmt ) {
    737735        assert( expr->result );
    738736        result = expr->result->clone();
     
    748746        os << std::endl << indent+1 << "... deleted by: ";
    749747        deleteStmt->print( os, indent+1 );
    750 }
    751 
    752 
    753 DefaultArgExpr::DefaultArgExpr( Expression * expr ) : expr( expr ) {
    754         assert( expr->result );
    755         result = expr->result->clone();
    756 }
    757 DefaultArgExpr::DefaultArgExpr( const DefaultArgExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ) {}
    758 DefaultArgExpr::~DefaultArgExpr() {
    759         delete expr;
    760 }
    761 
    762 void DefaultArgExpr::print( std::ostream & os, Indenter indent ) const {
    763         os << "Default Argument Expression" << std::endl << indent+1;
    764         expr->print( os, indent+1 );
    765748}
    766749
Note: See TracChangeset for help on using the changeset viewer.