OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_AST_AST_H_ | 5 #ifndef V8_AST_AST_H_ |
6 #define V8_AST_AST_H_ | 6 #define V8_AST_AST_H_ |
7 | 7 |
8 #include "src/ast/ast-types.h" | 8 #include "src/ast/ast-types.h" |
9 #include "src/ast/ast-value-factory.h" | 9 #include "src/ast/ast-value-factory.h" |
10 #include "src/ast/modules.h" | 10 #include "src/ast/modules.h" |
(...skipping 2771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2782 typedef ClassLiteralProperty Property; | 2782 typedef ClassLiteralProperty Property; |
2783 | 2783 |
2784 VariableProxy* class_variable_proxy() const { return class_variable_proxy_; } | 2784 VariableProxy* class_variable_proxy() const { return class_variable_proxy_; } |
2785 Expression* extends() const { return extends_; } | 2785 Expression* extends() const { return extends_; } |
2786 void set_extends(Expression* e) { extends_ = e; } | 2786 void set_extends(Expression* e) { extends_ = e; } |
2787 FunctionLiteral* constructor() const { return constructor_; } | 2787 FunctionLiteral* constructor() const { return constructor_; } |
2788 void set_constructor(FunctionLiteral* f) { constructor_ = f; } | 2788 void set_constructor(FunctionLiteral* f) { constructor_ = f; } |
2789 ZoneList<Property*>* properties() const { return properties_; } | 2789 ZoneList<Property*>* properties() const { return properties_; } |
2790 int start_position() const { return position(); } | 2790 int start_position() const { return position(); } |
2791 int end_position() const { return end_position_; } | 2791 int end_position() const { return end_position_; } |
| 2792 bool has_name_static_property() const { |
| 2793 return HasNameStaticProperty::decode(bit_field_); |
| 2794 } |
| 2795 bool has_static_computed_names() const { |
| 2796 return HasStaticComputedNames::decode(bit_field_); |
| 2797 } |
2792 | 2798 |
2793 VariableProxy* static_initializer_proxy() const { | 2799 VariableProxy* static_initializer_proxy() const { |
2794 return static_initializer_proxy_; | 2800 return static_initializer_proxy_; |
2795 } | 2801 } |
2796 void set_static_initializer_proxy(VariableProxy* proxy) { | 2802 void set_static_initializer_proxy(VariableProxy* proxy) { |
2797 static_initializer_proxy_ = proxy; | 2803 static_initializer_proxy_ = proxy; |
2798 } | 2804 } |
2799 | 2805 |
2800 // Object literals need one feedback slot for each non-trivial value, as well | 2806 // Object literals need one feedback slot for each non-trivial value, as well |
2801 // as some slots for home objects. | 2807 // as some slots for home objects. |
2802 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 2808 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
2803 FeedbackVectorSlotCache* cache); | 2809 FeedbackVectorSlotCache* cache); |
2804 | 2810 |
2805 bool NeedsProxySlot() const { | 2811 bool NeedsProxySlot() const { |
2806 return class_variable_proxy() != nullptr && | 2812 return class_variable_proxy() != nullptr && |
2807 class_variable_proxy()->var()->IsUnallocated(); | 2813 class_variable_proxy()->var()->IsUnallocated(); |
2808 } | 2814 } |
2809 | 2815 |
2810 FeedbackVectorSlot PrototypeSlot() const { return prototype_slot_; } | 2816 FeedbackVectorSlot PrototypeSlot() const { return prototype_slot_; } |
2811 FeedbackVectorSlot ProxySlot() const { return proxy_slot_; } | 2817 FeedbackVectorSlot ProxySlot() const { return proxy_slot_; } |
2812 | 2818 |
2813 private: | 2819 private: |
2814 friend class AstNodeFactory; | 2820 friend class AstNodeFactory; |
2815 | 2821 |
2816 ClassLiteral(VariableProxy* class_variable_proxy, Expression* extends, | 2822 ClassLiteral(VariableProxy* class_variable_proxy, Expression* extends, |
2817 FunctionLiteral* constructor, ZoneList<Property*>* properties, | 2823 FunctionLiteral* constructor, ZoneList<Property*>* properties, |
2818 int start_position, int end_position) | 2824 int start_position, int end_position, |
| 2825 bool has_name_static_property, bool has_static_computed_names) |
2819 : Expression(start_position, kClassLiteral), | 2826 : Expression(start_position, kClassLiteral), |
2820 end_position_(end_position), | 2827 end_position_(end_position), |
2821 class_variable_proxy_(class_variable_proxy), | 2828 class_variable_proxy_(class_variable_proxy), |
2822 extends_(extends), | 2829 extends_(extends), |
2823 constructor_(constructor), | 2830 constructor_(constructor), |
2824 properties_(properties), | 2831 properties_(properties), |
2825 static_initializer_proxy_(nullptr) {} | 2832 static_initializer_proxy_(nullptr) { |
| 2833 bit_field_ |= HasNameStaticProperty::encode(has_name_static_property) | |
| 2834 HasStaticComputedNames::encode(has_static_computed_names); |
| 2835 } |
2826 | 2836 |
2827 int end_position_; | 2837 int end_position_; |
2828 FeedbackVectorSlot prototype_slot_; | 2838 FeedbackVectorSlot prototype_slot_; |
2829 FeedbackVectorSlot proxy_slot_; | 2839 FeedbackVectorSlot proxy_slot_; |
2830 VariableProxy* class_variable_proxy_; | 2840 VariableProxy* class_variable_proxy_; |
2831 Expression* extends_; | 2841 Expression* extends_; |
2832 FunctionLiteral* constructor_; | 2842 FunctionLiteral* constructor_; |
2833 ZoneList<Property*>* properties_; | 2843 ZoneList<Property*>* properties_; |
2834 VariableProxy* static_initializer_proxy_; | 2844 VariableProxy* static_initializer_proxy_; |
| 2845 |
| 2846 class HasNameStaticProperty |
| 2847 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {}; |
| 2848 class HasStaticComputedNames |
| 2849 : public BitField<bool, HasNameStaticProperty::kNext, 1> {}; |
2835 }; | 2850 }; |
2836 | 2851 |
2837 | 2852 |
2838 class NativeFunctionLiteral final : public Expression { | 2853 class NativeFunctionLiteral final : public Expression { |
2839 public: | 2854 public: |
2840 Handle<String> name() const { return name_->string(); } | 2855 Handle<String> name() const { return name_->string(); } |
2841 v8::Extension* extension() const { return extension_; } | 2856 v8::Extension* extension() const { return extension_; } |
2842 | 2857 |
2843 private: | 2858 private: |
2844 friend class AstNodeFactory; | 2859 friend class AstNodeFactory; |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3458 ClassLiteral::Property* NewClassLiteralProperty( | 3473 ClassLiteral::Property* NewClassLiteralProperty( |
3459 Expression* key, Expression* value, ClassLiteralProperty::Kind kind, | 3474 Expression* key, Expression* value, ClassLiteralProperty::Kind kind, |
3460 bool is_static, bool is_computed_name) { | 3475 bool is_static, bool is_computed_name) { |
3461 return new (zone_) | 3476 return new (zone_) |
3462 ClassLiteral::Property(key, value, kind, is_static, is_computed_name); | 3477 ClassLiteral::Property(key, value, kind, is_static, is_computed_name); |
3463 } | 3478 } |
3464 | 3479 |
3465 ClassLiteral* NewClassLiteral(VariableProxy* proxy, Expression* extends, | 3480 ClassLiteral* NewClassLiteral(VariableProxy* proxy, Expression* extends, |
3466 FunctionLiteral* constructor, | 3481 FunctionLiteral* constructor, |
3467 ZoneList<ClassLiteral::Property*>* properties, | 3482 ZoneList<ClassLiteral::Property*>* properties, |
3468 int start_position, int end_position) { | 3483 int start_position, int end_position, |
3469 return new (zone_) ClassLiteral(proxy, extends, constructor, properties, | 3484 bool has_name_static_property, |
3470 start_position, end_position); | 3485 bool has_static_computed_names) { |
| 3486 return new (zone_) ClassLiteral( |
| 3487 proxy, extends, constructor, properties, start_position, end_position, |
| 3488 has_name_static_property, has_static_computed_names); |
3471 } | 3489 } |
3472 | 3490 |
3473 NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name, | 3491 NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name, |
3474 v8::Extension* extension, | 3492 v8::Extension* extension, |
3475 int pos) { | 3493 int pos) { |
3476 return new (zone_) NativeFunctionLiteral(name, extension, pos); | 3494 return new (zone_) NativeFunctionLiteral(name, extension, pos); |
3477 } | 3495 } |
3478 | 3496 |
3479 DoExpression* NewDoExpression(Block* block, Variable* result_var, int pos) { | 3497 DoExpression* NewDoExpression(Block* block, Variable* result_var, int pos) { |
3480 VariableProxy* result = NewVariableProxy(result_var, pos); | 3498 VariableProxy* result = NewVariableProxy(result_var, pos); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3571 : NULL; \ | 3589 : NULL; \ |
3572 } | 3590 } |
3573 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3591 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3574 #undef DECLARE_NODE_FUNCTIONS | 3592 #undef DECLARE_NODE_FUNCTIONS |
3575 | 3593 |
3576 | 3594 |
3577 } // namespace internal | 3595 } // namespace internal |
3578 } // namespace v8 | 3596 } // namespace v8 |
3579 | 3597 |
3580 #endif // V8_AST_AST_H_ | 3598 #endif // V8_AST_AST_H_ |
OLD | NEW |