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

Side by Side Diff: src/preparser.cc

Issue 1314203002: [strong] Class constructor bodies cannot contain "use strong" directive (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: formatting Created 5 years, 3 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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 bool use_strict_found = statement.IsUseStrictLiteral(); 255 bool use_strict_found = statement.IsUseStrictLiteral();
256 bool use_strong_found = 256 bool use_strong_found =
257 statement.IsUseStrongLiteral() && allow_strong_mode(); 257 statement.IsUseStrongLiteral() && allow_strong_mode();
258 258
259 if (use_strict_found) { 259 if (use_strict_found) {
260 scope_->SetLanguageMode( 260 scope_->SetLanguageMode(
261 static_cast<LanguageMode>(scope_->language_mode() | STRICT)); 261 static_cast<LanguageMode>(scope_->language_mode() | STRICT));
262 } else if (use_strong_found) { 262 } else if (use_strong_found) {
263 scope_->SetLanguageMode(static_cast<LanguageMode>( 263 scope_->SetLanguageMode(static_cast<LanguageMode>(
264 scope_->language_mode() | STRONG)); 264 scope_->language_mode() | STRONG));
265 if (i::IsConstructor(function_state_->kind())) {
266 // "use strong" cannot occur in a class constructor body, to avoid
267 // unintuitive strong class object semantics.
268 PreParserTraits::ReportMessageAt(
269 token_loc, MessageTemplate::kStrongConstructorDirective);
270 *ok = false;
271 return;
272 }
265 } else if (!statement.IsStringLiteral()) { 273 } else if (!statement.IsStringLiteral()) {
266 directive_prologue = false; 274 directive_prologue = false;
267 } 275 }
268 276
269 if ((use_strict_found || use_strong_found) && 277 if ((use_strict_found || use_strong_found) &&
270 !scope_->HasSimpleParameters()) { 278 !scope_->HasSimpleParameters()) {
271 // TC39 deemed "use strict" directives to be an error when occurring 279 // TC39 deemed "use strict" directives to be an error when occurring
272 // in the body of a function with non-simple parameter list, on 280 // in the body of a function with non-simple parameter list, on
273 // 29/7/2015. https://goo.gl/ueA7Ln 281 // 29/7/2015. https://goo.gl/ueA7Ln
274 // 282 //
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after
1223 1231
1224 DCHECK(!spread_pos.IsValid()); 1232 DCHECK(!spread_pos.IsValid());
1225 1233
1226 return Expression::Default(); 1234 return Expression::Default();
1227 } 1235 }
1228 1236
1229 #undef CHECK_OK 1237 #undef CHECK_OK
1230 1238
1231 1239
1232 } } // v8::internal 1240 } } // v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698