Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    rc8dfcd3 rb6fe7e6  
    2828#include "TypeSubstitution.h"
    2929#include "Common/utility.h"
     30#include "InitTweak/InitTweak.h"
    3031
    3132
     
    493494
    494495void ImplicitCopyCtorExpr::print( std::ostream &os, int indent ) const {
    495         os << std::string( indent, ' ' ) << "Implicit Copy Constructor Expression: " << std::endl;
     496        os << "Implicit Copy Constructor Expression: " << std::endl;
    496497        assert( callExpr );
    497498        callExpr->print( os, indent + 2 );
     
    503504}
    504505
     506
     507ConstructorExpr::ConstructorExpr( Expression * callExpr ) : callExpr( callExpr ) {
     508        // allow resolver to type a constructor used as an expression as if it has the same type as its first argument
     509        assert( callExpr );
     510        Expression * arg = InitTweak::getCallArg( callExpr, 0 );
     511        assert( arg );
     512        cloneAll( arg->get_results(), results );
     513}
     514
     515ConstructorExpr::ConstructorExpr( const ConstructorExpr & other ) : Expression( other ), callExpr( maybeClone( other.callExpr ) ) {
     516}
     517
     518ConstructorExpr::~ConstructorExpr() {
     519        delete callExpr;
     520}
     521
     522void ConstructorExpr::print( std::ostream &os, int indent ) const {
     523        os <<  "Constructor Expression: " << std::endl;
     524        assert( callExpr );
     525        os << std::string( indent+2, ' ' );
     526        callExpr->print( os, indent + 2 );
     527        Expression::print( os, indent );
     528}
     529
     530
     531CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : type( type ), initializer( initializer ) {
     532        add_result( type->clone() );
     533}
     534
     535CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), type( maybeClone( other.type ) ), initializer( maybeClone( other.initializer ) ) {}
     536
     537CompoundLiteralExpr::~CompoundLiteralExpr() {
     538        delete initializer;
     539        delete type;
     540}
     541
     542void CompoundLiteralExpr::print( std::ostream &os, int indent ) const {
     543        os << "Compound Literal Expression: " << std::endl;
     544        if ( type ) type->print( os, indent + 2 );
     545        if ( initializer ) initializer->print( os, indent + 2 );
     546}
     547
    505548UntypedValofExpr::UntypedValofExpr( const UntypedValofExpr & other ) : Expression( other ), body ( maybeClone( other.body ) ) {}
    506549
     
    511554        if ( get_body() != 0 )
    512555                get_body()->print( os, indent + 2 );
    513 }
    514 
    515 
    516 CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : type( type ), initializer( initializer ) {
    517         add_result( type->clone() );
    518 }
    519 
    520 CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), type( maybeClone( other.type ) ), initializer( maybeClone( other.initializer ) ) {}
    521 
    522 CompoundLiteralExpr::~CompoundLiteralExpr() {
    523         delete initializer;
    524         delete type;
    525 }
    526 
    527 void CompoundLiteralExpr::print( std::ostream &os, int indent ) const {
    528         os << "Compound Literal Expression: " << std::endl;
    529         if ( type ) type->print( os, indent + 2 );
    530         if ( initializer ) initializer->print( os, indent + 2 );
    531556}
    532557
Note: See TracChangeset for help on using the changeset viewer.