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

Unified Diff: src/preparser.cc

Issue 1105453002: Revert of [strong] checking of this & super in constructors (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/preparser.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/preparser.cc
diff --git a/src/preparser.cc b/src/preparser.cc
index caa383a3cc2a60732ccfb8ec101433ad495b5c18..4a8c37def5769f9da37c23ddc0d39e6523e33f5c 100644
--- a/src/preparser.cc
+++ b/src/preparser.cc
@@ -123,15 +123,6 @@
if (is_strict(scope_->language_mode())) {
int end_pos = scanner()->location().end_pos;
CheckStrictOctalLiteral(start_position, end_pos, &ok);
- if (!ok) return kPreParseSuccess;
-
- if (is_strong(scope_->language_mode()) && IsSubclassConstructor(kind)) {
- if (!function_state.super_location().IsValid()) {
- ReportMessageAt(Scanner::Location(start_position, start_position + 1),
- "strong_super_call_missing", kReferenceError);
- return kPreParseSuccess;
- }
- }
}
}
return kPreParseSuccess;
@@ -205,31 +196,19 @@
if (directive_prologue && peek() != Token::STRING) {
directive_prologue = false;
}
- Scanner::Location token_loc = scanner()->peek_location();
- Scanner::Location old_this_loc = function_state_->this_location();
- Scanner::Location old_super_loc = function_state_->super_location();
+ Token::Value token = peek();
+ Scanner::Location old_super_loc = function_state_->super_call_location();
Statement statement = ParseStatementListItem(ok);
if (!*ok) return;
-
+ Scanner::Location super_loc = function_state_->super_call_location();
if (is_strong(language_mode()) &&
- scope_->is_function_scope() &&
- i::IsConstructor(function_state_->kind())) {
- Scanner::Location this_loc = function_state_->this_location();
- Scanner::Location super_loc = function_state_->super_location();
- if (this_loc.beg_pos != old_this_loc.beg_pos &&
- this_loc.beg_pos != token_loc.beg_pos) {
- ReportMessageAt(this_loc, "strong_constructor_this");
- *ok = false;
- return;
- }
- if (super_loc.beg_pos != old_super_loc.beg_pos &&
- super_loc.beg_pos != token_loc.beg_pos) {
- ReportMessageAt(super_loc, "strong_constructor_super");
- *ok = false;
- return;
- }
- }
-
+ i::IsConstructor(function_state_->kind()) &&
+ !old_super_loc.IsValid() && super_loc.IsValid() &&
+ token != Token::SUPER) {
+ ReportMessageAt(super_loc, "strong_super_call_nested");
+ *ok = false;
+ return;
+ }
if (directive_prologue) {
if (statement.IsUseStrictLiteral()) {
scope_->SetLanguageMode(
@@ -552,37 +531,6 @@
ReportUnexpectedToken(Next());
*ok = false;
return Statement::Default();
-
- case Token::THIS:
- case Token::SUPER:
- if (is_strong(language_mode()) &&
- i::IsConstructor(function_state_->kind())) {
- bool is_this = peek() == Token::THIS;
- Expression expr = Expression::Default();
- if (is_this) {
- expr = ParseStrongInitializationExpression(CHECK_OK);
- } else {
- expr = ParseStrongSuperCallExpression(CHECK_OK);
- }
- switch (peek()) {
- case Token::SEMICOLON:
- Consume(Token::SEMICOLON);
- break;
- case Token::RBRACE:
- case Token::EOS:
- break;
- default:
- if (!scanner()->HasAnyLineTerminatorBeforeNext()) {
- ReportMessageAt(function_state_->this_location(),
- is_this ? "strong_constructor_this"
- : "strong_constructor_super");
- *ok = false;
- return Statement::Default();
- }
- }
- return Statement::ExpressionStatement(expr);
- }
- break;
// TODO(arv): Handle `let [`
// https://code.google.com/p/v8/issues/detail?id=3847
@@ -1024,7 +972,7 @@
}
if (is_strong(language_mode()) && IsSubclassConstructor(kind)) {
- if (!function_state.super_location().IsValid()) {
+ if (!function_state.super_call_location().IsValid()) {
ReportMessageAt(function_name_location, "strong_super_call_missing",
kReferenceError);
*ok = false;
« no previous file with comments | « src/preparser.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698