| 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 2276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2287 | 2287 |
| 2288 if (peek() == Token::YIELD && is_generator()) { | 2288 if (peek() == Token::YIELD && is_generator()) { |
| 2289 return this->ParseYieldExpression(accept_IN, classifier, ok); | 2289 return this->ParseYieldExpression(accept_IN, classifier, ok); |
| 2290 } | 2290 } |
| 2291 | 2291 |
| 2292 FuncNameInferrer::State fni_state(fni_); | 2292 FuncNameInferrer::State fni_state(fni_); |
| 2293 ParserBase<Traits>::Checkpoint checkpoint(this); | 2293 ParserBase<Traits>::Checkpoint checkpoint(this); |
| 2294 ExpressionClassifier arrow_formals_classifier(this, | 2294 ExpressionClassifier arrow_formals_classifier(this, |
| 2295 classifier->duplicate_finder()); | 2295 classifier->duplicate_finder()); |
| 2296 | 2296 |
| 2297 Scope::Snapshot scope_snapshot(scope()); |
| 2298 |
| 2297 bool is_async = allow_harmony_async_await() && peek() == Token::ASYNC && | 2299 bool is_async = allow_harmony_async_await() && peek() == Token::ASYNC && |
| 2298 !scanner()->HasAnyLineTerminatorAfterNext() && | 2300 !scanner()->HasAnyLineTerminatorAfterNext() && |
| 2299 IsValidArrowFormalParametersStart(PeekAhead()); | 2301 IsValidArrowFormalParametersStart(PeekAhead()); |
| 2300 | 2302 |
| 2301 bool parenthesized_formals = peek() == Token::LPAREN; | 2303 bool parenthesized_formals = peek() == Token::LPAREN; |
| 2302 if (!is_async && !parenthesized_formals) { | 2304 if (!is_async && !parenthesized_formals) { |
| 2303 ArrowFormalParametersUnexpectedToken(&arrow_formals_classifier); | 2305 ArrowFormalParametersUnexpectedToken(&arrow_formals_classifier); |
| 2304 } | 2306 } |
| 2305 ExpressionT expression = this->ParseConditionalExpression( | 2307 ExpressionT expression = this->ParseConditionalExpression( |
| 2306 accept_IN, &arrow_formals_classifier, CHECK_OK); | 2308 accept_IN, &arrow_formals_classifier, CHECK_OK); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2336 FormalParametersT parameters(scope); | 2338 FormalParametersT parameters(scope); |
| 2337 if (!arrow_formals_classifier.is_simple_parameter_list()) { | 2339 if (!arrow_formals_classifier.is_simple_parameter_list()) { |
| 2338 scope->SetHasNonSimpleParameters(); | 2340 scope->SetHasNonSimpleParameters(); |
| 2339 parameters.is_simple = false; | 2341 parameters.is_simple = false; |
| 2340 } | 2342 } |
| 2341 | 2343 |
| 2342 checkpoint.Restore(¶meters.materialized_literals_count); | 2344 checkpoint.Restore(¶meters.materialized_literals_count); |
| 2343 | 2345 |
| 2344 scope->set_start_position(lhs_beg_pos); | 2346 scope->set_start_position(lhs_beg_pos); |
| 2345 Scanner::Location duplicate_loc = Scanner::Location::invalid(); | 2347 Scanner::Location duplicate_loc = Scanner::Location::invalid(); |
| 2346 this->ParseArrowFunctionFormalParameterList(¶meters, expression, loc, | 2348 this->ParseArrowFunctionFormalParameterList( |
| 2347 &duplicate_loc, CHECK_OK); | 2349 ¶meters, expression, loc, &duplicate_loc, scope_snapshot, CHECK_OK); |
| 2348 if (duplicate_loc.IsValid()) { | 2350 if (duplicate_loc.IsValid()) { |
| 2349 arrow_formals_classifier.RecordDuplicateFormalParameterError( | 2351 arrow_formals_classifier.RecordDuplicateFormalParameterError( |
| 2350 duplicate_loc); | 2352 duplicate_loc); |
| 2351 } | 2353 } |
| 2352 expression = this->ParseArrowFunctionLiteral( | 2354 expression = this->ParseArrowFunctionLiteral( |
| 2353 accept_IN, parameters, is_async, arrow_formals_classifier, CHECK_OK); | 2355 accept_IN, parameters, is_async, arrow_formals_classifier, CHECK_OK); |
| 2354 arrow_formals_classifier.Discard(); | 2356 arrow_formals_classifier.Discard(); |
| 2355 classifier->RecordPatternError(arrow_loc, | 2357 classifier->RecordPatternError(arrow_loc, |
| 2356 MessageTemplate::kUnexpectedToken, | 2358 MessageTemplate::kUnexpectedToken, |
| 2357 Token::String(Token::ARROW)); | 2359 Token::String(Token::ARROW)); |
| (...skipping 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3696 has_seen_constructor_ = true; | 3698 has_seen_constructor_ = true; |
| 3697 return; | 3699 return; |
| 3698 } | 3700 } |
| 3699 } | 3701 } |
| 3700 | 3702 |
| 3701 | 3703 |
| 3702 } // namespace internal | 3704 } // namespace internal |
| 3703 } // namespace v8 | 3705 } // namespace v8 |
| 3704 | 3706 |
| 3705 #endif // V8_PARSING_PARSER_BASE_H | 3707 #endif // V8_PARSING_PARSER_BASE_H |
| OLD | NEW |