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

Unified Diff: src/parsing/parser-base.h

Issue 2423053002: Install the 'name' property in classes at runtime (Closed)
Patch Set: Check for 'name' properties at parse-time 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..6cbd7d414e1720757dad8fcbbf0f5c8a4f102ae8 100644
--- a/src/parsing/parser-base.h
+++ b/src/parsing/parser-base.h
@@ -690,7 +690,8 @@ 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) {}
VariableProxy* proxy;
ExpressionT extends;
typename Types::ClassPropertyList properties;
@@ -698,6 +699,7 @@ class ParserBase {
FunctionLiteralT constructor;
bool has_seen_constructor;
Variable* static_initializer_var;
+ bool has_name_static_property;
};
DeclarationScope* NewScriptScope() const {
@@ -1176,7 +1178,7 @@ 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* ok);
FunctionLiteralT ParseClassFieldForInitializer(bool has_initializer,
bool* ok);
ObjectLiteralPropertyT ParseObjectPropertyDefinition(
@@ -2139,12 +2141,11 @@ 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) {
+ParserBase<Impl>::ParseClassPropertyDefinition(
+ ClassLiteralChecker* checker, bool has_extends, bool* is_computed_name,
+ bool* has_seen_constructor, bool* has_name_static_property, bool* ok) {
DCHECK(has_seen_constructor != nullptr);
+ DCHECK(has_name_static_property != nullptr);
Toon Verwaest 2016/11/28 10:40:58 DCHECK_NOT_NULL
bool is_get = false;
bool is_set = false;
bool is_generator = false;
@@ -2178,6 +2179,10 @@ 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;
+ }
+
switch (kind) {
case PropertyKind::kClassField:
case PropertyKind::kNotSet: // This case is a name followed by a name or
@@ -4108,7 +4113,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,
+ CHECK_OK);
impl()->RewriteNonPattern(CHECK_OK);
impl()->AccumulateFormalParameterContainmentErrors();

Powered by Google App Engine
This is Rietveld 408576698