Changes in src/SynTree/Expression.h [6eb8948:b6fe7e6]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Expression.h
r6eb8948 rb6fe7e6 98 98 class UntypedExpr : public Expression { 99 99 public: 100 UntypedExpr( Expression *function, const std::list<Expression *> &args = std::list< Expression * >(),Expression *_aname = nullptr );100 UntypedExpr( Expression *function, Expression *_aname = nullptr ); 101 101 UntypedExpr( const UntypedExpr &other ); 102 UntypedExpr( Expression *function, std::list<Expression *> &args, Expression *_aname = nullptr ); 102 103 virtual ~UntypedExpr(); 103 104 … … 199 200 class UntypedMemberExpr : public Expression { 200 201 public: 201 UntypedMemberExpr( Expression *member, Expression *aggregate, Expression *_aname = nullptr );202 UntypedMemberExpr( std::string member, Expression *aggregate, Expression *_aname = nullptr ); 202 203 UntypedMemberExpr( const UntypedMemberExpr &other ); 203 204 virtual ~UntypedMemberExpr(); 204 205 205 Expression *get_member() const { return member; }206 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; } 207 208 Expression *get_aggregate() const { return aggregate; } 208 209 void set_aggregate( Expression *newValue ) { aggregate = newValue; } … … 213 214 virtual void print( std::ostream &os, int indent = 0 ) const; 214 215 private: 215 Expression *member;216 std::string member; 216 217 Expression *aggregate; 217 218 }; … … 482 483 }; 483 484 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 on 504 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 484 521 /// TypeExpr represents a type used in an expression (e.g. as a type generator parameter) 485 522 class TypeExpr : public Expression { … … 581 618 CompoundLiteralExpr( Type * type, Initializer * initializer ); 582 619 CompoundLiteralExpr( const CompoundLiteralExpr &other ); 583 virtual~CompoundLiteralExpr();620 ~CompoundLiteralExpr(); 584 621 585 622 Type * get_type() const { return type; } … … 633 670 private: 634 671 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 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 /// 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 tempDecls713 std::list< ObjectDecl * > tempDecls; // temporaries for address of lhs exprs714 };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;732 672 }; 733 673
Note:
See TracChangeset
for help on using the changeset viewer.