| Index: src/parsing/parser-base.h
|
| diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h
|
| index 3d486b88857fb003ec07c63f76701d8c97afec29..fd91f9878c97ee12ec5e171251d908e41bf4010f 100644
|
| --- a/src/parsing/parser-base.h
|
| +++ b/src/parsing/parser-base.h
|
| @@ -209,6 +209,7 @@ class ParserBase {
|
| scanner_(scanner),
|
| stack_overflow_(false),
|
| default_eager_compile_hint_(FunctionLiteral::kShouldLazyCompile),
|
| + function_literal_id_(0),
|
| allow_natives_(false),
|
| allow_tailcalls_(false),
|
| allow_harmony_do_expressions_(false),
|
| @@ -246,6 +247,13 @@ class ParserBase {
|
| return default_eager_compile_hint_;
|
| }
|
|
|
| + int GetNextFunctionLiteralId() { return ++function_literal_id_; }
|
| + int GetLastFunctionLiteralId() const { return function_literal_id_; }
|
| +
|
| + void SkipFunctionLiterals(int delta) { function_literal_id_ += delta; }
|
| +
|
| + void ResetFunctionLiteralId() { function_literal_id_ = 0; }
|
| +
|
| Zone* zone() const { return zone_; }
|
|
|
| protected:
|
| @@ -1149,7 +1157,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, ClassLiteralProperty::Kind* property_kind,
|
| + bool* is_static, bool* ok);
|
| FunctionLiteralT ParseClassFieldForInitializer(bool has_initializer,
|
| bool* ok);
|
| ObjectLiteralPropertyT ParseObjectPropertyDefinition(
|
| @@ -1433,6 +1442,8 @@ class ParserBase {
|
|
|
| FunctionLiteral::EagerCompileHint default_eager_compile_hint_;
|
|
|
| + int function_literal_id_;
|
| +
|
| bool allow_natives_;
|
| bool allow_tailcalls_;
|
| bool allow_harmony_do_expressions_;
|
| @@ -2107,17 +2118,17 @@ 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, ClassLiteralProperty::Kind* property_kind,
|
| + bool* is_static, bool* ok) {
|
| DCHECK(has_seen_constructor != nullptr);
|
| bool is_get = false;
|
| bool is_set = false;
|
| bool is_generator = false;
|
| bool is_async = false;
|
| - bool is_static = false;
|
| + *is_static = false;
|
| + *property_kind = ClassLiteralProperty::METHOD;
|
| PropertyKind kind = PropertyKind::kNotSet;
|
|
|
| Token::Value name_token = peek();
|
| @@ -2135,7 +2146,7 @@ ParserBase<Impl>::ParseClassPropertyDefinition(ClassLiteralChecker* checker,
|
| name = impl()->GetSymbol(); // TODO(bakkot) specialize on 'static'
|
| name_expression = factory()->NewStringLiteral(name, position());
|
| } else {
|
| - is_static = true;
|
| + *is_static = true;
|
| name_expression = ParsePropertyName(
|
| &name, &kind, &is_generator, &is_get, &is_set, &is_async,
|
| is_computed_name, CHECK_OK_CUSTOM(EmptyClassLiteralProperty));
|
| @@ -2162,9 +2173,10 @@ ParserBase<Impl>::ParseClassPropertyDefinition(ClassLiteralChecker* checker,
|
| ExpressionT function_literal = ParseClassFieldForInitializer(
|
| has_initializer, CHECK_OK_CUSTOM(EmptyClassLiteralProperty));
|
| ExpectSemicolon(CHECK_OK_CUSTOM(EmptyClassLiteralProperty));
|
| + *property_kind = ClassLiteralProperty::FIELD;
|
| return factory()->NewClassLiteralProperty(
|
| - name_expression, function_literal, ClassLiteralProperty::FIELD,
|
| - is_static, *is_computed_name);
|
| + name_expression, function_literal, *property_kind, *is_static,
|
| + *is_computed_name);
|
| } else {
|
| ReportUnexpectedToken(Next());
|
| *ok = false;
|
| @@ -2181,7 +2193,7 @@ ParserBase<Impl>::ParseClassPropertyDefinition(ClassLiteralChecker* checker,
|
| if (!*is_computed_name) {
|
| checker->CheckClassMethodName(
|
| name_token, PropertyKind::kMethodProperty, is_generator, is_async,
|
| - is_static, CHECK_OK_CUSTOM(EmptyClassLiteralProperty));
|
| + *is_static, CHECK_OK_CUSTOM(EmptyClassLiteralProperty));
|
| }
|
|
|
| FunctionKind kind = is_generator
|
| @@ -2189,7 +2201,7 @@ ParserBase<Impl>::ParseClassPropertyDefinition(ClassLiteralChecker* checker,
|
| : is_async ? FunctionKind::kAsyncConciseMethod
|
| : FunctionKind::kConciseMethod;
|
|
|
| - if (!is_static && impl()->IsConstructor(name)) {
|
| + if (!*is_static && impl()->IsConstructor(name)) {
|
| *has_seen_constructor = true;
|
| kind = has_extends ? FunctionKind::kSubclassConstructor
|
| : FunctionKind::kBaseConstructor;
|
| @@ -2200,9 +2212,10 @@ ParserBase<Impl>::ParseClassPropertyDefinition(ClassLiteralChecker* checker,
|
| kNoSourcePosition, FunctionLiteral::kAccessorOrMethod,
|
| language_mode(), CHECK_OK_CUSTOM(EmptyClassLiteralProperty));
|
|
|
| + *property_kind = ClassLiteralProperty::METHOD;
|
| return factory()->NewClassLiteralProperty(name_expression, value,
|
| - ClassLiteralProperty::METHOD,
|
| - is_static, *is_computed_name);
|
| + *property_kind, *is_static,
|
| + *is_computed_name);
|
| }
|
|
|
| case PropertyKind::kAccessorProperty: {
|
| @@ -2211,7 +2224,7 @@ ParserBase<Impl>::ParseClassPropertyDefinition(ClassLiteralChecker* checker,
|
| if (!*is_computed_name) {
|
| checker->CheckClassMethodName(
|
| name_token, PropertyKind::kAccessorProperty, false, false,
|
| - is_static, CHECK_OK_CUSTOM(EmptyClassLiteralProperty));
|
| + *is_static, CHECK_OK_CUSTOM(EmptyClassLiteralProperty));
|
| // Make sure the name expression is a string since we need a Name for
|
| // Runtime_DefineAccessorPropertyUnchecked and since we can determine
|
| // this statically we can skip the extra runtime check.
|
| @@ -2231,10 +2244,11 @@ ParserBase<Impl>::ParseClassPropertyDefinition(ClassLiteralChecker* checker,
|
| impl()->AddAccessorPrefixToFunctionName(is_get, value, name);
|
| }
|
|
|
| - return factory()->NewClassLiteralProperty(
|
| - name_expression, value,
|
| - is_get ? ClassLiteralProperty::GETTER : ClassLiteralProperty::SETTER,
|
| - is_static, *is_computed_name);
|
| + *property_kind =
|
| + is_get ? ClassLiteralProperty::GETTER : ClassLiteralProperty::SETTER;
|
| + return factory()->NewClassLiteralProperty(name_expression, value,
|
| + *property_kind, *is_static,
|
| + *is_computed_name);
|
| }
|
| }
|
| UNREACHABLE();
|
| @@ -2272,7 +2286,7 @@ ParserBase<Impl>::ParseClassFieldForInitializer(bool has_initializer,
|
| initializer_state.expected_property_count(), 0, 0,
|
| FunctionLiteral::kNoDuplicateParameters,
|
| FunctionLiteral::kAnonymousExpression, default_eager_compile_hint_,
|
| - initializer_scope->start_position(), true);
|
| + initializer_scope->start_position(), true, GetNextFunctionLiteralId());
|
| function_literal->set_is_class_field_initializer(true);
|
| return function_literal;
|
| }
|
| @@ -3910,6 +3924,7 @@ ParserBase<Impl>::ParseArrowFunctionLiteral(
|
| StatementListT body = impl()->NullStatementList();
|
| int materialized_literal_count = -1;
|
| int expected_property_count = -1;
|
| + int function_literal_id = GetNextFunctionLiteralId();
|
|
|
| FunctionKind kind = formal_parameters.scope->function_kind();
|
| FunctionLiteral::EagerCompileHint eager_compile_hint =
|
| @@ -4047,7 +4062,8 @@ ParserBase<Impl>::ParseArrowFunctionLiteral(
|
| formal_parameters.num_parameters(), formal_parameters.function_length,
|
| FunctionLiteral::kNoDuplicateParameters,
|
| FunctionLiteral::kAnonymousExpression, eager_compile_hint,
|
| - formal_parameters.scope->start_position(), has_braces);
|
| + formal_parameters.scope->start_position(), has_braces,
|
| + function_literal_id);
|
|
|
| function_literal->set_function_token_position(
|
| formal_parameters.scope->start_position());
|
| @@ -4105,14 +4121,17 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseClassLiteral(
|
| FuncNameInferrer::State fni_state(fni_);
|
| bool is_computed_name = false; // Classes do not care about computed
|
| // property names here.
|
| + bool is_static;
|
| + ClassLiteralProperty::Kind property_kind;
|
| 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, &property_kind, &is_static, CHECK_OK);
|
| impl()->RewriteNonPattern(CHECK_OK);
|
| impl()->AccumulateFormalParameterContainmentErrors();
|
|
|
| - impl()->DeclareClassProperty(name, property, &class_info, CHECK_OK);
|
| + impl()->DeclareClassProperty(name, property, property_kind, is_static,
|
| + &class_info, CHECK_OK);
|
| impl()->InferFunctionName();
|
| }
|
|
|
|
|