Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    r630a82a r4ffdd63  
    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 : Fri Apr  8 17:16:23 2016
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Wed Apr 27 17:07:19 2016
    1313// Update Count     : 40
    1414//
     
    7979
    8080VariableExpr::VariableExpr( DeclarationWithType *_var, Expression *_aname ) : Expression( _aname ), var( _var ) {
     81        assert( var );
     82        assert( var->get_type() );
    8183        add_result( var->get_type()->clone() );
    8284        for ( std::list< Type* >::iterator i = get_results().begin(); i != get_results().end(); ++i ) {
     
    9395
    9496void VariableExpr::print( std::ostream &os, int indent ) const {
    95         os << std::string( indent, ' ' ) << "Variable Expression: ";
     97        os << "Variable Expression: ";
    9698
    9799        Declaration *decl = get_var();
     
    122124
    123125void SizeofExpr::print( std::ostream &os, int indent) const {
    124         os << std::string( indent, ' ' ) << "Sizeof Expression on: ";
     126        os << "Sizeof Expression on: ";
    125127
    126128        if (isType)
     
    223225}
    224226
     227OffsetPackExpr::OffsetPackExpr( StructInstType *type_, Expression *aname_ ) : Expression( aname_ ), type( type_ ) {
     228        add_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) );
     229}
     230
     231OffsetPackExpr::OffsetPackExpr( const OffsetPackExpr &other ) : Expression( other ), type( maybeClone( other.type ) ) {}
     232
     233OffsetPackExpr::~OffsetPackExpr() { delete type; }
     234
     235void 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
    225248AttrExpr::AttrExpr( Expression *attr, Expression *expr_, Expression *_aname ) :
    226249                Expression( _aname ), attr( attr ), expr(expr_), type(0), isType(false) {
     
    274297
    275298void CastExpr::print( std::ostream &os, int indent ) const {
    276         os << std::string( indent, ' ' ) << "Cast of:" << std::endl;
     299        os << "Cast of:" << std::endl << std::string( indent+2, ' ' );
    277300        arg->print(os, indent+2);
    278301        os << std::endl << std::string( indent, ' ' ) << "to:" << std::endl;
     
    297320
    298321void UntypedMemberExpr::print( std::ostream &os, int indent ) const {
    299         os << std::string( indent, ' ' ) << "Member Expression, with field: " << get_member();
     322        os << "Untyped Member Expression, with field: " << get_member();
    300323
    301324        Expression *agg = get_aggregate();
    302325        os << std::string( indent, ' ' ) << "from aggregate: ";
    303         if (agg != 0) agg->print(os, indent + 2);
     326        if (agg != 0) {
     327                os << std::string( indent+2, ' ' );
     328                agg->print(os, indent + 2);
     329        }
     330        os << std::string( indent+2, ' ' );
    304331        Expression::print( os, indent );
    305332}
     
    324351
    325352void MemberExpr::print( std::ostream &os, int indent ) const {
    326         os << std::string( indent, ' ' ) << "Member Expression, with field: " << std::endl;
     353        os << "Member Expression, with field: " << std::endl;
    327354
    328355        assert( member );
     
    333360        Expression *agg = get_aggregate();
    334361        os << std::string( indent, ' ' ) << "from aggregate: " << std::endl;
    335         if (agg != 0) agg->print(os, indent + 2);
     362        if (agg != 0) {
     363                os << std::string( indent+2, ' ' );
     364                agg->print(os, indent + 2);
     365        }
     366        os << std::string( indent+2, ' ' );
    336367        Expression::print( os, indent );
    337368}
     
    351382
    352383void UntypedExpr::print( std::ostream &os, int indent ) const {
    353         os << std::string( indent, ' ' ) << "Applying untyped: " << std::endl;
     384        os << "Applying untyped: " << std::endl;
     385        os << std::string( indent, ' ' );
    354386        function->print(os, indent + 4);
    355387        os << std::string( indent, ' ' ) << "...to: " << std::endl;
     388        os << std::string( indent, ' ' );
    356389        printArgs(os, indent + 4);
    357390        Expression::print( os, indent );
     
    372405
    373406void NameExpr::print( std::ostream &os, int indent ) const {
    374         os << std::string( indent, ' ' ) << "Name: " << get_name() << std::endl;
     407        os << "Name: " << get_name() << std::endl;
    375408        Expression::print( os, indent );
    376409}
     
    433466}
    434467
     468
     469ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( ApplicationExpr * callExpr ) : callExpr( callExpr ) {
     470        assert( callExpr );
     471        cloneAll( callExpr->get_results(), results );
     472}
     473
     474ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other ) : Expression( other ), callExpr( maybeClone( other.callExpr ) ) {
     475        cloneAll( other.tempDecls, tempDecls );
     476        cloneAll( other.returnDecls, returnDecls );
     477        cloneAll( other.dtors, dtors );
     478}
     479
     480ImplicitCopyCtorExpr::~ImplicitCopyCtorExpr() {
     481        delete callExpr;
     482        deleteAll( tempDecls );
     483        deleteAll( returnDecls );
     484        deleteAll( dtors );
     485}
     486
     487void ImplicitCopyCtorExpr::print( std::ostream &os, int indent ) const {
     488        os << std::string( indent, ' ' ) <<  "Implicit Copy Constructor Expression: " << std::endl;
     489        assert( callExpr );
     490        callExpr->print( os, indent + 2 );
     491        os << std::endl << std::string( indent, ' ' ) << "with temporaries:" << std::endl;
     492        printAll(tempDecls, os, indent+2);
     493        os << std::endl << std::string( indent, ' ' ) << "with return temporaries:" << std::endl;
     494        printAll(returnDecls, os, indent+2);
     495        Expression::print( os, indent );
     496}
     497
    435498UntypedValofExpr::UntypedValofExpr( const UntypedValofExpr & other ) : Expression( other ), body ( maybeClone( other.body ) ) {}
    436499
Note: See TracChangeset for help on using the changeset viewer.