Chromium Code Reviews| Index: src/parsing/parser-base.h |
| diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h |
| index 35e103cdab8fd426783f6a6ff0cbdc35efc83b5e..2f0742b5cc9e4ce61e90027ae532d32ddbc0bcc4 100644 |
| --- a/src/parsing/parser-base.h |
| +++ b/src/parsing/parser-base.h |
| @@ -2218,10 +2218,12 @@ ParserBase<Impl>::ParseClassPropertyDefinition( |
| Token::Value name_token = peek(); |
| + int function_token_position = scanner()->peek_location().beg_pos; |
| IdentifierT name = impl()->EmptyIdentifier(); |
| ExpressionT name_expression; |
| if (name_token == Token::STATIC) { |
| Consume(Token::STATIC); |
| + function_token_position = scanner()->peek_location().beg_pos; |
| if (peek() == Token::LPAREN) { |
| kind = PropertyKind::kMethodProperty; |
| name = impl()->GetSymbol(); // TODO(bakkot) specialize on 'static' |
| @@ -2298,8 +2300,10 @@ ParserBase<Impl>::ParseClassPropertyDefinition( |
| ExpressionT value = impl()->ParseFunctionLiteral( |
| name, scanner()->location(), kSkipFunctionNameCheck, kind, |
| - kNoSourcePosition, FunctionLiteral::kAccessorOrMethod, |
| - language_mode(), CHECK_OK_CUSTOM(EmptyClassLiteralProperty)); |
| + FLAG_harmony_function_tostring ? function_token_position |
| + : kNoSourcePosition, |
| + FunctionLiteral::kAccessorOrMethod, language_mode(), |
| + CHECK_OK_CUSTOM(EmptyClassLiteralProperty)); |
| *property_kind = ClassLiteralProperty::METHOD; |
| return factory()->NewClassLiteralProperty(name_expression, value, |
| @@ -2326,8 +2330,10 @@ ParserBase<Impl>::ParseClassPropertyDefinition( |
| FunctionLiteralT value = impl()->ParseFunctionLiteral( |
| name, scanner()->location(), kSkipFunctionNameCheck, kind, |
| - kNoSourcePosition, FunctionLiteral::kAccessorOrMethod, |
| - language_mode(), CHECK_OK_CUSTOM(EmptyClassLiteralProperty)); |
| + FLAG_harmony_function_tostring ? function_token_position |
| + : kNoSourcePosition, |
| + FunctionLiteral::kAccessorOrMethod, language_mode(), |
| + CHECK_OK_CUSTOM(EmptyClassLiteralProperty)); |
| if (!*is_computed_name) { |
| impl()->AddAccessorPrefixToFunctionName(is_get, value, name); |
| @@ -2522,8 +2528,9 @@ ParserBase<Impl>::ParseObjectPropertyDefinition(ObjectLiteralChecker* checker, |
| ExpressionT value = impl()->ParseFunctionLiteral( |
| name, scanner()->location(), kSkipFunctionNameCheck, kind, |
| - kNoSourcePosition, FunctionLiteral::kAccessorOrMethod, |
| - language_mode(), CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
| + FLAG_harmony_function_tostring ? next_beg_pos : kNoSourcePosition, |
| + FunctionLiteral::kAccessorOrMethod, language_mode(), |
| + CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
| return factory()->NewObjectLiteralProperty( |
| name_expression, value, ObjectLiteralProperty::COMPUTED, |
| @@ -2551,8 +2558,9 @@ ParserBase<Impl>::ParseObjectPropertyDefinition(ObjectLiteralChecker* checker, |
| FunctionLiteralT value = impl()->ParseFunctionLiteral( |
| name, scanner()->location(), kSkipFunctionNameCheck, kind, |
| - kNoSourcePosition, FunctionLiteral::kAccessorOrMethod, |
| - language_mode(), CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
| + FLAG_harmony_function_tostring ? next_beg_pos : kNoSourcePosition, |
| + FunctionLiteral::kAccessorOrMethod, language_mode(), |
| + CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
| if (!*is_computed_name) { |
| impl()->AddAccessorPrefixToFunctionName(is_get, value, name); |
| @@ -3417,7 +3425,12 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseMemberExpression( |
| Scanner::Location function_name_location = Scanner::Location::invalid(); |
| FunctionLiteral::FunctionType function_type = |
| FunctionLiteral::kAnonymousExpression; |
| - if (peek_any_identifier()) { |
| + if (impl()->ParsingDynamicFunctionDeclaration()) { |
| + // Consume and discard the next token, which is always the identifier |
| + // "anonymous". |
|
Dan Ehrenberg
2017/02/14 12:06:00
Optional: Instead of saying what this is doing (wh
|
| + Consume(Token::IDENTIFIER); |
| + DCHECK(scanner()->UnescapedLiteralMatches("anonymous", 9)); |
| + } else if (peek_any_identifier()) { |
| name = ParseIdentifierOrStrictReservedWord( |
| function_kind, &is_strict_reserved_name, CHECK_OK); |
| function_name_location = scanner()->location(); |
| @@ -4446,7 +4459,12 @@ ParserBase<Impl>::ParseAsyncFunctionLiteral(bool* ok) { |
| IdentifierT name = impl()->EmptyIdentifier(); |
| FunctionLiteral::FunctionType type = FunctionLiteral::kAnonymousExpression; |
| - if (peek_any_identifier()) { |
| + if (impl()->ParsingDynamicFunctionDeclaration()) { |
| + // Consume and discard the next token, which is always the identifier |
| + // "anonymous". |
| + Consume(Token::IDENTIFIER); |
| + DCHECK(scanner()->UnescapedLiteralMatches("anonymous", 9)); |
| + } else if (peek_any_identifier()) { |
| type = FunctionLiteral::kNamedExpression; |
| name = ParseIdentifierOrStrictReservedWord(FunctionKind::kAsyncFunction, |
| &is_strict_reserved, CHECK_OK); |