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

Unified Diff: src/parsing/parser-base.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, 1 month 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
Index: src/parsing/parser-base.h
diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h
index 25c5230d44fa70cb35e961604c5e0a1c630e2460..2b303f1219320b6a20db3ea24abcae0cebd22f0a 100644
--- a/src/parsing/parser-base.h
+++ b/src/parsing/parser-base.h
@@ -690,7 +690,9 @@ class ParserBase {
instance_field_initializers(parser->impl()->NewExpressionList(0)),
constructor(parser->impl()->EmptyFunctionLiteral()),
has_seen_constructor(false),
- static_initializer_var(nullptr) {}
+ static_initializer_var(nullptr),
+ has_name_static_property(false),
+ has_static_computed_names(false) {}
VariableProxy* proxy;
ExpressionT extends;
typename Types::ClassPropertyList properties;
@@ -698,6 +700,8 @@ class ParserBase {
FunctionLiteralT constructor;
bool has_seen_constructor;
Variable* static_initializer_var;
+ bool has_name_static_property;
+ bool has_static_computed_names;
};
DeclarationScope* NewScriptScope() const {
@@ -1176,7 +1180,8 @@ class ParserBase {
ExpressionT ParseObjectLiteral(bool* ok);
ClassLiteralPropertyT ParseClassPropertyDefinition(
ClassLiteralChecker* checker, bool has_extends, bool* is_computed_name,
- bool* has_seen_constructor, bool* ok);
+ bool* has_seen_constructor, bool* has_name_static_property,
+ bool* has_static_computed_names, bool* ok);
FunctionLiteralT ParseClassFieldForInitializer(bool has_initializer,
bool* ok);
ObjectLiteralPropertyT ParseObjectPropertyDefinition(
@@ -2139,12 +2144,13 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParsePropertyName(
template <typename Impl>
typename ParserBase<Impl>::ClassLiteralPropertyT
-ParserBase<Impl>::ParseClassPropertyDefinition(ClassLiteralChecker* checker,
- bool has_extends,
- bool* is_computed_name,
- bool* has_seen_constructor,
- bool* ok) {
- DCHECK(has_seen_constructor != nullptr);
+ParserBase<Impl>::ParseClassPropertyDefinition(
+ ClassLiteralChecker* checker, bool has_extends, bool* is_computed_name,
+ bool* has_seen_constructor, bool* has_name_static_property,
+ bool* has_static_computed_names, bool* ok) {
+ DCHECK_NOT_NULL(has_seen_constructor);
Henrique Ferreiro 2016/11/29 11:01:26 Is it ok to fix this in this CL?
Toon Verwaest 2016/11/29 12:27:47 Sure, drive-by fixes like this are entirely fine i
+ DCHECK_NOT_NULL(has_name_static_property);
+ DCHECK_NOT_NULL(has_static_computed_names);
bool is_get = false;
bool is_set = false;
bool is_generator = false;
@@ -2178,6 +2184,14 @@ ParserBase<Impl>::ParseClassPropertyDefinition(ClassLiteralChecker* checker,
is_computed_name, CHECK_OK_CUSTOM(EmptyClassLiteralProperty));
}
+ if (!*has_name_static_property && is_static && impl()->IsName(name)) {
+ *has_name_static_property = true;
+ }
+
+ if (!*has_static_computed_names && is_static && *is_computed_name) {
+ *has_static_computed_names = true;
+ }
+
switch (kind) {
case PropertyKind::kClassField:
case PropertyKind::kNotSet: // This case is a name followed by a name or
@@ -4108,7 +4122,8 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseClassLiteral(
ExpressionClassifier property_classifier(this);
ClassLiteralPropertyT property = ParseClassPropertyDefinition(
&checker, has_extends, &is_computed_name,
- &class_info.has_seen_constructor, CHECK_OK);
+ &class_info.has_seen_constructor, &class_info.has_name_static_property,
+ &class_info.has_static_computed_names, CHECK_OK);
impl()->RewriteNonPattern(CHECK_OK);
impl()->AccumulateFormalParameterContainmentErrors();

Powered by Google App Engine
This is Rietveld 408576698