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/hashmap.h" | 10 #include "src/hashmap.h" |
(...skipping 3291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3302 expected_property_count = function_state.expected_property_count(); | 3302 expected_property_count = function_state.expected_property_count(); |
3303 } | 3303 } |
3304 } else { | 3304 } else { |
3305 // Single-expression body | 3305 // Single-expression body |
3306 int pos = position(); | 3306 int pos = position(); |
3307 ExpressionClassifier classifier(this); | 3307 ExpressionClassifier classifier(this); |
3308 DCHECK(ReturnExprContext::kInsideValidBlock == | 3308 DCHECK(ReturnExprContext::kInsideValidBlock == |
3309 function_state_->return_expr_context()); | 3309 function_state_->return_expr_context()); |
3310 ReturnExprScope allow_tail_calls( | 3310 ReturnExprScope allow_tail_calls( |
3311 function_state_, ReturnExprContext::kInsideValidReturnStatement); | 3311 function_state_, ReturnExprContext::kInsideValidReturnStatement); |
3312 ExpressionT expression = | |
3313 ParseAssignmentExpression(accept_IN, &classifier, CHECK_OK); | |
3314 Traits::RewriteNonPattern(&classifier, CHECK_OK); | |
3315 body = this->NewStatementList(1, zone()); | 3312 body = this->NewStatementList(1, zone()); |
3316 this->AddParameterInitializationBlock(formal_parameters, body, CHECK_OK); | 3313 this->AddParameterInitializationBlock(formal_parameters, body, is_async, |
3317 body->Add(factory()->NewReturnStatement(expression, pos), zone()); | 3314 CHECK_OK); |
| 3315 if (is_async) { |
| 3316 this->ParseAsyncArrowSingleExpressionBody(body, accept_IN, &classifier, |
| 3317 pos, CHECK_OK); |
| 3318 Traits::RewriteNonPattern(&classifier, CHECK_OK); |
| 3319 } else { |
| 3320 ExpressionT expression = |
| 3321 ParseAssignmentExpression(accept_IN, &classifier, CHECK_OK); |
| 3322 Traits::RewriteNonPattern(&classifier, CHECK_OK); |
| 3323 body->Add(factory()->NewReturnStatement(expression, pos), zone()); |
| 3324 if (allow_tailcalls() && !is_sloppy(language_mode())) { |
| 3325 // ES6 14.6.1 Static Semantics: IsInTailPosition |
| 3326 this->MarkTailPosition(expression); |
| 3327 } |
| 3328 } |
3318 materialized_literal_count = function_state.materialized_literal_count(); | 3329 materialized_literal_count = function_state.materialized_literal_count(); |
3319 expected_property_count = function_state.expected_property_count(); | 3330 expected_property_count = function_state.expected_property_count(); |
3320 if (allow_tailcalls() && !is_sloppy(language_mode())) { | |
3321 // ES6 14.6.1 Static Semantics: IsInTailPosition | |
3322 this->MarkTailPosition(expression); | |
3323 } | |
3324 this->MarkCollectedTailCallExpressions(); | 3331 this->MarkCollectedTailCallExpressions(); |
3325 } | 3332 } |
3326 super_loc = function_state.super_location(); | 3333 super_loc = function_state.super_location(); |
3327 | 3334 |
3328 formal_parameters.scope->set_end_position(scanner()->location().end_pos); | 3335 formal_parameters.scope->set_end_position(scanner()->location().end_pos); |
3329 | 3336 |
3330 // Arrow function formal parameters are parsed as StrictFormalParameterList, | 3337 // Arrow function formal parameters are parsed as StrictFormalParameterList, |
3331 // which is not the same as "parameters of a strict function"; it only means | 3338 // which is not the same as "parameters of a strict function"; it only means |
3332 // that duplicates are not allowed. Of course, the arrow function may | 3339 // that duplicates are not allowed. Of course, the arrow function may |
3333 // itself be strict as well. | 3340 // itself be strict as well. |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3573 has_seen_constructor_ = true; | 3580 has_seen_constructor_ = true; |
3574 return; | 3581 return; |
3575 } | 3582 } |
3576 } | 3583 } |
3577 | 3584 |
3578 | 3585 |
3579 } // namespace internal | 3586 } // namespace internal |
3580 } // namespace v8 | 3587 } // namespace v8 |
3581 | 3588 |
3582 #endif // V8_PARSING_PARSER_BASE_H | 3589 #endif // V8_PARSING_PARSER_BASE_H |
OLD | NEW |