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

Side by Side Diff: src/preparser.cc

Issue 1002253002: [strong] Check super constructor calls (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Typo 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 187
188 void PreParser::ParseStatementList(int end_token, bool* ok) { 188 void PreParser::ParseStatementList(int end_token, bool* ok) {
189 // SourceElements :: 189 // SourceElements ::
190 // (Statement)* <end_token> 190 // (Statement)* <end_token>
191 191
192 bool directive_prologue = true; 192 bool directive_prologue = true;
193 while (peek() != end_token) { 193 while (peek() != end_token) {
194 if (directive_prologue && peek() != Token::STRING) { 194 if (directive_prologue && peek() != Token::STRING) {
195 directive_prologue = false; 195 directive_prologue = false;
196 } 196 }
197 Token::Value token = peek();
198 Scanner::Location old_super_loc = function_state_->super_call_location();
197 Statement statement = ParseStatementListItem(ok); 199 Statement statement = ParseStatementListItem(ok);
198 if (!*ok) return; 200 if (!*ok) return;
201 Scanner::Location super_loc = function_state_->super_call_location();
202 if (is_strong(language_mode()) &&
203 i::IsConstructor(function_state_->kind()) &&
204 !old_super_loc.IsValid() && super_loc.IsValid() &&
205 token != Token::SUPER) {
206 ReportMessageAt(super_loc, "strong_super_call_nested");
207 *ok = false;
208 return;
209 }
199 if (directive_prologue) { 210 if (directive_prologue) {
200 if (statement.IsUseStrictLiteral()) { 211 if (statement.IsUseStrictLiteral()) {
201 scope_->SetLanguageMode( 212 scope_->SetLanguageMode(
202 static_cast<LanguageMode>(scope_->language_mode() | STRICT_BIT)); 213 static_cast<LanguageMode>(scope_->language_mode() | STRICT_BIT));
203 } else if (statement.IsUseStrongLiteral() && allow_strong_mode()) { 214 } else if (statement.IsUseStrongLiteral() && allow_strong_mode()) {
204 scope_->SetLanguageMode(static_cast<LanguageMode>( 215 scope_->SetLanguageMode(static_cast<LanguageMode>(
205 scope_->language_mode() | STRICT_BIT | STRONG_BIT)); 216 scope_->language_mode() | STRICT_BIT | STRONG_BIT));
206 } else if (!statement.IsStringLiteral()) { 217 } else if (!statement.IsStringLiteral()) {
207 directive_prologue = false; 218 directive_prologue = false;
208 } 219 }
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 const bool use_strict_params = is_rest || IsConciseMethod(kind); 949 const bool use_strict_params = is_rest || IsConciseMethod(kind);
939 CheckFunctionParameterNames(language_mode(), use_strict_params, 950 CheckFunctionParameterNames(language_mode(), use_strict_params,
940 eval_args_error_loc, dupe_error_loc, 951 eval_args_error_loc, dupe_error_loc,
941 reserved_error_loc, CHECK_OK); 952 reserved_error_loc, CHECK_OK);
942 953
943 if (is_strict(language_mode())) { 954 if (is_strict(language_mode())) {
944 int end_position = scanner()->location().end_pos; 955 int end_position = scanner()->location().end_pos;
945 CheckStrictOctalLiteral(start_position, end_position, CHECK_OK); 956 CheckStrictOctalLiteral(start_position, end_position, CHECK_OK);
946 } 957 }
947 958
959 if (is_strong(language_mode()) && IsSubclassConstructor(kind)) {
960 if (!function_state.super_call_location().IsValid()) {
961 ReportMessageAt(function_name_location, "strong_super_call_missing");
962 *ok = false;
963 return Expression::Default();
964 }
965 }
966
948 return Expression::Default(); 967 return Expression::Default();
949 } 968 }
950 969
951 970
952 void PreParser::ParseLazyFunctionLiteralBody(bool* ok) { 971 void PreParser::ParseLazyFunctionLiteralBody(bool* ok) {
953 int body_start = position(); 972 int body_start = position();
954 ParseStatementList(Token::RBRACE, ok); 973 ParseStatementList(Token::RBRACE, ok);
955 if (!*ok) return; 974 if (!*ok) return;
956 975
957 // Position right after terminal '}'. 976 // Position right after terminal '}'.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); 1042 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK);
1024 ParseArguments(ok); 1043 ParseArguments(ok);
1025 1044
1026 return Expression::Default(); 1045 return Expression::Default();
1027 } 1046 }
1028 1047
1029 #undef CHECK_OK 1048 #undef CHECK_OK
1030 1049
1031 1050
1032 } } // v8::internal 1051 } } // v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698