| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 V(CallRuntime) \ | 88 V(CallRuntime) \ |
| 89 V(UnaryOperation) \ | 89 V(UnaryOperation) \ |
| 90 V(CountOperation) \ | 90 V(CountOperation) \ |
| 91 V(BinaryOperation) \ | 91 V(BinaryOperation) \ |
| 92 V(CompareOperation) \ | 92 V(CompareOperation) \ |
| 93 V(ThisFunction) | 93 V(ThisFunction) |
| 94 | 94 |
| 95 | 95 |
| 96 // Forward declarations | 96 // Forward declarations |
| 97 class TargetCollector; | 97 class TargetCollector; |
| 98 class MaterializedLiteral; | |
| 99 | 98 |
| 100 #define DEF_FORWARD_DECLARATION(type) class type; | 99 #define DEF_FORWARD_DECLARATION(type) class type; |
| 101 NODE_LIST(DEF_FORWARD_DECLARATION) | 100 NODE_LIST(DEF_FORWARD_DECLARATION) |
| 102 #undef DEF_FORWARD_DECLARATION | 101 #undef DEF_FORWARD_DECLARATION |
| 103 | 102 |
| 104 | 103 |
| 105 // Typedef only introduced to avoid unreadable code. | 104 // Typedef only introduced to avoid unreadable code. |
| 106 // Please do appreciate the required space in "> >". | 105 // Please do appreciate the required space in "> >". |
| 107 typedef ZoneList<Handle<String> > ZoneStringList; | 106 typedef ZoneList<Handle<String> > ZoneStringList; |
| 108 | 107 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 123 virtual VariableProxy* AsVariableProxy() { return NULL; } | 122 virtual VariableProxy* AsVariableProxy() { return NULL; } |
| 124 virtual Property* AsProperty() { return NULL; } | 123 virtual Property* AsProperty() { return NULL; } |
| 125 virtual Call* AsCall() { return NULL; } | 124 virtual Call* AsCall() { return NULL; } |
| 126 virtual TargetCollector* AsTargetCollector() { return NULL; } | 125 virtual TargetCollector* AsTargetCollector() { return NULL; } |
| 127 virtual BreakableStatement* AsBreakableStatement() { return NULL; } | 126 virtual BreakableStatement* AsBreakableStatement() { return NULL; } |
| 128 virtual IterationStatement* AsIterationStatement() { return NULL; } | 127 virtual IterationStatement* AsIterationStatement() { return NULL; } |
| 129 virtual UnaryOperation* AsUnaryOperation() { return NULL; } | 128 virtual UnaryOperation* AsUnaryOperation() { return NULL; } |
| 130 virtual BinaryOperation* AsBinaryOperation() { return NULL; } | 129 virtual BinaryOperation* AsBinaryOperation() { return NULL; } |
| 131 virtual Assignment* AsAssignment() { return NULL; } | 130 virtual Assignment* AsAssignment() { return NULL; } |
| 132 virtual FunctionLiteral* AsFunctionLiteral() { return NULL; } | 131 virtual FunctionLiteral* AsFunctionLiteral() { return NULL; } |
| 133 virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; } | |
| 134 virtual ObjectLiteral* AsObjectLiteral() { return NULL; } | |
| 135 virtual ArrayLiteral* AsArrayLiteral() { return NULL; } | |
| 136 | 132 |
| 137 void set_statement_pos(int statement_pos) { statement_pos_ = statement_pos; } | 133 void set_statement_pos(int statement_pos) { statement_pos_ = statement_pos; } |
| 138 int statement_pos() const { return statement_pos_; } | 134 int statement_pos() const { return statement_pos_; } |
| 139 | 135 |
| 140 private: | 136 private: |
| 141 int statement_pos_; | 137 int statement_pos_; |
| 142 }; | 138 }; |
| 143 | 139 |
| 144 | 140 |
| 145 class Statement: public Node { | 141 class Statement: public Node { |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 Handle<Object> handle() const { return handle_; } | 629 Handle<Object> handle() const { return handle_; } |
| 634 | 630 |
| 635 private: | 631 private: |
| 636 Handle<Object> handle_; | 632 Handle<Object> handle_; |
| 637 }; | 633 }; |
| 638 | 634 |
| 639 | 635 |
| 640 // Base class for literals that needs space in the corresponding JSFunction. | 636 // Base class for literals that needs space in the corresponding JSFunction. |
| 641 class MaterializedLiteral: public Expression { | 637 class MaterializedLiteral: public Expression { |
| 642 public: | 638 public: |
| 643 explicit MaterializedLiteral(int literal_index, bool is_simple) | 639 explicit MaterializedLiteral(int literal_index) |
| 644 : literal_index_(literal_index), is_simple_(is_simple) {} | 640 : literal_index_(literal_index) {} |
| 645 | |
| 646 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } | |
| 647 | |
| 648 int literal_index() { return literal_index_; } | 641 int literal_index() { return literal_index_; } |
| 649 | |
| 650 // A materialized literal is simple if the values consist of only | |
| 651 // constants and simple object and array literals. | |
| 652 bool is_simple() const { return is_simple_; } | |
| 653 | |
| 654 private: | 642 private: |
| 655 int literal_index_; | 643 int literal_index_; |
| 656 bool is_simple_; | |
| 657 }; | 644 }; |
| 658 | 645 |
| 659 | 646 |
| 660 // An object literal has a boilerplate object that is used | 647 // An object literal has a boilerplate object that is used |
| 661 // for minimizing the work when constructing it at runtime. | 648 // for minimizing the work when constructing it at runtime. |
| 662 class ObjectLiteral: public MaterializedLiteral { | 649 class ObjectLiteral: public MaterializedLiteral { |
| 663 public: | 650 public: |
| 664 // Property is used for passing information | 651 // Property is used for passing information |
| 665 // about an object literal's properties from the parser | 652 // about an object literal's properties from the parser |
| 666 // to the code generator. | 653 // to the code generator. |
| 667 class Property: public ZoneObject { | 654 class Property: public ZoneObject { |
| 668 public: | 655 public: |
| 669 | 656 |
| 670 enum Kind { | 657 enum Kind { |
| 671 CONSTANT, // Property with constant value (compile time). | 658 CONSTANT, // Property with constant value (at compile time). |
| 672 COMPUTED, // Property with computed value (execution time). | 659 COMPUTED, // Property with computed value (at execution time). |
| 673 MATERIALIZED_LITERAL, // Property value is a materialized literal. | 660 GETTER, SETTER, // Property is an accessor function. |
| 674 GETTER, SETTER, // Property is an accessor function. | 661 PROTOTYPE // Property is __proto__. |
| 675 PROTOTYPE // Property is __proto__. | |
| 676 }; | 662 }; |
| 677 | 663 |
| 678 Property(Literal* key, Expression* value); | 664 Property(Literal* key, Expression* value); |
| 679 Property(bool is_getter, FunctionLiteral* value); | 665 Property(bool is_getter, FunctionLiteral* value); |
| 680 | 666 |
| 681 Literal* key() { return key_; } | 667 Literal* key() { return key_; } |
| 682 Expression* value() { return value_; } | 668 Expression* value() { return value_; } |
| 683 Kind kind() { return kind_; } | 669 Kind kind() { return kind_; } |
| 684 | 670 |
| 685 private: | 671 private: |
| 686 Literal* key_; | 672 Literal* key_; |
| 687 Expression* value_; | 673 Expression* value_; |
| 688 Kind kind_; | 674 Kind kind_; |
| 689 }; | 675 }; |
| 690 | 676 |
| 691 ObjectLiteral(Handle<FixedArray> constant_properties, | 677 ObjectLiteral(Handle<FixedArray> constant_properties, |
| 692 ZoneList<Property*>* properties, | 678 ZoneList<Property*>* properties, |
| 693 int literal_index, | 679 int literal_index) |
| 694 bool is_simple) | 680 : MaterializedLiteral(literal_index), |
| 695 : MaterializedLiteral(literal_index, is_simple), | |
| 696 constant_properties_(constant_properties), | 681 constant_properties_(constant_properties), |
| 697 properties_(properties) {} | 682 properties_(properties) { |
| 683 } |
| 698 | 684 |
| 699 virtual ObjectLiteral* AsObjectLiteral() { return this; } | |
| 700 virtual void Accept(AstVisitor* v); | 685 virtual void Accept(AstVisitor* v); |
| 701 | 686 |
| 702 Handle<FixedArray> constant_properties() const { | 687 Handle<FixedArray> constant_properties() const { |
| 703 return constant_properties_; | 688 return constant_properties_; |
| 704 } | 689 } |
| 705 ZoneList<Property*>* properties() const { return properties_; } | 690 ZoneList<Property*>* properties() const { return properties_; } |
| 706 | 691 |
| 707 private: | 692 private: |
| 708 Handle<FixedArray> constant_properties_; | 693 Handle<FixedArray> constant_properties_; |
| 709 ZoneList<Property*>* properties_; | 694 ZoneList<Property*>* properties_; |
| 710 }; | 695 }; |
| 711 | 696 |
| 712 | 697 |
| 713 // Node for capturing a regexp literal. | 698 // Node for capturing a regexp literal. |
| 714 class RegExpLiteral: public MaterializedLiteral { | 699 class RegExpLiteral: public MaterializedLiteral { |
| 715 public: | 700 public: |
| 716 RegExpLiteral(Handle<String> pattern, | 701 RegExpLiteral(Handle<String> pattern, |
| 717 Handle<String> flags, | 702 Handle<String> flags, |
| 718 int literal_index) | 703 int literal_index) |
| 719 : MaterializedLiteral(literal_index, false), | 704 : MaterializedLiteral(literal_index), |
| 720 pattern_(pattern), | 705 pattern_(pattern), |
| 721 flags_(flags) {} | 706 flags_(flags) {} |
| 722 | 707 |
| 723 virtual void Accept(AstVisitor* v); | 708 virtual void Accept(AstVisitor* v); |
| 724 | 709 |
| 725 Handle<String> pattern() const { return pattern_; } | 710 Handle<String> pattern() const { return pattern_; } |
| 726 Handle<String> flags() const { return flags_; } | 711 Handle<String> flags() const { return flags_; } |
| 727 | 712 |
| 728 private: | 713 private: |
| 729 Handle<String> pattern_; | 714 Handle<String> pattern_; |
| 730 Handle<String> flags_; | 715 Handle<String> flags_; |
| 731 }; | 716 }; |
| 732 | 717 |
| 733 // An array literal has a literals object that is used | 718 // An array literal has a literals object that is used |
| 734 // for minimizing the work when constructing it at runtime. | 719 // for minimizing the work when constructing it at runtime. |
| 735 class ArrayLiteral: public MaterializedLiteral { | 720 class ArrayLiteral: public Expression { |
| 736 public: | 721 public: |
| 737 ArrayLiteral(Handle<FixedArray> literals, | 722 ArrayLiteral(Handle<FixedArray> literals, |
| 738 ZoneList<Expression*>* values, | 723 ZoneList<Expression*>* values) |
| 739 int literal_index, | 724 : literals_(literals), values_(values) { |
| 740 bool is_simple) | 725 } |
| 741 : MaterializedLiteral(literal_index, is_simple), | |
| 742 literals_(literals), | |
| 743 values_(values) {} | |
| 744 | 726 |
| 745 virtual void Accept(AstVisitor* v); | 727 virtual void Accept(AstVisitor* v); |
| 746 virtual ArrayLiteral* AsArrayLiteral() { return this; } | |
| 747 | 728 |
| 748 Handle<FixedArray> literals() const { return literals_; } | 729 Handle<FixedArray> literals() const { return literals_; } |
| 749 ZoneList<Expression*>* values() const { return values_; } | 730 ZoneList<Expression*>* values() const { return values_; } |
| 750 | 731 |
| 751 private: | 732 private: |
| 752 Handle<FixedArray> literals_; | 733 Handle<FixedArray> literals_; |
| 753 ZoneList<Expression*>* values_; | 734 ZoneList<Expression*>* values_; |
| 754 }; | 735 }; |
| 755 | 736 |
| 756 | 737 |
| (...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1687 #undef DEF_VISIT | 1668 #undef DEF_VISIT |
| 1688 | 1669 |
| 1689 private: | 1670 private: |
| 1690 bool stack_overflow_; | 1671 bool stack_overflow_; |
| 1691 }; | 1672 }; |
| 1692 | 1673 |
| 1693 | 1674 |
| 1694 } } // namespace v8::internal | 1675 } } // namespace v8::internal |
| 1695 | 1676 |
| 1696 #endif // V8_AST_H_ | 1677 #endif // V8_AST_H_ |
| OLD | NEW |