Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    r630a82a re04ef3a  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Apr  8 17:16:23 2016
    13 // Update Count     : 40
     12// Last Modified On : Mon Jun 13 16:03:39 2016
     13// Update Count     : 42
    1414//
    1515
     
    3232Expression::Expression( Expression *_aname ) : env( 0 ), argName( _aname ) {}
    3333
    34 Expression::Expression( const Expression &other ) : env( maybeClone( other.env ) ), argName( maybeClone( other.get_argName() ) ) {
     34Expression::Expression( const Expression &other ) : env( maybeClone( other.env ) ), argName( maybeClone( other.get_argName() ) ), extension( other.extension ) {
    3535        cloneAll( other.results, results );
    3636}
     
    6060                argName->print( os, indent+2 );
    6161        } // if
     62
     63        if ( extension ) {
     64                os << std::string( indent, ' ' ) << "with extension:";
     65        } // if
    6266}
    6367
     
    7276
    7377void ConstantExpr::print( std::ostream &os, int indent ) const {
    74         os << std::string( indent, ' ' ) << "constant expression " ;
     78        os << "constant expression " ;
    7579        constant.print( os );
    7680        Expression::print( os, indent );
    77         os << std::endl;
    7881}
    7982
    8083VariableExpr::VariableExpr( DeclarationWithType *_var, Expression *_aname ) : Expression( _aname ), var( _var ) {
     84        assert( var );
     85        assert( var->get_type() );
    8186        add_result( var->get_type()->clone() );
    8287        for ( std::list< Type* >::iterator i = get_results().begin(); i != get_results().end(); ++i ) {
     
    9398
    9499void VariableExpr::print( std::ostream &os, int indent ) const {
    95         os << std::string( indent, ' ' ) << "Variable Expression: ";
     100        os << "Variable Expression: ";
    96101
    97102        Declaration *decl = get_var();
     
    122127
    123128void SizeofExpr::print( std::ostream &os, int indent) const {
    124         os << std::string( indent, ' ' ) << "Sizeof Expression on: ";
     129        os << "Sizeof Expression on: ";
    125130
    126131        if (isType)
     
    212217
    213218        os << " of ";
     219
     220        if ( type ) {
     221                type->print(os, indent + 2);
     222        } else {
     223                os << "<NULL>";
     224        }
     225
     226        os << std::endl;
     227        Expression::print( os, indent );
     228}
     229
     230OffsetPackExpr::OffsetPackExpr( StructInstType *type_, Expression *aname_ ) : Expression( aname_ ), type( type_ ) {
     231        add_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) );
     232}
     233
     234OffsetPackExpr::OffsetPackExpr( const OffsetPackExpr &other ) : Expression( other ), type( maybeClone( other.type ) ) {}
     235
     236OffsetPackExpr::~OffsetPackExpr() { delete type; }
     237
     238void OffsetPackExpr::print( std::ostream &os, int indent ) const {
     239        os << std::string( indent, ' ' ) << "Offset pack expression on ";
    214240
    215241        if ( type ) {
     
    274300
    275301void CastExpr::print( std::ostream &os, int indent ) const {
    276         os << std::string( indent, ' ' ) << "Cast of:" << std::endl;
     302        os << "Cast of:" << std::endl << std::string( indent+2, ' ' );
    277303        arg->print(os, indent+2);
    278304        os << std::endl << std::string( indent, ' ' ) << "to:" << std::endl;
     
    297323
    298324void UntypedMemberExpr::print( std::ostream &os, int indent ) const {
    299         os << std::string( indent, ' ' ) << "Member Expression, with field: " << get_member();
     325        os << "Untyped Member Expression, with field: " << get_member();
    300326
    301327        Expression *agg = get_aggregate();
    302         os << std::string( indent, ' ' ) << "from aggregate: ";
    303         if (agg != 0) agg->print(os, indent + 2);
     328        os << ", from aggregate: ";
     329        if (agg != 0) {
     330                os << std::string( indent + 2, ' ' );
     331                agg->print(os, indent + 2);
     332        }
     333        os << std::string( indent+2, ' ' );
    304334        Expression::print( os, indent );
    305335}
     
    324354
    325355void MemberExpr::print( std::ostream &os, int indent ) const {
    326         os << std::string( indent, ' ' ) << "Member Expression, with field: " << std::endl;
     356        os << "Member Expression, with field: " << std::endl;
    327357
    328358        assert( member );
     
    333363        Expression *agg = get_aggregate();
    334364        os << std::string( indent, ' ' ) << "from aggregate: " << std::endl;
    335         if (agg != 0) agg->print(os, indent + 2);
     365        if (agg != 0) {
     366                os << std::string( indent + 2, ' ' );
     367                agg->print(os, indent + 2);
     368        }
     369        os << std::string( indent+2, ' ' );
    336370        Expression::print( os, indent );
    337371}
     
    351385
    352386void UntypedExpr::print( std::ostream &os, int indent ) const {
    353         os << std::string( indent, ' ' ) << "Applying untyped: " << std::endl;
    354         function->print(os, indent + 4);
     387        os << "Applying untyped: " << std::endl;
     388        os << std::string( indent+2, ' ' );
     389        function->print(os, indent + 2);
    355390        os << std::string( indent, ' ' ) << "...to: " << std::endl;
    356         printArgs(os, indent + 4);
     391        printAll(args, os, indent + 2);
    357392        Expression::print( os, indent );
    358393}
     
    360395void UntypedExpr::printArgs( std::ostream &os, int indent ) const {
    361396        std::list<Expression *>::const_iterator i;
    362         for (i = args.begin(); i != args.end(); i++)
     397        for (i = args.begin(); i != args.end(); i++) {
     398                os << std::string(indent, ' ' );
    363399                (*i)->print(os, indent);
     400        }
    364401}
    365402
     
    372409
    373410void NameExpr::print( std::ostream &os, int indent ) const {
    374         os << std::string( indent, ' ' ) << "Name: " << get_name() << std::endl;
     411        os << "Name: " << get_name() << std::endl;
    375412        Expression::print( os, indent );
    376413}
     
    433470}
    434471
     472
     473ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( ApplicationExpr * callExpr ) : callExpr( callExpr ) {
     474        assert( callExpr );
     475        cloneAll( callExpr->get_results(), results );
     476}
     477
     478ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other ) : Expression( other ), callExpr( maybeClone( other.callExpr ) ) {
     479        cloneAll( other.tempDecls, tempDecls );
     480        cloneAll( other.returnDecls, returnDecls );
     481        cloneAll( other.dtors, dtors );
     482}
     483
     484ImplicitCopyCtorExpr::~ImplicitCopyCtorExpr() {
     485        delete callExpr;
     486        deleteAll( tempDecls );
     487        deleteAll( returnDecls );
     488        deleteAll( dtors );
     489}
     490
     491void ImplicitCopyCtorExpr::print( std::ostream &os, int indent ) const {
     492        os << std::string( indent, ' ' ) <<  "Implicit Copy Constructor Expression: " << std::endl;
     493        assert( callExpr );
     494        callExpr->print( os, indent + 2 );
     495        os << std::endl << std::string( indent, ' ' ) << "with temporaries:" << std::endl;
     496        printAll(tempDecls, os, indent+2);
     497        os << std::endl << std::string( indent, ' ' ) << "with return temporaries:" << std::endl;
     498        printAll(returnDecls, os, indent+2);
     499        Expression::print( os, indent );
     500}
     501
    435502UntypedValofExpr::UntypedValofExpr( const UntypedValofExpr & other ) : Expression( other ), body ( maybeClone( other.body ) ) {}
    436503
Note: See TracChangeset for help on using the changeset viewer.