Changes in src/SynTree/Expression.h [b6fe7e6:6eb8948]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Expression.h
rb6fe7e6 r6eb8948 98 98 class UntypedExpr : public Expression { 99 99 public: 100 UntypedExpr( Expression *function, Expression *_aname = nullptr );100 UntypedExpr( Expression *function, const std::list<Expression *> &args = std::list< Expression * >(), Expression *_aname = nullptr ); 101 101 UntypedExpr( const UntypedExpr &other ); 102 UntypedExpr( Expression *function, std::list<Expression *> &args, Expression *_aname = nullptr );103 102 virtual ~UntypedExpr(); 104 103 … … 200 199 class UntypedMemberExpr : public Expression { 201 200 public: 202 UntypedMemberExpr( std::stringmember, Expression *aggregate, Expression *_aname = nullptr );201 UntypedMemberExpr( Expression *member, Expression *aggregate, Expression *_aname = nullptr ); 203 202 UntypedMemberExpr( const UntypedMemberExpr &other ); 204 203 virtual ~UntypedMemberExpr(); 205 204 206 std::stringget_member() const { return member; }207 void set_member( const std::string &newValue ) { member = newValue; }205 Expression * get_member() const { return member; } 206 void set_member( Expression * newValue ) { member = newValue; } 208 207 Expression *get_aggregate() const { return aggregate; } 209 208 void set_aggregate( Expression *newValue ) { aggregate = newValue; } … … 214 213 virtual void print( std::ostream &os, int indent = 0 ) const; 215 214 private: 216 std::stringmember;215 Expression *member; 217 216 Expression *aggregate; 218 217 }; … … 483 482 }; 484 483 485 /// TupleExpr represents a tuple expression ( [a, b, c] )486 class TupleExpr : public Expression {487 public:488 TupleExpr( Expression *_aname = nullptr );489 TupleExpr( const TupleExpr &other );490 virtual ~TupleExpr();491 492 void set_exprs( std::list<Expression*> newValue ) { exprs = newValue; }493 std::list<Expression*>& get_exprs() { return exprs; }494 495 virtual TupleExpr *clone() const { return new TupleExpr( *this ); }496 virtual void accept( Visitor &v ) { v.visit( this ); }497 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }498 virtual void print( std::ostream &os, int indent = 0 ) const;499 private:500 std::list<Expression*> exprs;501 };502 503 /// SolvedTupleExpr represents a TupleExpr whose components have been type-resolved. It is effectively a shell for the code generator to work on504 class SolvedTupleExpr : public Expression {505 public:506 SolvedTupleExpr( Expression *_aname = nullptr ) : Expression( _aname ) {}507 SolvedTupleExpr( std::list<Expression *> &, Expression *_aname = nullptr );508 SolvedTupleExpr( const SolvedTupleExpr &other );509 virtual ~SolvedTupleExpr() {}510 511 std::list<Expression*> &get_exprs() { return exprs; }512 513 virtual SolvedTupleExpr *clone() const { return new SolvedTupleExpr( *this ); }514 virtual void accept( Visitor &v ) { v.visit( this ); }515 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }516 virtual void print( std::ostream &os, int indent = 0 ) const;517 private:518 std::list<Expression*> exprs;519 };520 521 484 /// TypeExpr represents a type used in an expression (e.g. as a type generator parameter) 522 485 class TypeExpr : public Expression { … … 618 581 CompoundLiteralExpr( Type * type, Initializer * initializer ); 619 582 CompoundLiteralExpr( const CompoundLiteralExpr &other ); 620 ~CompoundLiteralExpr();583 virtual ~CompoundLiteralExpr(); 621 584 622 585 Type * get_type() const { return type; } … … 670 633 private: 671 634 Expression *low, *high; 635 }; 636 637 /// TupleExpr represents a tuple expression ( [a, b, c] ) 638 class TupleExpr : public Expression { 639 public: 640 TupleExpr( Expression *_aname = nullptr ); 641 TupleExpr( const TupleExpr &other ); 642 virtual ~TupleExpr(); 643 644 void set_exprs( std::list<Expression*> newValue ) { exprs = newValue; } 645 std::list<Expression*>& get_exprs() { return exprs; } 646 647 virtual TupleExpr *clone() const { return new TupleExpr( *this ); } 648 virtual void accept( Visitor &v ) { v.visit( this ); } 649 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 650 virtual void print( std::ostream &os, int indent = 0 ) const; 651 private: 652 std::list<Expression*> exprs; 653 }; 654 655 /// TupleIndexExpr represents an element selection operation on a tuple value, e.g. t.3 after processing by the expression analyzer 656 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 analyzer 677 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 /// TupleAssignExpr represents a multiple assignment operation, where both sides of the assignment have tuple type, e.g. [a, b, c] = [d, e, f];, or a mass assignment operation, where the left hand side has tuple type and the right hand side does not, e.g. [a, b, c] = 5.0; 698 class TupleAssignExpr : public Expression { 699 public: 700 TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls, Expression * _aname = nullptr ); 701 TupleAssignExpr( const TupleAssignExpr &other ); 702 virtual ~TupleAssignExpr(); 703 704 std::list< Expression * > & get_assigns() { return assigns; } 705 std::list< ObjectDecl * > & get_tempDecls() { return tempDecls; } 706 707 virtual TupleAssignExpr *clone() const { return new TupleAssignExpr( *this ); } 708 virtual void accept( Visitor &v ) { v.visit( this ); } 709 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 710 virtual void print( std::ostream &os, int indent = 0 ) const; 711 private: 712 std::list< Expression * > assigns; // assignment expressions that use tempDecls 713 std::list< ObjectDecl * > tempDecls; // temporaries for address of lhs exprs 714 }; 715 716 /// StmtExpr represents a GCC 'statement expression', e.g. ({ int x = 5; x; }) 717 class StmtExpr : public Expression { 718 public: 719 StmtExpr( CompoundStmt *statements ); 720 StmtExpr( const StmtExpr & other ); 721 virtual ~StmtExpr(); 722 723 CompoundStmt * get_statements() const { return statements; } 724 StmtExpr * set_statements( CompoundStmt * newValue ) { statements = newValue; return this; } 725 726 virtual StmtExpr *clone() const { return new StmtExpr( *this ); } 727 virtual void accept( Visitor &v ) { v.visit( this ); } 728 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 729 virtual void print( std::ostream &os, int indent = 0 ) const; 730 private: 731 CompoundStmt * statements; 672 732 }; 673 733
Note:
See TracChangeset
for help on using the changeset viewer.