| 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 #include "src/parsing/parser.h" | 5 #include "src/parsing/parser.h" |
| 6 | 6 |
| 7 #include "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
| 9 #include "src/ast/ast-expression-rewriter.h" | 9 #include "src/ast/ast-expression-rewriter.h" |
| 10 #include "src/ast/ast-expression-visitor.h" | 10 #include "src/ast/ast-expression-visitor.h" |
| (...skipping 2621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2632 | 2632 |
| 2633 // is_undefined ? this : is_object_conditional | 2633 // is_undefined ? this : is_object_conditional |
| 2634 return_value = factory()->NewConditional( | 2634 return_value = factory()->NewConditional( |
| 2635 is_undefined, ThisExpression(scope_, factory(), pos), | 2635 is_undefined, ThisExpression(scope_, factory(), pos), |
| 2636 is_object_conditional, pos); | 2636 is_object_conditional, pos); |
| 2637 } | 2637 } |
| 2638 | 2638 |
| 2639 // TODO(ishell): update chapter number. | 2639 // TODO(ishell): update chapter number. |
| 2640 // ES8 XX.YY.ZZ | 2640 // ES8 XX.YY.ZZ |
| 2641 if (tail_call_position >= 0) { | 2641 if (tail_call_position >= 0) { |
| 2642 if (!function_state_->collect_expressions_in_tail_position()) { | 2642 ReturnExprContext return_expr_context = |
| 2643 Scanner::Location loc(tail_call_position, tail_call_position + 1); | 2643 function_state_->return_expr_context(); |
| 2644 ReportMessageAt(loc, MessageTemplate::kTailCallInTryBlock); | 2644 if (return_expr_context != ReturnExprContext::kNormal) { |
| 2645 ReportIllegalTailCallAt(tail_call_position, return_expr_context); |
| 2645 *ok = false; | 2646 *ok = false; |
| 2646 return NULL; | 2647 return NULL; |
| 2647 } | 2648 } |
| 2648 function_state_->AddExpressionInTailPosition(return_value, | 2649 function_state_->AddExpressionInTailPosition(return_value, |
| 2649 tail_call_position); | 2650 tail_call_position); |
| 2650 | 2651 |
| 2651 } else if (allow_tailcalls() && !is_sloppy(language_mode())) { | 2652 } else if (allow_tailcalls() && !is_sloppy(language_mode())) { |
| 2652 // ES6 14.6.1 Static Semantics: IsInTailPosition | 2653 // ES6 14.6.1 Static Semantics: IsInTailPosition |
| 2653 function_state_->AddExpressionInTailPosition(return_value, pos); | 2654 function_state_->AddExpressionInTailPosition(return_value, pos); |
| 2654 } | 2655 } |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2841 // 'catch' '(' Identifier ')' Block | 2842 // 'catch' '(' Identifier ')' Block |
| 2842 // | 2843 // |
| 2843 // Finally :: | 2844 // Finally :: |
| 2844 // 'finally' Block | 2845 // 'finally' Block |
| 2845 | 2846 |
| 2846 Expect(Token::TRY, CHECK_OK); | 2847 Expect(Token::TRY, CHECK_OK); |
| 2847 int pos = position(); | 2848 int pos = position(); |
| 2848 | 2849 |
| 2849 Block* try_block; | 2850 Block* try_block; |
| 2850 { | 2851 { |
| 2851 DontCollectExpressionsInTailPositionScope no_tail_calls(function_state_); | 2852 ReturnExprScope no_tail_calls(function_state_, |
| 2853 ReturnExprContext::kInsideTryBlock); |
| 2852 try_block = ParseBlock(NULL, CHECK_OK); | 2854 try_block = ParseBlock(NULL, CHECK_OK); |
| 2853 } | 2855 } |
| 2854 | 2856 |
| 2855 Token::Value tok = peek(); | 2857 Token::Value tok = peek(); |
| 2856 if (tok != Token::CATCH && tok != Token::FINALLY) { | 2858 if (tok != Token::CATCH && tok != Token::FINALLY) { |
| 2857 ReportMessage(MessageTemplate::kNoCatchOrFinally); | 2859 ReportMessage(MessageTemplate::kNoCatchOrFinally); |
| 2858 *ok = false; | 2860 *ok = false; |
| 2859 return NULL; | 2861 return NULL; |
| 2860 } | 2862 } |
| 2861 | 2863 |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3548 | 3550 |
| 3549 Expect(Token::RPAREN, CHECK_OK); | 3551 Expect(Token::RPAREN, CHECK_OK); |
| 3550 | 3552 |
| 3551 Scope* body_scope = NewScope(scope_, BLOCK_SCOPE); | 3553 Scope* body_scope = NewScope(scope_, BLOCK_SCOPE); |
| 3552 body_scope->set_start_position(scanner()->location().beg_pos); | 3554 body_scope->set_start_position(scanner()->location().beg_pos); |
| 3553 | 3555 |
| 3554 Block* body_block = | 3556 Block* body_block = |
| 3555 factory()->NewBlock(NULL, 3, false, RelocInfo::kNoPosition); | 3557 factory()->NewBlock(NULL, 3, false, RelocInfo::kNoPosition); |
| 3556 | 3558 |
| 3557 { | 3559 { |
| 3558 DontCollectExpressionsInTailPositionScope no_tail_calls( | 3560 ReturnExprScope no_tail_calls(function_state_, |
| 3559 function_state_); | 3561 ReturnExprContext::kInsideForInOfBody); |
| 3560 BlockState block_state(&scope_, body_scope); | 3562 BlockState block_state(&scope_, body_scope); |
| 3561 | 3563 |
| 3562 Statement* body = ParseScopedStatement(NULL, true, CHECK_OK); | 3564 Statement* body = ParseScopedStatement(NULL, true, CHECK_OK); |
| 3563 | 3565 |
| 3564 auto each_initialization_block = | 3566 auto each_initialization_block = |
| 3565 factory()->NewBlock(nullptr, 1, true, RelocInfo::kNoPosition); | 3567 factory()->NewBlock(nullptr, 1, true, RelocInfo::kNoPosition); |
| 3566 { | 3568 { |
| 3567 auto descriptor = parsing_result.descriptor; | 3569 auto descriptor = parsing_result.descriptor; |
| 3568 descriptor.declaration_pos = RelocInfo::kNoPosition; | 3570 descriptor.declaration_pos = RelocInfo::kNoPosition; |
| 3569 descriptor.initialization_pos = RelocInfo::kNoPosition; | 3571 descriptor.initialization_pos = RelocInfo::kNoPosition; |
| (...skipping 3223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6793 try_block, target); | 6795 try_block, target); |
| 6794 final_loop = target; | 6796 final_loop = target; |
| 6795 } | 6797 } |
| 6796 | 6798 |
| 6797 return final_loop; | 6799 return final_loop; |
| 6798 } | 6800 } |
| 6799 | 6801 |
| 6800 | 6802 |
| 6801 } // namespace internal | 6803 } // namespace internal |
| 6802 } // namespace v8 | 6804 } // namespace v8 |
| OLD | NEW |