Changes in src/SynTree/Expression.h [3b58d91:b6fe7e6]
- File:
-
- 1 edited
-
src/SynTree/Expression.h (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Expression.h
r3b58d91 rb6fe7e6 200 200 class UntypedMemberExpr : public Expression { 201 201 public: 202 UntypedMemberExpr( Expression *member, Expression *aggregate, Expression *_aname = nullptr );202 UntypedMemberExpr( std::string member, Expression *aggregate, Expression *_aname = nullptr ); 203 203 UntypedMemberExpr( const UntypedMemberExpr &other ); 204 204 virtual ~UntypedMemberExpr(); 205 205 206 Expression *get_member() const { return member; }207 void set_member( Expression *newValue ) { member = newValue; }206 std::string get_member() const { return member; } 207 void set_member( const std::string &newValue ) { member = newValue; } 208 208 Expression *get_aggregate() const { return aggregate; } 209 209 void set_aggregate( Expression *newValue ) { aggregate = newValue; } … … 214 214 virtual void print( std::ostream &os, int indent = 0 ) const; 215 215 private: 216 Expression *member;216 std::string member; 217 217 Expression *aggregate; 218 218 }; … … 595 595 }; 596 596 597 /// ConstructorExpr represents the use of a constructor in an expression context, e.g. int * x = malloc() { 5 }; 598 class ConstructorExpr : public Expression { 599 public: 600 ConstructorExpr( Expression * callExpr ); 601 ConstructorExpr( const ConstructorExpr & other ); 602 ~ConstructorExpr(); 603 604 Expression *get_callExpr() const { return callExpr; } 605 void set_callExpr( Expression *newValue ) { callExpr = newValue; } 606 607 virtual ConstructorExpr *clone() const { return new ConstructorExpr( *this ); } 608 virtual void accept( Visitor &v ) { v.visit( this ); } 609 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 610 virtual void print( std::ostream &os, int indent = 0 ) const; 611 private: 612 Expression * callExpr; 613 }; 614 615 /// CompoundLiteralExpr represents a C99 'compound literal' 616 class CompoundLiteralExpr : public Expression { 617 public: 618 CompoundLiteralExpr( Type * type, Initializer * initializer ); 619 CompoundLiteralExpr( const CompoundLiteralExpr &other ); 620 ~CompoundLiteralExpr(); 621 622 Type * get_type() const { return type; } 623 void set_type( Type * t ) { type = t; } 624 625 Initializer * get_initializer() const { return initializer; } 626 void set_initializer( Initializer * i ) { initializer = i; } 627 628 virtual CompoundLiteralExpr *clone() const { return new CompoundLiteralExpr( *this ); } 629 virtual void accept( Visitor &v ) { v.visit( this ); } 630 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 631 virtual void print( std::ostream &os, int indent = 0 ) const; 632 private: 633 Type * type; 634 Initializer * initializer; 635 }; 636 597 637 /// ValofExpr represents a GCC 'lambda expression' 598 638 class UntypedValofExpr : public Expression { … … 613 653 }; 614 654 615 /// CompoundLiteralExpr represents a C99 'compound literal' 616 class CompoundLiteralExpr : public Expression { 617 public: 618 CompoundLiteralExpr( Type * type, Initializer * initializer ); 619 CompoundLiteralExpr( const CompoundLiteralExpr &other ); 620 virtual ~CompoundLiteralExpr(); 621 622 Type * get_type() const { return type; } 623 void set_type( Type * t ) { type = t; } 624 625 Initializer * get_initializer() const { return initializer; } 626 void set_initializer( Initializer * i ) { initializer = i; } 627 628 virtual CompoundLiteralExpr *clone() const { return new CompoundLiteralExpr( *this ); } 629 virtual void accept( Visitor &v ) { v.visit( this ); } 630 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 631 virtual void print( std::ostream &os, int indent = 0 ) const; 632 private: 633 Type * type; 634 Initializer * initializer; 635 }; 636 655 /// RangeExpr represents a range e.g. '3 ... 5' or '1~10' 637 656 class RangeExpr : public Expression { 638 657 public: … … 651 670 private: 652 671 Expression *low, *high; 653 };654 655 /// TupleIndexExpr represents an element selection operation on a tuple value, e.g. t.3 after processing by the expression analyzer656 class TupleIndexExpr : public Expression {657 public:658 TupleIndexExpr( Expression * tuple, unsigned int index );659 TupleIndexExpr( const TupleIndexExpr &other );660 virtual ~TupleIndexExpr();661 662 Expression * get_tuple() const { return tuple; }663 int get_index() const { return index; }664 TupleIndexExpr * set_tuple( Expression *newValue ) { tuple = newValue; return this; }665 TupleIndexExpr * set_index( unsigned int newValue ) { index = newValue; return this; }666 667 virtual TupleIndexExpr *clone() const { return new TupleIndexExpr( *this ); }668 virtual void accept( Visitor &v ) { v.visit( this ); }669 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }670 virtual void print( std::ostream &os, int indent = 0 ) const;671 private:672 Expression * tuple;673 unsigned int index;674 };675 676 /// MemberTupleExpr represents a tuple member selection operation on a struct type, e.g. s.[a, b, c] after processing by the expression analyzer677 class MemberTupleExpr : public Expression {678 public:679 MemberTupleExpr( Expression * member, Expression * aggregate, Expression * _aname = nullptr );680 MemberTupleExpr( const MemberTupleExpr &other );681 virtual ~MemberTupleExpr();682 683 Expression * get_member() const { return member; }684 Expression * get_aggregate() const { return aggregate; }685 MemberTupleExpr * set_member( Expression *newValue ) { member = newValue; return this; }686 MemberTupleExpr * set_aggregate( Expression *newValue ) { aggregate = newValue; return this; }687 688 virtual MemberTupleExpr *clone() const { return new MemberTupleExpr( *this ); }689 virtual void accept( Visitor &v ) { v.visit( this ); }690 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }691 virtual void print( std::ostream &os, int indent = 0 ) const;692 private:693 Expression * member;694 Expression * aggregate;695 };696 697 /// MultipleAssignExpr represents a multiple assignment operation, where both sides of the assignment have tuple type, e.g. [a, b, c] = [d, e, f];698 class MultipleAssignExpr : public Expression {699 public:700 MultipleAssignExpr( Expression * lhs, Expression * rhs );701 MultipleAssignExpr( const MultipleAssignExpr &other );702 virtual ~MultipleAssignExpr();703 704 Expression * get_lhs() const { return lhs; }705 Expression * get_rhs() const { return rhs; }706 MultipleAssignExpr * set_lhs( Expression *newValue ) { lhs = newValue; return this; }707 MultipleAssignExpr * set_rhs( Expression *newValue ) { rhs = newValue; return this; }708 709 virtual MultipleAssignExpr *clone() const { return new MultipleAssignExpr( *this ); }710 virtual void accept( Visitor &v ) { v.visit( this ); }711 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }712 virtual void print( std::ostream &os, int indent = 0 ) const;713 private:714 Expression * lhs;715 Expression * rhs;716 };717 718 /// MassAssignExpr represents a mass assignment operations, where the left hand side has tuple type and the right hand side does not, e.g. [a, b, c] = 5.0;719 class MassAssignExpr : public Expression {720 public:721 MassAssignExpr( Expression * tuple, int field );722 MassAssignExpr( const MassAssignExpr &other );723 virtual ~MassAssignExpr();724 725 Expression * get_lhs() const { return lhs; }726 Expression * get_rhs() const { return rhs; }727 MassAssignExpr * set_lhs( Expression *newValue ) { lhs = newValue; return this; }728 MassAssignExpr * set_rhs( Expression *newValue ) { rhs = newValue; return this; }729 730 virtual MassAssignExpr *clone() const { return new MassAssignExpr( *this ); }731 virtual void accept( Visitor &v ) { v.visit( this ); }732 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }733 virtual void print( std::ostream &os, int indent = 0 ) const;734 private:735 Expression * lhs; // multiple exprs736 Expression * rhs; // single expr737 672 }; 738 673
Note:
See TracChangeset
for help on using the changeset viewer.