Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: src/ast/ast.h

Issue 2423053002: Install the 'name' property in classes at runtime (Closed)
Patch Set: rebased Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/ast/ast-value-factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2769 matching lines...) Expand 10 before | Expand all | Expand 10 after
2780 typedef ClassLiteralProperty Property; 2780 typedef ClassLiteralProperty Property;
2781 2781
2782 VariableProxy* class_variable_proxy() const { return class_variable_proxy_; } 2782 VariableProxy* class_variable_proxy() const { return class_variable_proxy_; }
2783 Expression* extends() const { return extends_; } 2783 Expression* extends() const { return extends_; }
2784 void set_extends(Expression* e) { extends_ = e; } 2784 void set_extends(Expression* e) { extends_ = e; }
2785 FunctionLiteral* constructor() const { return constructor_; } 2785 FunctionLiteral* constructor() const { return constructor_; }
2786 void set_constructor(FunctionLiteral* f) { constructor_ = f; } 2786 void set_constructor(FunctionLiteral* f) { constructor_ = f; }
2787 ZoneList<Property*>* properties() const { return properties_; } 2787 ZoneList<Property*>* properties() const { return properties_; }
2788 int start_position() const { return position(); } 2788 int start_position() const { return position(); }
2789 int end_position() const { return end_position_; } 2789 int end_position() const { return end_position_; }
2790 bool has_name_static_property() const {
2791 return HasNameStaticProperty::decode(bit_field_);
2792 }
2793 bool has_static_computed_names() const {
2794 return HasStaticComputedNames::decode(bit_field_);
2795 }
2790 2796
2791 VariableProxy* static_initializer_proxy() const { 2797 VariableProxy* static_initializer_proxy() const {
2792 return static_initializer_proxy_; 2798 return static_initializer_proxy_;
2793 } 2799 }
2794 void set_static_initializer_proxy(VariableProxy* proxy) { 2800 void set_static_initializer_proxy(VariableProxy* proxy) {
2795 static_initializer_proxy_ = proxy; 2801 static_initializer_proxy_ = proxy;
2796 } 2802 }
2797 2803
2798 // Object literals need one feedback slot for each non-trivial value, as well 2804 // Object literals need one feedback slot for each non-trivial value, as well
2799 // as some slots for home objects. 2805 // as some slots for home objects.
2800 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, 2806 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
2801 FeedbackVectorSlotCache* cache); 2807 FeedbackVectorSlotCache* cache);
2802 2808
2803 bool NeedsProxySlot() const { 2809 bool NeedsProxySlot() const {
2804 return class_variable_proxy() != nullptr && 2810 return class_variable_proxy() != nullptr &&
2805 class_variable_proxy()->var()->IsUnallocated(); 2811 class_variable_proxy()->var()->IsUnallocated();
2806 } 2812 }
2807 2813
2808 FeedbackVectorSlot PrototypeSlot() const { return prototype_slot_; } 2814 FeedbackVectorSlot PrototypeSlot() const { return prototype_slot_; }
2809 FeedbackVectorSlot ProxySlot() const { return proxy_slot_; } 2815 FeedbackVectorSlot ProxySlot() const { return proxy_slot_; }
2810 2816
2811 private: 2817 private:
2812 friend class AstNodeFactory; 2818 friend class AstNodeFactory;
2813 2819
2814 ClassLiteral(VariableProxy* class_variable_proxy, Expression* extends, 2820 ClassLiteral(VariableProxy* class_variable_proxy, Expression* extends,
2815 FunctionLiteral* constructor, ZoneList<Property*>* properties, 2821 FunctionLiteral* constructor, ZoneList<Property*>* properties,
2816 int start_position, int end_position) 2822 int start_position, int end_position,
2823 bool has_name_static_property, bool has_static_computed_names)
2817 : Expression(start_position, kClassLiteral), 2824 : Expression(start_position, kClassLiteral),
2818 end_position_(end_position), 2825 end_position_(end_position),
2819 class_variable_proxy_(class_variable_proxy), 2826 class_variable_proxy_(class_variable_proxy),
2820 extends_(extends), 2827 extends_(extends),
2821 constructor_(constructor), 2828 constructor_(constructor),
2822 properties_(properties), 2829 properties_(properties),
2823 static_initializer_proxy_(nullptr) {} 2830 static_initializer_proxy_(nullptr) {
2831 bit_field_ |= HasNameStaticProperty::encode(has_name_static_property) |
2832 HasStaticComputedNames::encode(has_static_computed_names);
2833 }
2824 2834
2825 int end_position_; 2835 int end_position_;
2826 FeedbackVectorSlot prototype_slot_; 2836 FeedbackVectorSlot prototype_slot_;
2827 FeedbackVectorSlot proxy_slot_; 2837 FeedbackVectorSlot proxy_slot_;
2828 VariableProxy* class_variable_proxy_; 2838 VariableProxy* class_variable_proxy_;
2829 Expression* extends_; 2839 Expression* extends_;
2830 FunctionLiteral* constructor_; 2840 FunctionLiteral* constructor_;
2831 ZoneList<Property*>* properties_; 2841 ZoneList<Property*>* properties_;
2832 VariableProxy* static_initializer_proxy_; 2842 VariableProxy* static_initializer_proxy_;
2843
2844 class HasNameStaticProperty
2845 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {};
2846 class HasStaticComputedNames
2847 : public BitField<bool, HasNameStaticProperty::kNext, 1> {};
2833 }; 2848 };
2834 2849
2835 2850
2836 class NativeFunctionLiteral final : public Expression { 2851 class NativeFunctionLiteral final : public Expression {
2837 public: 2852 public:
2838 Handle<String> name() const { return name_->string(); } 2853 Handle<String> name() const { return name_->string(); }
2839 v8::Extension* extension() const { return extension_; } 2854 v8::Extension* extension() const { return extension_; }
2840 2855
2841 private: 2856 private:
2842 friend class AstNodeFactory; 2857 friend class AstNodeFactory;
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
3456 ClassLiteral::Property* NewClassLiteralProperty( 3471 ClassLiteral::Property* NewClassLiteralProperty(
3457 Expression* key, Expression* value, ClassLiteralProperty::Kind kind, 3472 Expression* key, Expression* value, ClassLiteralProperty::Kind kind,
3458 bool is_static, bool is_computed_name) { 3473 bool is_static, bool is_computed_name) {
3459 return new (zone_) 3474 return new (zone_)
3460 ClassLiteral::Property(key, value, kind, is_static, is_computed_name); 3475 ClassLiteral::Property(key, value, kind, is_static, is_computed_name);
3461 } 3476 }
3462 3477
3463 ClassLiteral* NewClassLiteral(VariableProxy* proxy, Expression* extends, 3478 ClassLiteral* NewClassLiteral(VariableProxy* proxy, Expression* extends,
3464 FunctionLiteral* constructor, 3479 FunctionLiteral* constructor,
3465 ZoneList<ClassLiteral::Property*>* properties, 3480 ZoneList<ClassLiteral::Property*>* properties,
3466 int start_position, int end_position) { 3481 int start_position, int end_position,
3467 return new (zone_) ClassLiteral(proxy, extends, constructor, properties, 3482 bool has_name_static_property,
3468 start_position, end_position); 3483 bool has_static_computed_names) {
3484 return new (zone_) ClassLiteral(
3485 proxy, extends, constructor, properties, start_position, end_position,
3486 has_name_static_property, has_static_computed_names);
3469 } 3487 }
3470 3488
3471 NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name, 3489 NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name,
3472 v8::Extension* extension, 3490 v8::Extension* extension,
3473 int pos) { 3491 int pos) {
3474 return new (zone_) NativeFunctionLiteral(name, extension, pos); 3492 return new (zone_) NativeFunctionLiteral(name, extension, pos);
3475 } 3493 }
3476 3494
3477 DoExpression* NewDoExpression(Block* block, Variable* result_var, int pos) { 3495 DoExpression* NewDoExpression(Block* block, Variable* result_var, int pos) {
3478 VariableProxy* result = NewVariableProxy(result_var, pos); 3496 VariableProxy* result = NewVariableProxy(result_var, pos);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
3569 : NULL; \ 3587 : NULL; \
3570 } 3588 }
3571 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 3589 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
3572 #undef DECLARE_NODE_FUNCTIONS 3590 #undef DECLARE_NODE_FUNCTIONS
3573 3591
3574 3592
3575 } // namespace internal 3593 } // namespace internal
3576 } // namespace v8 3594 } // namespace v8
3577 3595
3578 #endif // V8_AST_AST_H_ 3596 #endif // V8_AST_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast/ast-value-factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698