Changeset 141b786 for src/SynTree
- Timestamp:
- Nov 9, 2016, 2:21:05 PM (8 years ago)
- 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:
- b726084
- Parents:
- 23bb1b9
- Location:
- src/SynTree
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/SynTree/Expression.cc ¶
r23bb1b9 r141b786 609 609 610 610 long long UniqueExpr::count = 0; 611 UniqueExpr::UniqueExpr( Expression *expr, long long idVal ) : expr( new Expression* ), object( new ObjectDecl* ), id( idVal ) { 611 UniqueExpr::UniqueExpr( Expression *expr, long long idVal ) : expr( expr ), object( nullptr ), var( nullptr ), id( idVal ) { 612 assert( expr ); 612 613 assert( count != -1 ); 613 614 if ( id == -1 ) id = count++; 614 set_expr( expr );615 assert( expr );616 615 if ( expr->get_result() ) { 617 616 set_result( expr->get_result()->clone() ); 618 617 } 619 set_object( nullptr ); 620 } 621 UniqueExpr::UniqueExpr( const UniqueExpr &other ) : Expression( other ), expr( other.expr ), object( other.object ), id( other.id ) { 618 } 619 UniqueExpr::UniqueExpr( const UniqueExpr &other ) : Expression( other ), expr( maybeClone( other.expr ) ), object( maybeClone( other.object ) ), var( maybeClone( other.var ) ), id( other.id ) { 622 620 } 623 621 UniqueExpr::~UniqueExpr() { 624 if ( expr.unique() ) { 625 delete *expr; 626 } 627 if ( object.unique() ) { 628 delete *object; 629 } 622 delete expr; 623 delete object; 624 delete var; 630 625 } 631 626 void UniqueExpr::print( std::ostream &os, int indent ) const { -
TabularUnified src/SynTree/Expression.h ¶
r23bb1b9 r141b786 742 742 ~UniqueExpr(); 743 743 744 Expression * get_expr() const { return *expr; } 745 UniqueExpr * set_expr( Expression * newValue ) { *expr = newValue; return this; } 746 747 ObjectDecl * get_object() const { return *object; } 748 UniqueExpr * set_object( ObjectDecl * newValue ) { *object = newValue; return this; } 744 Expression * get_expr() const { return expr; } 745 UniqueExpr * set_expr( Expression * newValue ) { expr = newValue; return this; } 746 747 ObjectDecl * get_object() const { return object; } 748 UniqueExpr * set_object( ObjectDecl * newValue ) { object = newValue; return this; } 749 750 VariableExpr * get_var() const { return var; } 751 UniqueExpr * set_var( VariableExpr * newValue ) { var = newValue; return this; } 749 752 750 753 int get_id() const { return id; } … … 755 758 virtual void print( std::ostream &os, int indent = 0 ) const; 756 759 private: 757 std::shared_ptr< Expression * > expr; 758 std::shared_ptr< ObjectDecl * > object; 760 Expression * expr; 761 ObjectDecl * object; 762 VariableExpr * var; 759 763 int id; 760 764 static long long count;
Note: See TracChangeset
for help on using the changeset viewer.