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

Side by Side Diff: src/parser.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 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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/ast.h" 8 #include "src/ast.h"
9 #include "src/bailout-reason.h" 9 #include "src/bailout-reason.h"
10 #include "src/base/platform/platform.h" 10 #include "src/base/platform/platform.h"
(...skipping 2689 matching lines...) Expand 10 before | Expand all | Expand 10 after
2700 2700
2701 Statement* Parser::ParseReturnStatement(bool* ok) { 2701 Statement* Parser::ParseReturnStatement(bool* ok) {
2702 // ReturnStatement :: 2702 // ReturnStatement ::
2703 // 'return' Expression? ';' 2703 // 'return' Expression? ';'
2704 2704
2705 // Consume the return token. It is necessary to do that before 2705 // Consume the return token. It is necessary to do that before
2706 // reporting any errors on it, because of the way errors are 2706 // reporting any errors on it, because of the way errors are
2707 // reported (underlining). 2707 // reported (underlining).
2708 Expect(Token::RETURN, CHECK_OK); 2708 Expect(Token::RETURN, CHECK_OK);
2709 Scanner::Location loc = scanner()->location(); 2709 Scanner::Location loc = scanner()->location();
2710 function_state_->set_return_location(loc);
2710 2711
2711 Token::Value tok = peek(); 2712 Token::Value tok = peek();
2712 Statement* result; 2713 Statement* result;
2713 Expression* return_value; 2714 Expression* return_value;
2714 if (scanner()->HasAnyLineTerminatorBeforeNext() || 2715 if (scanner()->HasAnyLineTerminatorBeforeNext() ||
2715 tok == Token::SEMICOLON || 2716 tok == Token::SEMICOLON ||
2716 tok == Token::RBRACE || 2717 tok == Token::RBRACE ||
2717 tok == Token::EOS) { 2718 tok == Token::EOS) {
2718 if (IsSubclassConstructor(function_state_->kind())) { 2719 if (IsSubclassConstructor(function_state_->kind())) {
2719 return_value = ThisExpression(scope_, factory(), loc.beg_pos); 2720 return_value = ThisExpression(scope_, factory(), loc.beg_pos);
2720 } else { 2721 } else {
2721 return_value = GetLiteralUndefined(position()); 2722 return_value = GetLiteralUndefined(position());
2722 } 2723 }
2723 } else { 2724 } else {
2725 if (is_strong(language_mode()) &&
2726 i::IsConstructor(function_state_->kind())) {
2727 int pos = peek_position();
2728 ReportMessageAt(Scanner::Location(pos, pos + 1),
2729 "strong_constructor_return_value");
2730 *ok = false;
2731 return NULL;
2732 }
2724 return_value = ParseExpression(true, CHECK_OK); 2733 return_value = ParseExpression(true, CHECK_OK);
2725 } 2734 }
2726 ExpectSemicolon(CHECK_OK); 2735 ExpectSemicolon(CHECK_OK);
2727 2736
2728 if (is_generator()) { 2737 if (is_generator()) {
2729 Expression* generator = factory()->NewVariableProxy( 2738 Expression* generator = factory()->NewVariableProxy(
2730 function_state_->generator_object_variable()); 2739 function_state_->generator_object_variable());
2731 Expression* yield = factory()->NewYield( 2740 Expression* yield = factory()->NewYield(
2732 generator, return_value, Yield::kFinal, loc.beg_pos); 2741 generator, return_value, Yield::kFinal, loc.beg_pos);
2733 result = factory()->NewExpressionStatement(yield, loc.beg_pos); 2742 result = factory()->NewExpressionStatement(yield, loc.beg_pos);
(...skipping 2801 matching lines...) Expand 10 before | Expand all | Expand 10 after
5535 } else { 5544 } else {
5536 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); 5545 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data());
5537 running_hash = StringHasher::ComputeRunningHash(running_hash, data, 5546 running_hash = StringHasher::ComputeRunningHash(running_hash, data,
5538 raw_string->length()); 5547 raw_string->length());
5539 } 5548 }
5540 } 5549 }
5541 5550
5542 return running_hash; 5551 return running_hash;
5543 } 5552 }
5544 } } // namespace v8::internal 5553 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698