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 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 | 741 |
742 | 742 |
743 PreParser::Statement PreParser::ParseReturnStatement(bool* ok) { | 743 PreParser::Statement PreParser::ParseReturnStatement(bool* ok) { |
744 // ReturnStatement :: | 744 // ReturnStatement :: |
745 // 'return' [no line terminator] Expression? ';' | 745 // 'return' [no line terminator] Expression? ';' |
746 | 746 |
747 // Consume the return token. It is necessary to do before | 747 // Consume the return token. It is necessary to do before |
748 // reporting any errors on it, because of the way errors are | 748 // reporting any errors on it, because of the way errors are |
749 // reported (underlining). | 749 // reported (underlining). |
750 Expect(Token::RETURN, CHECK_OK); | 750 Expect(Token::RETURN, CHECK_OK); |
751 function_state_->set_return_location(scanner()->location()); | |
752 | 751 |
753 // An ECMAScript program is considered syntactically incorrect if it | 752 // An ECMAScript program is considered syntactically incorrect if it |
754 // contains a return statement that is not within the body of a | 753 // contains a return statement that is not within the body of a |
755 // function. See ECMA-262, section 12.9, page 67. | 754 // function. See ECMA-262, section 12.9, page 67. |
756 // This is not handled during preparsing. | 755 // This is not handled during preparsing. |
757 | 756 |
758 Token::Value tok = peek(); | 757 Token::Value tok = peek(); |
759 if (!scanner()->HasAnyLineTerminatorBeforeNext() && | 758 if (!scanner()->HasAnyLineTerminatorBeforeNext() && |
760 tok != Token::SEMICOLON && | 759 tok != Token::SEMICOLON && |
761 tok != Token::RBRACE && | 760 tok != Token::RBRACE && |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1318 | 1317 |
1319 body->Add(PreParserStatement::ExpressionStatement(return_value), zone()); | 1318 body->Add(PreParserStatement::ExpressionStatement(return_value), zone()); |
1320 } | 1319 } |
1321 | 1320 |
1322 #undef CHECK_OK | 1321 #undef CHECK_OK |
1323 #undef CHECK_OK_CUSTOM | 1322 #undef CHECK_OK_CUSTOM |
1324 | 1323 |
1325 | 1324 |
1326 } // namespace internal | 1325 } // namespace internal |
1327 } // namespace v8 | 1326 } // namespace v8 |
OLD | NEW |