OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_PARSING_PARSER_BASE_H | 5 #ifndef V8_PARSING_PARSER_BASE_H |
6 #define V8_PARSING_PARSER_BASE_H | 6 #define V8_PARSING_PARSER_BASE_H |
7 | 7 |
8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
10 #include "src/base/hashmap.h" | 10 #include "src/base/hashmap.h" |
(...skipping 2309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2320 expression = this->ParseConditionalExpression( | 2320 expression = this->ParseConditionalExpression( |
2321 accept_IN, &arrow_formals_classifier, CHECK_OK); | 2321 accept_IN, &arrow_formals_classifier, CHECK_OK); |
2322 } | 2322 } |
2323 | 2323 |
2324 if (is_async && peek_any_identifier() && PeekAhead() == Token::ARROW) { | 2324 if (is_async && peek_any_identifier() && PeekAhead() == Token::ARROW) { |
2325 // async Identifier => AsyncConciseBody | 2325 // async Identifier => AsyncConciseBody |
2326 IdentifierT name = | 2326 IdentifierT name = |
2327 ParseAndClassifyIdentifier(&arrow_formals_classifier, CHECK_OK); | 2327 ParseAndClassifyIdentifier(&arrow_formals_classifier, CHECK_OK); |
2328 expression = this->ExpressionFromIdentifier(name, position(), | 2328 expression = this->ExpressionFromIdentifier(name, position(), |
2329 scanner()->location().end_pos); | 2329 scanner()->location().end_pos); |
2330 if (fni_) { | |
2331 // Remove `async` and the argument name from the inferred name. | |
2332 fni_->RemoveLastName(); | |
2333 fni_->RemoveLastName(); | |
Dan Ehrenberg
2016/08/12 00:39:21
I'm surprised that you have to remove two names he
caitp
2016/08/12 01:12:27
well, the `async` is removed on line 2896. As for
| |
2334 } | |
2330 } | 2335 } |
2331 | 2336 |
2332 if (peek() == Token::ARROW) { | 2337 if (peek() == Token::ARROW) { |
2333 Scanner::Location arrow_loc = scanner()->peek_location(); | 2338 Scanner::Location arrow_loc = scanner()->peek_location(); |
2334 ValidateArrowFormalParameters(&arrow_formals_classifier, expression, | 2339 ValidateArrowFormalParameters(&arrow_formals_classifier, expression, |
2335 parenthesized_formals, is_async, CHECK_OK); | 2340 parenthesized_formals, is_async, CHECK_OK); |
2336 // This reads strangely, but is correct: it checks whether any | 2341 // This reads strangely, but is correct: it checks whether any |
2337 // sub-expression of the parameter list failed to be a valid formal | 2342 // sub-expression of the parameter list failed to be a valid formal |
2338 // parameter initializer. Since YieldExpressions are banned anywhere | 2343 // parameter initializer. Since YieldExpressions are banned anywhere |
2339 // in an arrow parameter list, this is correct. | 2344 // in an arrow parameter list, this is correct. |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2876 // Also the trailing parenthesis are a hint that the function will | 2881 // Also the trailing parenthesis are a hint that the function will |
2877 // be called immediately. If we happen to have parsed a preceding | 2882 // be called immediately. If we happen to have parsed a preceding |
2878 // function literal eagerly, we can also compile it eagerly. | 2883 // function literal eagerly, we can also compile it eagerly. |
2879 if (result->IsFunctionLiteral() && mode() == PARSE_EAGERLY) { | 2884 if (result->IsFunctionLiteral() && mode() == PARSE_EAGERLY) { |
2880 result->AsFunctionLiteral()->set_should_eager_compile(); | 2885 result->AsFunctionLiteral()->set_should_eager_compile(); |
2881 } | 2886 } |
2882 } | 2887 } |
2883 Scanner::Location spread_pos; | 2888 Scanner::Location spread_pos; |
2884 typename Traits::Type::ExpressionList args; | 2889 typename Traits::Type::ExpressionList args; |
2885 if (V8_UNLIKELY(is_async)) { | 2890 if (V8_UNLIKELY(is_async)) { |
2891 int async_index = fni_ ? fni_->LastNameIndex() : -1; | |
2886 ExpressionClassifier async_classifier(this); | 2892 ExpressionClassifier async_classifier(this); |
2887 args = ParseArguments(&spread_pos, true, &async_classifier, CHECK_OK); | 2893 args = ParseArguments(&spread_pos, true, &async_classifier, CHECK_OK); |
2888 if (peek() == Token::ARROW) { | 2894 if (peek() == Token::ARROW) { |
2895 if (fni_) { | |
2896 fni_->RemoveNameAtIndex(async_index); | |
2897 } | |
2889 ValidateBindingPattern(&async_classifier, CHECK_OK); | 2898 ValidateBindingPattern(&async_classifier, CHECK_OK); |
2890 if (!async_classifier.is_valid_async_arrow_formal_parameters()) { | 2899 if (!async_classifier.is_valid_async_arrow_formal_parameters()) { |
2891 ReportClassifierError( | 2900 ReportClassifierError( |
2892 async_classifier.async_arrow_formal_parameters_error()); | 2901 async_classifier.async_arrow_formal_parameters_error()); |
2893 *ok = false; | 2902 *ok = false; |
2894 return this->EmptyExpression(); | 2903 return this->EmptyExpression(); |
2895 } | 2904 } |
2896 if (args->length()) { | 2905 if (args->length()) { |
2897 // async ( Arguments ) => ... | 2906 // async ( Arguments ) => ... |
2898 return Traits::ExpressionListToExpression(args); | 2907 return Traits::ExpressionListToExpression(args); |
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3722 has_seen_constructor_ = true; | 3731 has_seen_constructor_ = true; |
3723 return; | 3732 return; |
3724 } | 3733 } |
3725 } | 3734 } |
3726 | 3735 |
3727 | 3736 |
3728 } // namespace internal | 3737 } // namespace internal |
3729 } // namespace v8 | 3738 } // namespace v8 |
3730 | 3739 |
3731 #endif // V8_PARSING_PARSER_BASE_H | 3740 #endif // V8_PARSING_PARSER_BASE_H |
OLD | NEW |