Changes in src/SynTree/Expression.h [906e24d:6eb8948]
- File:
-
- 1 edited
-
src/SynTree/Expression.h (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Expression.h
r906e24d r6eb8948 32 32 virtual ~Expression(); 33 33 34 Type *& get_result() { return result; } 35 void set_result( Type *newValue ) { result = newValue; } 36 bool has_result() const { return result != nullptr; } 34 std::list<Type *>& get_results() { return results; } 35 void add_result( Type *t ); 37 36 38 37 TypeSubstitution *get_env() const { return env; } … … 48 47 virtual void print( std::ostream &os, int indent = 0 ) const; 49 48 protected: 50 Type * result;49 std::list<Type *> results; 51 50 TypeSubstitution *env; 52 51 Expression* argName; // if expression is used as an argument, it can be "designated" by this name … … 99 98 class UntypedExpr : public Expression { 100 99 public: 101 UntypedExpr( Expression *function, Expression *_aname = nullptr );100 UntypedExpr( Expression *function, const std::list<Expression *> &args = std::list< Expression * >(), Expression *_aname = nullptr ); 102 101 UntypedExpr( const UntypedExpr &other ); 103 UntypedExpr( Expression *function, std::list<Expression *> &args, Expression *_aname = nullptr );104 102 virtual ~UntypedExpr(); 105 103 … … 201 199 class UntypedMemberExpr : public Expression { 202 200 public: 203 UntypedMemberExpr( std::stringmember, Expression *aggregate, Expression *_aname = nullptr );201 UntypedMemberExpr( Expression *member, Expression *aggregate, Expression *_aname = nullptr ); 204 202 UntypedMemberExpr( const UntypedMemberExpr &other ); 205 203 virtual ~UntypedMemberExpr(); 206 204 207 std::stringget_member() const { return member; }208 void set_member( const std::string &newValue ) { member = newValue; }205 Expression * get_member() const { return member; } 206 void set_member( Expression * newValue ) { member = newValue; } 209 207 Expression *get_aggregate() const { return aggregate; } 210 208 void set_aggregate( Expression *newValue ) { aggregate = newValue; } … … 215 213 virtual void print( std::ostream &os, int indent = 0 ) const; 216 214 private: 217 std::stringmember;215 Expression *member; 218 216 Expression *aggregate; 219 217 }; … … 484 482 }; 485 483 486 /// TupleExpr represents a tuple expression ( [a, b, c] )487 class TupleExpr : public Expression {488 public:489 TupleExpr( Expression *_aname = nullptr );490 TupleExpr( const TupleExpr &other );491 virtual ~TupleExpr();492 493 void set_exprs( std::list<Expression*> newValue ) { exprs = newValue; }494 std::list<Expression*>& get_exprs() { return exprs; }495 496 virtual TupleExpr *clone() const { return new TupleExpr( *this ); }497 virtual void accept( Visitor &v ) { v.visit( this ); }498 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }499 virtual void print( std::ostream &os, int indent = 0 ) const;500 private:501 std::list<Expression*> exprs;502 };503 504 /// SolvedTupleExpr represents a TupleExpr whose components have been type-resolved. It is effectively a shell for the code generator to work on505 class SolvedTupleExpr : public Expression {506 public:507 SolvedTupleExpr( Expression *_aname = nullptr ) : Expression( _aname ) {}508 SolvedTupleExpr( std::list<Expression *> &, Expression *_aname = nullptr );509 SolvedTupleExpr( const SolvedTupleExpr &other );510 virtual ~SolvedTupleExpr() {}511 512 std::list<Expression*> &get_exprs() { return exprs; }513 514 virtual SolvedTupleExpr *clone() const { return new SolvedTupleExpr( *this ); }515 virtual void accept( Visitor &v ) { v.visit( this ); }516 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }517 virtual void print( std::ostream &os, int indent = 0 ) const;518 private:519 std::list<Expression*> exprs;520 };521 522 484 /// TypeExpr represents a type used in an expression (e.g. as a type generator parameter) 523 485 class TypeExpr : public Expression { … … 619 581 CompoundLiteralExpr( Type * type, Initializer * initializer ); 620 582 CompoundLiteralExpr( const CompoundLiteralExpr &other ); 621 ~CompoundLiteralExpr();583 virtual ~CompoundLiteralExpr(); 622 584 623 585 Type * get_type() const { return type; } … … 671 633 private: 672 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; 673 732 }; 674 733
Note:
See TracChangeset
for help on using the changeset viewer.