Ignore:
Timestamp:
Jul 4, 2017, 9:40:16 AM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
208e5be
Parents:
9c951e3 (diff), f7cb0bc (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into references

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    r9c951e3 rb1e63ac5  
    2121#include <iterator>
    2222
     23#include "Declaration.h"
     24#include "Expression.h"
     25#include "Initializer.h"
     26#include "Statement.h"
    2327#include "Type.h"
    24 #include "Initializer.h"
    25 #include "Expression.h"
    26 #include "Declaration.h"
    27 #include "Statement.h"
    2828#include "TypeSubstitution.h"
     29#include "VarExprReplacer.h"
     30
    2931#include "Common/utility.h"
     32#include "Common/PassVisitor.h"
     33
    3034#include "InitTweak/InitTweak.h"
    3135
     
    9296
    9397        Declaration *decl = get_var();
    94         // if ( decl != 0) decl->print(os, indent + 2);
    9598        if ( decl != 0) decl->printShort(os, indent + 2);
    9699        os << std::endl;
     
    287290        delete arg;
    288291}
    289 
    290 // CastExpr *CastExpr::clone() const { return 0; }
    291292
    292293void CastExpr::print( std::ostream &os, int indent ) const {
     
    355356}
    356357
    357 //// is this right? It's cloning the member, but the member is a declaration so probably shouldn't be cloned...
    358358MemberExpr::MemberExpr( const MemberExpr &other ) :
    359359                Expression( other ), member( other.member ), aggregate( maybeClone( other.aggregate ) ) {
     
    361361
    362362MemberExpr::~MemberExpr() {
    363         // delete member;
     363        // don't delete the member declaration, since it points somewhere else in the tree
    364364        delete aggregate;
    365365}
     
    591591}
    592592
    593 UntypedValofExpr::UntypedValofExpr( const UntypedValofExpr & other ) : Expression( other ), body ( maybeClone( other.body ) ) {}
    594 
    595 UntypedValofExpr::~UntypedValofExpr() { delete body; }
    596 
    597 void UntypedValofExpr::print( std::ostream &os, int indent ) const {
    598         os << std::string( indent, ' ' ) << "Valof Expression: " << std::endl;
    599         if ( get_body() != 0 )
    600                 get_body()->print( os, indent + 2 );
    601 }
    602 
    603593RangeExpr::RangeExpr( Expression *low, Expression *high ) : low( low ), high( high ) {}
    604594RangeExpr::RangeExpr( const RangeExpr &other ) : Expression( other ), low( other.low->clone() ), high( other.high->clone() ) {}
     
    670660}
    671661
     662InitAlternative::InitAlternative( Type * type, Designation * designation ) : type( type ), designation( designation ) {}
     663InitAlternative::InitAlternative( const InitAlternative & other ) : type( maybeClone( other.type ) ), designation( maybeClone( other.designation ) ) {}
     664InitAlternative::~InitAlternative() {
     665        delete type;
     666        delete designation;
     667}
     668
     669UntypedInitExpr::UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts ) : expr( expr ), initAlts( initAlts ) {}
     670UntypedInitExpr::UntypedInitExpr( const UntypedInitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), initAlts( other.initAlts ) {}
     671UntypedInitExpr::~UntypedInitExpr() {
     672        delete expr;
     673}
     674
     675void UntypedInitExpr::print( std::ostream & os, int indent ) const {
     676        os << "Untyped Init Expression" << std::endl << std::string( indent+2, ' ' );
     677        expr->print( os, indent+2 );
     678        if ( ! initAlts.empty() ) {
     679                for ( const InitAlternative & alt : initAlts ) {
     680                        os << std::string( indent+2, ' ' ) <<  "InitAlternative: ";
     681                        alt.type->print( os, indent+2 );
     682                        alt.designation->print( os, indent+2 );
     683                }
     684        }
     685}
     686
     687InitExpr::InitExpr( Expression * expr, Designation * designation ) : expr( expr ), designation( designation ) {
     688        set_result( expr->get_result()->clone() );
     689}
     690InitExpr::InitExpr( const InitExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), designation( maybeClone( other.designation) ) {}
     691InitExpr::~InitExpr() {
     692        delete expr;
     693        delete designation;
     694}
     695
     696void InitExpr::print( std::ostream & os, int indent ) const {
     697        os << "Init Expression" << std::endl << std::string( indent+2, ' ' );
     698        expr->print( os, indent+2 );
     699        os << std::string( indent+2, ' ' ) << "with designation: ";
     700        designation->print( os, indent+2 );
     701}
     702
     703
    672704std::ostream & operator<<( std::ostream & out, const Expression * expr ) {
    673705        if ( expr ) {
Note: See TracChangeset for help on using the changeset viewer.