Changeset bf32bb8 for src/SynTree
- Timestamp:
- Oct 18, 2016, 4:23:04 PM (9 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:
- f0121d7
- Parents:
- 848ce71
- Location:
- src/SynTree
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/SynTree/Expression.cc ¶
r848ce71 rbf32bb8 580 580 581 581 582 UniqueExpr::UniqueExpr( Expression *expr ) : expr( new Expression* ) { 582 long long UniqueExpr::count = 0; 583 UniqueExpr::UniqueExpr( Expression *expr, long long idVal ) : expr( new Expression* ), id( idVal ) { 584 assert( count != -1 ); 585 if ( id == -1 ) id = count++; 583 586 set_expr( expr ); 584 587 assert( expr ); 585 assert( expr->has_result() ); 586 set_result( expr->get_result()->clone() ); 587 } 588 UniqueExpr::UniqueExpr( const UniqueExpr &other ) : Expression( other ), expr( other.expr ) { 588 if ( expr->get_result() ) { 589 set_result( expr->get_result()->clone() ); 590 } 591 } 592 UniqueExpr::UniqueExpr( const UniqueExpr &other ) : Expression( other ), expr( other.expr ), id( other.id ) { 589 593 } 590 594 UniqueExpr::~UniqueExpr() { … … 594 598 } 595 599 void UniqueExpr::print( std::ostream &os, int indent ) const { 596 os << "Unique Expression : "<< std::endl << std::string( indent+2, ' ' );600 os << "Unique Expression with id:" << id << std::endl << std::string( indent+2, ' ' ); 597 601 get_expr()->print( os, indent+2 ); 598 602 } -
TabularUnified src/SynTree/Expression.h ¶
r848ce71 rbf32bb8 735 735 class UniqueExpr : public Expression { 736 736 public: 737 UniqueExpr( Expression * expr );737 UniqueExpr( Expression * expr, long long idVal = -1 ); 738 738 UniqueExpr( const UniqueExpr & other ); 739 739 ~UniqueExpr(); … … 742 742 UniqueExpr * set_expr( Expression * newValue ) { *expr = newValue; return this; } 743 743 744 int get_id() const { return id; } 745 744 746 virtual UniqueExpr *clone() const { return new UniqueExpr( *this ); } 745 747 virtual void accept( Visitor &v ) { v.visit( this ); } … … 748 750 private: 749 751 std::shared_ptr< Expression * > expr; 752 int id; 753 static long long count; 750 754 }; 751 755
Note: See TracChangeset
for help on using the changeset viewer.