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

Unified Diff: src/ast/ast.h

Issue 2315733003: Class fields, part 1 (parsing and infrastructure) (Closed)
Patch Set: Created 4 years, 3 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/ast/prettyprinter.cc » ('j') | test/cctest/test-parsing.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/ast.h
diff --git a/src/ast/ast.h b/src/ast/ast.h
index 4885379c9a60f3f0bbdb04fee9dddde2f455a1ed..007ad5d26d2c0405d8bd3e2c8b6809efc435f051 100644
--- a/src/ast/ast.h
+++ b/src/ast/ast.h
@@ -2623,6 +2623,15 @@ class FunctionLiteral final : public Expression {
int yield_count() { return yield_count_; }
void set_yield_count(int yield_count) { yield_count_ = yield_count; }
+ bool requires_class_field_init() { return requires_class_field_init_; }
+ void set_requires_class_field_init(bool requires_class_field_init) {
+ requires_class_field_init_ = requires_class_field_init;
+ }
+ bool is_class_field_initializer() { return is_class_field_initializer_; }
+ void set_is_class_field_initializer(bool is_class_field_initializer) {
+ is_class_field_initializer_ = is_class_field_initializer;
+ }
+
private:
friend class AstNodeFactory;
@@ -2645,7 +2654,9 @@ class FunctionLiteral final : public Expression {
scope_(scope),
body_(body),
raw_inferred_name_(ast_value_factory->empty_string()),
- ast_properties_(zone) {
+ ast_properties_(zone),
+ requires_class_field_init_(false),
+ is_class_field_initializer_(false) {
bitfield_ =
FunctionTypeBits::encode(function_type) | Pretenure::encode(false) |
HasDuplicateParameters::encode(has_duplicate_parameters ==
@@ -2682,13 +2693,16 @@ class FunctionLiteral final : public Expression {
const AstString* raw_inferred_name_;
Handle<String> inferred_name_;
AstProperties ast_properties_;
+
+ bool requires_class_field_init_; // TODO(bakkot) this should be a bitfield
+ bool is_class_field_initializer_; // TODO(bakkot) this should be a bitfield
Dan Ehrenberg 2016/09/06 23:55:59 As we discussed offline, it'd be nice to find thes
bakkot 2016/09/07 19:30:12 I ended up just expanding the bitfield in Function
};
// Property is used for passing information
// about a class literal's properties from the parser to the code generator.
class ClassLiteralProperty final : public LiteralProperty {
public:
- enum Kind : uint8_t { METHOD, GETTER, SETTER };
+ enum Kind : uint8_t { METHOD, GETTER, SETTER, FIELD };
Kind kind() const { return kind_; }
@@ -2717,6 +2731,13 @@ class ClassLiteral final : public Expression {
int start_position() const { return position(); }
int end_position() const { return end_position_; }
+ VariableProxy* static_initializer_proxy() const {
+ return static_initializer_proxy_;
+ }
+ void set_static_initializer_proxy(VariableProxy* proxy) {
+ static_initializer_proxy_ = proxy;
+ }
+
BailoutId CreateLiteralId() const { return BailoutId(local_id(0)); }
BailoutId PrototypeId() { return BailoutId(local_id(1)); }
@@ -2751,7 +2772,8 @@ class ClassLiteral final : public Expression {
class_variable_proxy_(class_variable_proxy),
extends_(extends),
constructor_(constructor),
- properties_(properties) {}
+ properties_(properties),
+ static_initializer_proxy_(nullptr) {}
static int parent_num_ids() { return Expression::num_ids(); }
int local_id(int n) const { return base_id() + parent_num_ids() + n; }
@@ -2763,6 +2785,7 @@ class ClassLiteral final : public Expression {
Expression* extends_;
FunctionLiteral* constructor_;
ZoneList<Property*>* properties_;
+ VariableProxy* static_initializer_proxy_; // TODO(bakkot) initialize inline
Dan Ehrenberg 2016/09/06 23:55:59 What do you mean by this TODO?
bakkot 2016/09/07 19:30:12 Sorry, that's stale. I was originally going to hav
};
« no previous file with comments | « no previous file | src/ast/prettyprinter.cc » ('j') | test/cctest/test-parsing.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698