Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: src/preparser.cc

Issue 1019283002: [strong] Check constructor returns (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 606
607 607
608 PreParser::Statement PreParser::ParseReturnStatement(bool* ok) { 608 PreParser::Statement PreParser::ParseReturnStatement(bool* ok) {
609 // ReturnStatement :: 609 // ReturnStatement ::
610 // 'return' [no line terminator] Expression? ';' 610 // 'return' [no line terminator] Expression? ';'
611 611
612 // Consume the return token. It is necessary to do before 612 // Consume the return token. It is necessary to do before
613 // reporting any errors on it, because of the way errors are 613 // reporting any errors on it, because of the way errors are
614 // reported (underlining). 614 // reported (underlining).
615 Expect(Token::RETURN, CHECK_OK); 615 Expect(Token::RETURN, CHECK_OK);
616 function_state_->set_return_location(scanner()->location());
616 617
617 // An ECMAScript program is considered syntactically incorrect if it 618 // An ECMAScript program is considered syntactically incorrect if it
618 // contains a return statement that is not within the body of a 619 // contains a return statement that is not within the body of a
619 // function. See ECMA-262, section 12.9, page 67. 620 // function. See ECMA-262, section 12.9, page 67.
620 // This is not handled during preparsing. 621 // This is not handled during preparsing.
621 622
622 Token::Value tok = peek(); 623 Token::Value tok = peek();
623 if (!scanner()->HasAnyLineTerminatorBeforeNext() && 624 if (!scanner()->HasAnyLineTerminatorBeforeNext() &&
624 tok != Token::SEMICOLON && 625 tok != Token::SEMICOLON &&
625 tok != Token::RBRACE && 626 tok != Token::RBRACE &&
626 tok != Token::EOS) { 627 tok != Token::EOS) {
628 if (is_strong(language_mode()) &&
629 i::IsConstructor(function_state_->kind())) {
630 int pos = peek_position();
631 ReportMessageAt(Scanner::Location(pos, pos + 1),
632 "strong_constructor_return_value");
633 *ok = false;
634 return Statement::Default();
635 }
627 ParseExpression(true, CHECK_OK); 636 ParseExpression(true, CHECK_OK);
628 } 637 }
629 ExpectSemicolon(CHECK_OK); 638 ExpectSemicolon(CHECK_OK);
630 return Statement::Default(); 639 return Statement::Default();
631 } 640 }
632 641
633 642
634 PreParser::Statement PreParser::ParseWithStatement(bool* ok) { 643 PreParser::Statement PreParser::ParseWithStatement(bool* ok) {
635 // WithStatement :: 644 // WithStatement ::
636 // 'with' '(' Expression ')' Statement 645 // 'with' '(' Expression ')' Statement
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); 1045 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK);
1037 ParseArguments(ok); 1046 ParseArguments(ok);
1038 1047
1039 return Expression::Default(); 1048 return Expression::Default();
1040 } 1049 }
1041 1050
1042 #undef CHECK_OK 1051 #undef CHECK_OK
1043 1052
1044 1053
1045 } } // v8::internal 1054 } } // v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698