Changeset 77971f6 for src/SynTree
- Timestamp:
- Oct 27, 2016, 3:24:02 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:
- 3f0c6a5
- Parents:
- a1e67dd
- git-author:
- Rob Schluntz <rschlunt@…> (10/27/16 15:11:00)
- git-committer:
- Rob Schluntz <rschlunt@…> (10/27/16 15:24:02)
- Location:
- src/SynTree
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Expression.cc
ra1e67dd r77971f6 581 581 582 582 long long UniqueExpr::count = 0; 583 UniqueExpr::UniqueExpr( Expression *expr, long long idVal ) : expr( new Expression* ), id( idVal ) {583 UniqueExpr::UniqueExpr( Expression *expr, long long idVal ) : expr( new Expression* ), object( new ObjectDecl* ), id( idVal ) { 584 584 assert( count != -1 ); 585 585 if ( id == -1 ) id = count++; … … 589 589 set_result( expr->get_result()->clone() ); 590 590 } 591 } 592 UniqueExpr::UniqueExpr( const UniqueExpr &other ) : Expression( other ), expr( other.expr ), id( other.id ) { 591 set_object( nullptr ); 592 } 593 UniqueExpr::UniqueExpr( const UniqueExpr &other ) : Expression( other ), expr( other.expr ), object( other.object ), id( other.id ) { 593 594 } 594 595 UniqueExpr::~UniqueExpr() { … … 596 597 delete *expr; 597 598 } 599 if ( object.unique() ) { 600 delete *object; 601 } 598 602 } 599 603 void UniqueExpr::print( std::ostream &os, int indent ) const { 600 604 os << "Unique Expression with id:" << id << std::endl << std::string( indent+2, ' ' ); 601 605 get_expr()->print( os, indent+2 ); 606 if ( get_object() ) { 607 os << " with decl: "; 608 get_object()->printShort( os, indent+2 ); 609 } 602 610 } 603 611 -
src/SynTree/Expression.h
ra1e67dd r77971f6 742 742 UniqueExpr * set_expr( Expression * newValue ) { *expr = newValue; return this; } 743 743 744 ObjectDecl * get_object() const { return *object; } 745 UniqueExpr * set_object( ObjectDecl * newValue ) { *object = newValue; return this; } 746 744 747 int get_id() const { return id; } 745 748 … … 750 753 private: 751 754 std::shared_ptr< Expression * > expr; 755 std::shared_ptr< ObjectDecl * > object; 752 756 int id; 753 757 static long long count;
Note: See TracChangeset
for help on using the changeset viewer.