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

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

Issue 2423053002: Install the 'name' property in classes at runtime (Closed)
Patch Set: Move computed property names check to parser and runtime function 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') | src/compiler/ast-graph-builder.cc » ('J')
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 2782 matching lines...) Expand 10 before | Expand all | Expand 10 after
2793 typedef ClassLiteralProperty Property; 2793 typedef ClassLiteralProperty Property;
2794 2794
2795 VariableProxy* class_variable_proxy() const { return class_variable_proxy_; } 2795 VariableProxy* class_variable_proxy() const { return class_variable_proxy_; }
2796 Expression* extends() const { return extends_; } 2796 Expression* extends() const { return extends_; }
2797 void set_extends(Expression* e) { extends_ = e; } 2797 void set_extends(Expression* e) { extends_ = e; }
2798 FunctionLiteral* constructor() const { return constructor_; } 2798 FunctionLiteral* constructor() const { return constructor_; }
2799 void set_constructor(FunctionLiteral* f) { constructor_ = f; } 2799 void set_constructor(FunctionLiteral* f) { constructor_ = f; }
2800 ZoneList<Property*>* properties() const { return properties_; } 2800 ZoneList<Property*>* properties() const { return properties_; }
2801 int start_position() const { return position(); } 2801 int start_position() const { return position(); }
2802 int end_position() const { return end_position_; } 2802 int end_position() const { return end_position_; }
2803 bool has_name_static_property() const {
2804 return HasNameStaticProperty::decode(bit_field_);
2805 }
2806 bool has_static_computed_names() const {
2807 return HasStaticComputedNames::decode(bit_field_);
2808 }
2803 2809
2804 VariableProxy* static_initializer_proxy() const { 2810 VariableProxy* static_initializer_proxy() const {
2805 return static_initializer_proxy_; 2811 return static_initializer_proxy_;
2806 } 2812 }
2807 void set_static_initializer_proxy(VariableProxy* proxy) { 2813 void set_static_initializer_proxy(VariableProxy* proxy) {
2808 static_initializer_proxy_ = proxy; 2814 static_initializer_proxy_ = proxy;
2809 } 2815 }
2810 2816
2811 BailoutId CreateLiteralId() const { return BailoutId(local_id(0)); } 2817 BailoutId CreateLiteralId() const { return BailoutId(local_id(0)); }
2812 BailoutId PrototypeId() { return BailoutId(local_id(1)); } 2818 BailoutId PrototypeId() { return BailoutId(local_id(1)); }
(...skipping 16 matching lines...) Expand all
2829 } 2835 }
2830 2836
2831 FeedbackVectorSlot PrototypeSlot() const { return prototype_slot_; } 2837 FeedbackVectorSlot PrototypeSlot() const { return prototype_slot_; }
2832 FeedbackVectorSlot ProxySlot() const { return proxy_slot_; } 2838 FeedbackVectorSlot ProxySlot() const { return proxy_slot_; }
2833 2839
2834 private: 2840 private:
2835 friend class AstNodeFactory; 2841 friend class AstNodeFactory;
2836 2842
2837 ClassLiteral(VariableProxy* class_variable_proxy, Expression* extends, 2843 ClassLiteral(VariableProxy* class_variable_proxy, Expression* extends,
2838 FunctionLiteral* constructor, ZoneList<Property*>* properties, 2844 FunctionLiteral* constructor, ZoneList<Property*>* properties,
2839 int start_position, int end_position) 2845 int start_position, int end_position,
2846 bool has_name_static_property, bool has_static_computed_names)
2840 : Expression(start_position, kClassLiteral), 2847 : Expression(start_position, kClassLiteral),
2841 end_position_(end_position), 2848 end_position_(end_position),
2842 class_variable_proxy_(class_variable_proxy), 2849 class_variable_proxy_(class_variable_proxy),
2843 extends_(extends), 2850 extends_(extends),
2844 constructor_(constructor), 2851 constructor_(constructor),
2845 properties_(properties), 2852 properties_(properties),
2846 static_initializer_proxy_(nullptr) {} 2853 static_initializer_proxy_(nullptr) {
2854 bit_field_ |=
2855 HasNameStaticProperty::update(bit_field_, has_name_static_property) |
Toon Verwaest 2016/11/29 12:27:47 HasNameStaticProperty::encode(has_name_static_prop
2856 HasStaticComputedNames::update(bit_field_, has_static_computed_names);
2857 }
2847 2858
2848 static int parent_num_ids() { return Expression::num_ids(); } 2859 static int parent_num_ids() { return Expression::num_ids(); }
2849 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 2860 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2850 2861
2851 int end_position_; 2862 int end_position_;
2852 FeedbackVectorSlot prototype_slot_; 2863 FeedbackVectorSlot prototype_slot_;
2853 FeedbackVectorSlot proxy_slot_; 2864 FeedbackVectorSlot proxy_slot_;
2854 VariableProxy* class_variable_proxy_; 2865 VariableProxy* class_variable_proxy_;
2855 Expression* extends_; 2866 Expression* extends_;
2856 FunctionLiteral* constructor_; 2867 FunctionLiteral* constructor_;
2857 ZoneList<Property*>* properties_; 2868 ZoneList<Property*>* properties_;
2858 VariableProxy* static_initializer_proxy_; 2869 VariableProxy* static_initializer_proxy_;
2870
2871 class HasNameStaticProperty
2872 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {};
2873 class HasStaticComputedNames
2874 : public BitField<bool, HasNameStaticProperty::kNext, 1> {};
2859 }; 2875 };
2860 2876
2861 2877
2862 class NativeFunctionLiteral final : public Expression { 2878 class NativeFunctionLiteral final : public Expression {
2863 public: 2879 public:
2864 Handle<String> name() const { return name_->string(); } 2880 Handle<String> name() const { return name_->string(); }
2865 v8::Extension* extension() const { return extension_; } 2881 v8::Extension* extension() const { return extension_; }
2866 2882
2867 private: 2883 private:
2868 friend class AstNodeFactory; 2884 friend class AstNodeFactory;
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
3485 ClassLiteral::Property* NewClassLiteralProperty( 3501 ClassLiteral::Property* NewClassLiteralProperty(
3486 Expression* key, Expression* value, ClassLiteralProperty::Kind kind, 3502 Expression* key, Expression* value, ClassLiteralProperty::Kind kind,
3487 bool is_static, bool is_computed_name) { 3503 bool is_static, bool is_computed_name) {
3488 return new (zone_) 3504 return new (zone_)
3489 ClassLiteral::Property(key, value, kind, is_static, is_computed_name); 3505 ClassLiteral::Property(key, value, kind, is_static, is_computed_name);
3490 } 3506 }
3491 3507
3492 ClassLiteral* NewClassLiteral(VariableProxy* proxy, Expression* extends, 3508 ClassLiteral* NewClassLiteral(VariableProxy* proxy, Expression* extends,
3493 FunctionLiteral* constructor, 3509 FunctionLiteral* constructor,
3494 ZoneList<ClassLiteral::Property*>* properties, 3510 ZoneList<ClassLiteral::Property*>* properties,
3495 int start_position, int end_position) { 3511 int start_position, int end_position,
3496 return new (zone_) ClassLiteral(proxy, extends, constructor, properties, 3512 bool has_name_static_property,
3497 start_position, end_position); 3513 bool has_static_computed_names) {
3514 return new (zone_) ClassLiteral(
3515 proxy, extends, constructor, properties, start_position, end_position,
3516 has_name_static_property, has_static_computed_names);
3498 } 3517 }
3499 3518
3500 NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name, 3519 NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name,
3501 v8::Extension* extension, 3520 v8::Extension* extension,
3502 int pos) { 3521 int pos) {
3503 return new (zone_) NativeFunctionLiteral(name, extension, pos); 3522 return new (zone_) NativeFunctionLiteral(name, extension, pos);
3504 } 3523 }
3505 3524
3506 DoExpression* NewDoExpression(Block* block, Variable* result_var, int pos) { 3525 DoExpression* NewDoExpression(Block* block, Variable* result_var, int pos) {
3507 VariableProxy* result = NewVariableProxy(result_var, pos); 3526 VariableProxy* result = NewVariableProxy(result_var, pos);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
3598 : NULL; \ 3617 : NULL; \
3599 } 3618 }
3600 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 3619 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
3601 #undef DECLARE_NODE_FUNCTIONS 3620 #undef DECLARE_NODE_FUNCTIONS
3602 3621
3603 3622
3604 } // namespace internal 3623 } // namespace internal
3605 } // namespace v8 3624 } // namespace v8
3606 3625
3607 #endif // V8_AST_AST_H_ 3626 #endif // V8_AST_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast/ast-value-factory.h » ('j') | src/compiler/ast-graph-builder.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698