OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 <cmath> | 5 #include <cmath> |
6 | 6 |
7 #include "src/allocation.h" | 7 #include "src/allocation.h" |
8 #include "src/base/logging.h" | 8 #include "src/base/logging.h" |
9 #include "src/conversions-inl.h" | 9 #include "src/conversions-inl.h" |
10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 Consume(Token::CONTINUE); | 686 Consume(Token::CONTINUE); |
687 tail_call_position = position(); | 687 tail_call_position = position(); |
688 tok = peek(); | 688 tok = peek(); |
689 } | 689 } |
690 if (!scanner()->HasAnyLineTerminatorBeforeNext() && | 690 if (!scanner()->HasAnyLineTerminatorBeforeNext() && |
691 tok != Token::SEMICOLON && | 691 tok != Token::SEMICOLON && |
692 tok != Token::RBRACE && | 692 tok != Token::RBRACE && |
693 tok != Token::EOS) { | 693 tok != Token::EOS) { |
694 ParseExpression(true, CHECK_OK); | 694 ParseExpression(true, CHECK_OK); |
695 if (tail_call_position >= 0) { | 695 if (tail_call_position >= 0) { |
696 if (!function_state_->collect_expressions_in_tail_position()) { | 696 ReturnExprContext return_expr_context = |
697 Scanner::Location loc(tail_call_position, tail_call_position + 1); | 697 function_state_->return_expr_context(); |
698 ReportMessageAt(loc, MessageTemplate::kTailCallInTryBlock); | 698 if (return_expr_context != ReturnExprContext::kNormal) { |
| 699 ReportIllegalTailCallAt(tail_call_position, return_expr_context); |
699 *ok = false; | 700 *ok = false; |
700 return Statement::Default(); | 701 return Statement::Default(); |
701 } | 702 } |
702 function_state_->AddExpressionInTailPosition( | 703 function_state_->AddExpressionInTailPosition( |
703 PreParserExpression::Default(), tail_call_position); | 704 PreParserExpression::Default(), tail_call_position); |
704 } | 705 } |
705 } | 706 } |
706 ExpectSemicolon(CHECK_OK); | 707 ExpectSemicolon(CHECK_OK); |
707 return Statement::Jump(); | 708 return Statement::Jump(); |
708 } | 709 } |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 | 844 |
844 if (mode == ForEachStatement::ITERATE) { | 845 if (mode == ForEachStatement::ITERATE) { |
845 ExpressionClassifier classifier(this); | 846 ExpressionClassifier classifier(this); |
846 ParseAssignmentExpression(true, &classifier, CHECK_OK); | 847 ParseAssignmentExpression(true, &classifier, CHECK_OK); |
847 RewriteNonPattern(&classifier, CHECK_OK); | 848 RewriteNonPattern(&classifier, CHECK_OK); |
848 } else { | 849 } else { |
849 ParseExpression(true, CHECK_OK); | 850 ParseExpression(true, CHECK_OK); |
850 } | 851 } |
851 | 852 |
852 Expect(Token::RPAREN, CHECK_OK); | 853 Expect(Token::RPAREN, CHECK_OK); |
853 ParseScopedStatement(true, CHECK_OK); | 854 { |
| 855 ReturnExprScope no_tail_calls(function_state_, |
| 856 ReturnExprContext::kInsideForInOfBody); |
| 857 ParseScopedStatement(true, CHECK_OK); |
| 858 } |
854 return Statement::Default(); | 859 return Statement::Default(); |
855 } | 860 } |
856 } else { | 861 } else { |
857 int lhs_beg_pos = peek_position(); | 862 int lhs_beg_pos = peek_position(); |
858 ExpressionClassifier classifier(this); | 863 ExpressionClassifier classifier(this); |
859 Expression lhs = ParseExpression(false, &classifier, CHECK_OK); | 864 Expression lhs = ParseExpression(false, &classifier, CHECK_OK); |
860 int lhs_end_pos = scanner()->location().end_pos; | 865 int lhs_end_pos = scanner()->location().end_pos; |
861 bool is_for_each = CheckInOrOf(&mode, ok); | 866 bool is_for_each = CheckInOrOf(&mode, ok); |
862 if (!*ok) return Statement::Default(); | 867 if (!*ok) return Statement::Default(); |
863 bool is_destructuring = is_for_each && | 868 bool is_destructuring = is_for_each && |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
946 // | 951 // |
947 // Catch :: | 952 // Catch :: |
948 // 'catch' '(' Identifier ')' Block | 953 // 'catch' '(' Identifier ')' Block |
949 // | 954 // |
950 // Finally :: | 955 // Finally :: |
951 // 'finally' Block | 956 // 'finally' Block |
952 | 957 |
953 Expect(Token::TRY, CHECK_OK); | 958 Expect(Token::TRY, CHECK_OK); |
954 | 959 |
955 { | 960 { |
956 DontCollectExpressionsInTailPositionScope no_tail_calls(function_state_); | 961 ReturnExprScope no_tail_calls(function_state_, |
| 962 ReturnExprContext::kInsideTryBlock); |
957 ParseBlock(CHECK_OK); | 963 ParseBlock(CHECK_OK); |
958 } | 964 } |
959 | 965 |
960 Token::Value tok = peek(); | 966 Token::Value tok = peek(); |
961 if (tok != Token::CATCH && tok != Token::FINALLY) { | 967 if (tok != Token::CATCH && tok != Token::FINALLY) { |
962 ReportMessageAt(scanner()->location(), MessageTemplate::kNoCatchOrFinally); | 968 ReportMessageAt(scanner()->location(), MessageTemplate::kNoCatchOrFinally); |
963 *ok = false; | 969 *ok = false; |
964 return Statement::Default(); | 970 return Statement::Default(); |
965 } | 971 } |
966 List<TailCallExpression> expressions_in_tail_position_in_catch_block; | 972 List<TailCallExpression> expressions_in_tail_position_in_catch_block; |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1192 } | 1198 } |
1193 Expect(Token::RBRACE, CHECK_OK); | 1199 Expect(Token::RBRACE, CHECK_OK); |
1194 return PreParserExpression::Default(); | 1200 return PreParserExpression::Default(); |
1195 } | 1201 } |
1196 | 1202 |
1197 #undef CHECK_OK | 1203 #undef CHECK_OK |
1198 | 1204 |
1199 | 1205 |
1200 } // namespace internal | 1206 } // namespace internal |
1201 } // namespace v8 | 1207 } // namespace v8 |
OLD | NEW |