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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 virtual VariableProxy* AsVariableProxy() { return NULL; } | 122 virtual VariableProxy* AsVariableProxy() { return NULL; } |
123 virtual Property* AsProperty() { return NULL; } | 123 virtual Property* AsProperty() { return NULL; } |
124 virtual Call* AsCall() { return NULL; } | 124 virtual Call* AsCall() { return NULL; } |
125 virtual TargetCollector* AsTargetCollector() { return NULL; } | 125 virtual TargetCollector* AsTargetCollector() { return NULL; } |
126 virtual BreakableStatement* AsBreakableStatement() { return NULL; } | 126 virtual BreakableStatement* AsBreakableStatement() { return NULL; } |
127 virtual IterationStatement* AsIterationStatement() { return NULL; } | 127 virtual IterationStatement* AsIterationStatement() { return NULL; } |
128 virtual UnaryOperation* AsUnaryOperation() { return NULL; } | 128 virtual UnaryOperation* AsUnaryOperation() { return NULL; } |
129 virtual BinaryOperation* AsBinaryOperation() { return NULL; } | 129 virtual BinaryOperation* AsBinaryOperation() { return NULL; } |
130 virtual Assignment* AsAssignment() { return NULL; } | 130 virtual Assignment* AsAssignment() { return NULL; } |
131 virtual FunctionLiteral* AsFunctionLiteral() { return NULL; } | 131 virtual FunctionLiteral* AsFunctionLiteral() { return NULL; } |
| 132 virtual ObjectLiteral* AsObjectLiteral() { return NULL; } |
132 | 133 |
133 void set_statement_pos(int statement_pos) { statement_pos_ = statement_pos; } | 134 void set_statement_pos(int statement_pos) { statement_pos_ = statement_pos; } |
134 int statement_pos() const { return statement_pos_; } | 135 int statement_pos() const { return statement_pos_; } |
135 | 136 |
136 private: | 137 private: |
137 int statement_pos_; | 138 int statement_pos_; |
138 }; | 139 }; |
139 | 140 |
140 | 141 |
141 class Statement: public Node { | 142 class Statement: public Node { |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 // for minimizing the work when constructing it at runtime. | 645 // for minimizing the work when constructing it at runtime. |
645 class ObjectLiteral: public MaterializedLiteral { | 646 class ObjectLiteral: public MaterializedLiteral { |
646 public: | 647 public: |
647 // Property is used for passing information | 648 // Property is used for passing information |
648 // about an object literal's properties from the parser | 649 // about an object literal's properties from the parser |
649 // to the code generator. | 650 // to the code generator. |
650 class Property: public ZoneObject { | 651 class Property: public ZoneObject { |
651 public: | 652 public: |
652 | 653 |
653 enum Kind { | 654 enum Kind { |
654 CONSTANT, // Property with constant value (at compile time). | 655 CONSTANT, // Property with constant value (at compile time). |
655 COMPUTED, // Property with computed value (at execution time). | 656 COMPUTED, // Property with computed value (at execution time). |
| 657 OBJECT_LITERAL, // Property value is an object literal. |
656 GETTER, SETTER, // Property is an accessor function. | 658 GETTER, SETTER, // Property is an accessor function. |
657 PROTOTYPE // Property is __proto__. | 659 PROTOTYPE // Property is __proto__. |
658 }; | 660 }; |
659 | 661 |
660 Property(Literal* key, Expression* value); | 662 Property(Literal* key, Expression* value); |
661 Property(bool is_getter, FunctionLiteral* value); | 663 Property(bool is_getter, FunctionLiteral* value); |
662 | 664 |
663 Literal* key() { return key_; } | 665 Literal* key() { return key_; } |
664 Expression* value() { return value_; } | 666 Expression* value() { return value_; } |
665 Kind kind() { return kind_; } | 667 Kind kind() { return kind_; } |
666 | 668 |
667 private: | 669 private: |
668 Literal* key_; | 670 Literal* key_; |
669 Expression* value_; | 671 Expression* value_; |
670 Kind kind_; | 672 Kind kind_; |
671 }; | 673 }; |
672 | 674 |
673 ObjectLiteral(Handle<FixedArray> constant_properties, | 675 ObjectLiteral(Handle<FixedArray> constant_properties, |
674 ZoneList<Property*>* properties, | 676 ZoneList<Property*>* properties, |
675 int literal_index) | 677 int literal_index, |
| 678 bool is_simple) |
676 : MaterializedLiteral(literal_index), | 679 : MaterializedLiteral(literal_index), |
677 constant_properties_(constant_properties), | 680 constant_properties_(constant_properties), |
678 properties_(properties) { | 681 properties_(properties), |
| 682 is_simple_(is_simple) { |
679 } | 683 } |
680 | 684 |
| 685 virtual ObjectLiteral* AsObjectLiteral() { return this; } |
681 virtual void Accept(AstVisitor* v); | 686 virtual void Accept(AstVisitor* v); |
682 | 687 |
683 Handle<FixedArray> constant_properties() const { | 688 Handle<FixedArray> constant_properties() const { |
684 return constant_properties_; | 689 return constant_properties_; |
685 } | 690 } |
686 ZoneList<Property*>* properties() const { return properties_; } | 691 ZoneList<Property*>* properties() const { return properties_; } |
687 | 692 |
| 693 // An object literal is simple if the values consist of only |
| 694 // constants and simple object literals. |
| 695 bool is_simple() const { return is_simple_; } |
| 696 |
688 private: | 697 private: |
689 Handle<FixedArray> constant_properties_; | 698 Handle<FixedArray> constant_properties_; |
690 ZoneList<Property*>* properties_; | 699 ZoneList<Property*>* properties_; |
| 700 bool is_simple_; |
691 }; | 701 }; |
692 | 702 |
693 | 703 |
694 // Node for capturing a regexp literal. | 704 // Node for capturing a regexp literal. |
695 class RegExpLiteral: public MaterializedLiteral { | 705 class RegExpLiteral: public MaterializedLiteral { |
696 public: | 706 public: |
697 RegExpLiteral(Handle<String> pattern, | 707 RegExpLiteral(Handle<String> pattern, |
698 Handle<String> flags, | 708 Handle<String> flags, |
699 int literal_index) | 709 int literal_index) |
700 : MaterializedLiteral(literal_index), | 710 : MaterializedLiteral(literal_index), |
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1644 #undef DEF_VISIT | 1654 #undef DEF_VISIT |
1645 | 1655 |
1646 private: | 1656 private: |
1647 bool stack_overflow_; | 1657 bool stack_overflow_; |
1648 }; | 1658 }; |
1649 | 1659 |
1650 | 1660 |
1651 } } // namespace v8::internal | 1661 } } // namespace v8::internal |
1652 | 1662 |
1653 #endif // V8_AST_H_ | 1663 #endif // V8_AST_H_ |
OLD | NEW |