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 2270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2281 | 2281 |
2282 if (peek() == Token::YIELD && is_generator()) { | 2282 if (peek() == Token::YIELD && is_generator()) { |
2283 return this->ParseYieldExpression(accept_IN, classifier, ok); | 2283 return this->ParseYieldExpression(accept_IN, classifier, ok); |
2284 } | 2284 } |
2285 | 2285 |
2286 FuncNameInferrer::State fni_state(fni_); | 2286 FuncNameInferrer::State fni_state(fni_); |
2287 ParserBase<Traits>::Checkpoint checkpoint(this); | 2287 ParserBase<Traits>::Checkpoint checkpoint(this); |
2288 ExpressionClassifier arrow_formals_classifier(this, | 2288 ExpressionClassifier arrow_formals_classifier(this, |
2289 classifier->duplicate_finder()); | 2289 classifier->duplicate_finder()); |
2290 | 2290 |
| 2291 Scope::Snapshot scope_snapshot(scope()); |
| 2292 |
2291 bool is_async = allow_harmony_async_await() && peek() == Token::ASYNC && | 2293 bool is_async = allow_harmony_async_await() && peek() == Token::ASYNC && |
2292 !scanner()->HasAnyLineTerminatorAfterNext() && | 2294 !scanner()->HasAnyLineTerminatorAfterNext() && |
2293 IsValidArrowFormalParametersStart(PeekAhead()); | 2295 IsValidArrowFormalParametersStart(PeekAhead()); |
2294 | 2296 |
2295 bool parenthesized_formals = peek() == Token::LPAREN; | 2297 bool parenthesized_formals = peek() == Token::LPAREN; |
2296 if (!is_async && !parenthesized_formals) { | 2298 if (!is_async && !parenthesized_formals) { |
2297 ArrowFormalParametersUnexpectedToken(&arrow_formals_classifier); | 2299 ArrowFormalParametersUnexpectedToken(&arrow_formals_classifier); |
2298 } | 2300 } |
2299 ExpressionT expression = this->ParseConditionalExpression( | 2301 ExpressionT expression = this->ParseConditionalExpression( |
2300 accept_IN, &arrow_formals_classifier, CHECK_OK); | 2302 accept_IN, &arrow_formals_classifier, CHECK_OK); |
(...skipping 29 matching lines...) Expand all Loading... |
2330 FormalParametersT parameters(scope); | 2332 FormalParametersT parameters(scope); |
2331 if (!arrow_formals_classifier.is_simple_parameter_list()) { | 2333 if (!arrow_formals_classifier.is_simple_parameter_list()) { |
2332 scope->SetHasNonSimpleParameters(); | 2334 scope->SetHasNonSimpleParameters(); |
2333 parameters.is_simple = false; | 2335 parameters.is_simple = false; |
2334 } | 2336 } |
2335 | 2337 |
2336 checkpoint.Restore(¶meters.materialized_literals_count); | 2338 checkpoint.Restore(¶meters.materialized_literals_count); |
2337 | 2339 |
2338 scope->set_start_position(lhs_beg_pos); | 2340 scope->set_start_position(lhs_beg_pos); |
2339 Scanner::Location duplicate_loc = Scanner::Location::invalid(); | 2341 Scanner::Location duplicate_loc = Scanner::Location::invalid(); |
2340 this->ParseArrowFunctionFormalParameterList(¶meters, expression, loc, | 2342 this->ParseArrowFunctionFormalParameterList( |
2341 &duplicate_loc, CHECK_OK); | 2343 ¶meters, expression, loc, &duplicate_loc, scope_snapshot, CHECK_OK); |
2342 if (duplicate_loc.IsValid()) { | 2344 if (duplicate_loc.IsValid()) { |
2343 arrow_formals_classifier.RecordDuplicateFormalParameterError( | 2345 arrow_formals_classifier.RecordDuplicateFormalParameterError( |
2344 duplicate_loc); | 2346 duplicate_loc); |
2345 } | 2347 } |
2346 expression = this->ParseArrowFunctionLiteral( | 2348 expression = this->ParseArrowFunctionLiteral( |
2347 accept_IN, parameters, is_async, arrow_formals_classifier, CHECK_OK); | 2349 accept_IN, parameters, is_async, arrow_formals_classifier, CHECK_OK); |
2348 arrow_formals_classifier.Discard(); | 2350 arrow_formals_classifier.Discard(); |
2349 classifier->RecordPatternError(arrow_loc, | 2351 classifier->RecordPatternError(arrow_loc, |
2350 MessageTemplate::kUnexpectedToken, | 2352 MessageTemplate::kUnexpectedToken, |
2351 Token::String(Token::ARROW)); | 2353 Token::String(Token::ARROW)); |
(...skipping 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3689 has_seen_constructor_ = true; | 3691 has_seen_constructor_ = true; |
3690 return; | 3692 return; |
3691 } | 3693 } |
3692 } | 3694 } |
3693 | 3695 |
3694 | 3696 |
3695 } // namespace internal | 3697 } // namespace internal |
3696 } // namespace v8 | 3698 } // namespace v8 |
3697 | 3699 |
3698 #endif // V8_PARSING_PARSER_BASE_H | 3700 #endif // V8_PARSING_PARSER_BASE_H |
OLD | NEW |