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

Side by Side Diff: src/parser.cc

Issue 1240273002: [strong] Keep language mode consistent (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « src/compiler/js-operator.cc ('k') | src/preparser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ast-literal-reindexer.h" 9 #include "src/ast-literal-reindexer.h"
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 int materialized_literal_count = -1; 339 int materialized_literal_count = -1;
340 int expected_property_count = -1; 340 int expected_property_count = -1;
341 int parameter_count = 0; 341 int parameter_count = 0;
342 const AstRawString* name = ast_value_factory()->empty_string(); 342 const AstRawString* name = ast_value_factory()->empty_string();
343 343
344 344
345 FunctionKind kind = call_super ? FunctionKind::kDefaultSubclassConstructor 345 FunctionKind kind = call_super ? FunctionKind::kDefaultSubclassConstructor
346 : FunctionKind::kDefaultBaseConstructor; 346 : FunctionKind::kDefaultBaseConstructor;
347 Scope* function_scope = NewScope(scope, FUNCTION_SCOPE, kind); 347 Scope* function_scope = NewScope(scope, FUNCTION_SCOPE, kind);
348 function_scope->SetLanguageMode( 348 function_scope->SetLanguageMode(
349 static_cast<LanguageMode>(language_mode | STRICT_BIT)); 349 static_cast<LanguageMode>(language_mode | STRICT));
350 // Set start and end position to the same value 350 // Set start and end position to the same value
351 function_scope->set_start_position(pos); 351 function_scope->set_start_position(pos);
352 function_scope->set_end_position(pos); 352 function_scope->set_end_position(pos);
353 ZoneList<Statement*>* body = NULL; 353 ZoneList<Statement*>* body = NULL;
354 354
355 { 355 {
356 AstNodeFactory function_factory(ast_value_factory()); 356 AstNodeFactory function_factory(ast_value_factory());
357 FunctionState function_state(&function_state_, &scope_, function_scope, 357 FunctionState function_state(&function_state_, &scope_, function_scope,
358 kind, &function_factory); 358 kind, &function_factory);
359 359
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 allow_strong_mode() && 1320 allow_strong_mode() &&
1321 literal->raw_value()->AsString() == 1321 literal->raw_value()->AsString() ==
1322 ast_value_factory()->use_strong_string() && 1322 ast_value_factory()->use_strong_string() &&
1323 token_loc.end_pos - token_loc.beg_pos == 1323 token_loc.end_pos - token_loc.beg_pos ==
1324 ast_value_factory()->use_strong_string()->length() + 2; 1324 ast_value_factory()->use_strong_string()->length() + 2;
1325 if (use_strict_found || use_strong_found) { 1325 if (use_strict_found || use_strong_found) {
1326 // Strong mode implies strict mode. If there are several "use strict" 1326 // Strong mode implies strict mode. If there are several "use strict"
1327 // / "use strong" directives, do the strict mode changes only once. 1327 // / "use strong" directives, do the strict mode changes only once.
1328 if (is_sloppy(scope_->language_mode())) { 1328 if (is_sloppy(scope_->language_mode())) {
1329 scope_->SetLanguageMode(static_cast<LanguageMode>( 1329 scope_->SetLanguageMode(static_cast<LanguageMode>(
1330 scope_->language_mode() | STRICT_BIT)); 1330 scope_->language_mode() | STRICT));
1331 } 1331 }
1332 1332
1333 if (use_strong_found) { 1333 if (use_strong_found) {
1334 scope_->SetLanguageMode(static_cast<LanguageMode>( 1334 scope_->SetLanguageMode(static_cast<LanguageMode>(
1335 scope_->language_mode() | STRONG_BIT)); 1335 scope_->language_mode() | STRONG));
1336 } 1336 }
1337 // Because declarations in strict eval code don't leak into the scope 1337 // Because declarations in strict eval code don't leak into the scope
1338 // of the eval call, it is likely that functions declared in strict 1338 // of the eval call, it is likely that functions declared in strict
1339 // eval code will be used within the eval code, so lazy parsing is 1339 // eval code will be used within the eval code, so lazy parsing is
1340 // probably not a win. Also, resolution of "var" bindings defined in 1340 // probably not a win. Also, resolution of "var" bindings defined in
1341 // strict eval code from within nested functions is currently broken 1341 // strict eval code from within nested functions is currently broken
1342 // with the pre-parser; lazy parsing of strict eval code causes 1342 // with the pre-parser; lazy parsing of strict eval code causes
1343 // regress/regress-crbug-135066.js to fail. 1343 // regress/regress-crbug-135066.js to fail.
1344 if (scope_->is_eval_scope()) mode_ = PARSE_EAGERLY; 1344 if (scope_->is_eval_scope()) mode_ = PARSE_EAGERLY;
1345 } else if (literal->raw_value()->AsString() == 1345 } else if (literal->raw_value()->AsString() ==
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1425 void* Parser::ParseModuleItemList(ZoneList<Statement*>* body, bool* ok) { 1425 void* Parser::ParseModuleItemList(ZoneList<Statement*>* body, bool* ok) {
1426 // (Ecma 262 6th Edition, 15.2): 1426 // (Ecma 262 6th Edition, 15.2):
1427 // Module : 1427 // Module :
1428 // ModuleBody? 1428 // ModuleBody?
1429 // 1429 //
1430 // ModuleBody : 1430 // ModuleBody :
1431 // ModuleItem* 1431 // ModuleItem*
1432 1432
1433 DCHECK(scope_->is_module_scope()); 1433 DCHECK(scope_->is_module_scope());
1434 scope_->SetLanguageMode( 1434 scope_->SetLanguageMode(
1435 static_cast<LanguageMode>(scope_->language_mode() | STRICT_BIT)); 1435 static_cast<LanguageMode>(scope_->language_mode() | STRICT));
1436 1436
1437 while (peek() != Token::EOS) { 1437 while (peek() != Token::EOS) {
1438 Statement* stat = ParseModuleItem(CHECK_OK); 1438 Statement* stat = ParseModuleItem(CHECK_OK);
1439 if (stat && !stat->IsEmpty()) { 1439 if (stat && !stat->IsEmpty()) {
1440 body->Add(stat, zone()); 1440 body->Add(stat, zone());
1441 } 1441 }
1442 } 1442 }
1443 1443
1444 // Check that all exports are bound. 1444 // Check that all exports are bound.
1445 ModuleDescriptor* descriptor = scope_->module(); 1445 ModuleDescriptor* descriptor = scope_->module();
(...skipping 3061 matching lines...) Expand 10 before | Expand all | Expand 10 after
4507 } 4507 }
4508 if (is_strong(language_mode()) && IsUndefined(name)) { 4508 if (is_strong(language_mode()) && IsUndefined(name)) {
4509 ReportMessageAt(class_name_location, MessageTemplate::kStrongUndefined); 4509 ReportMessageAt(class_name_location, MessageTemplate::kStrongUndefined);
4510 *ok = false; 4510 *ok = false;
4511 return NULL; 4511 return NULL;
4512 } 4512 }
4513 4513
4514 Scope* block_scope = NewScope(scope_, BLOCK_SCOPE); 4514 Scope* block_scope = NewScope(scope_, BLOCK_SCOPE);
4515 BlockState block_state(&scope_, block_scope); 4515 BlockState block_state(&scope_, block_scope);
4516 scope_->SetLanguageMode( 4516 scope_->SetLanguageMode(
4517 static_cast<LanguageMode>(scope_->language_mode() | STRICT_BIT)); 4517 static_cast<LanguageMode>(scope_->language_mode() | STRICT));
4518 scope_->SetScopeName(name); 4518 scope_->SetScopeName(name);
4519 4519
4520 VariableProxy* proxy = NULL; 4520 VariableProxy* proxy = NULL;
4521 if (name != NULL) { 4521 if (name != NULL) {
4522 proxy = NewUnresolved(name, CONST); 4522 proxy = NewUnresolved(name, CONST);
4523 const bool is_class_declaration = true; 4523 const bool is_class_declaration = true;
4524 Declaration* declaration = factory()->NewVariableDeclaration( 4524 Declaration* declaration = factory()->NewVariableDeclaration(
4525 proxy, CONST, block_scope, pos, is_class_declaration, 4525 proxy, CONST, block_scope, pos, is_class_declaration,
4526 scope_->class_declaration_group_start()); 4526 scope_->class_declaration_group_start());
4527 Declare(declaration, DeclarationDescriptor::NORMAL, true, CHECK_OK); 4527 Declare(declaration, DeclarationDescriptor::NORMAL, true, CHECK_OK);
(...skipping 1463 matching lines...) Expand 10 before | Expand all | Expand 10 after
5991 Expression* Parser::SpreadCallNew(Expression* function, 5991 Expression* Parser::SpreadCallNew(Expression* function,
5992 ZoneList<v8::internal::Expression*>* args, 5992 ZoneList<v8::internal::Expression*>* args,
5993 int pos) { 5993 int pos) {
5994 args->InsertAt(0, function, zone()); 5994 args->InsertAt(0, function, zone());
5995 5995
5996 return factory()->NewCallRuntime( 5996 return factory()->NewCallRuntime(
5997 ast_value_factory()->reflect_construct_string(), NULL, args, pos); 5997 ast_value_factory()->reflect_construct_string(), NULL, args, pos);
5998 } 5998 }
5999 } // namespace internal 5999 } // namespace internal
6000 } // namespace v8 6000 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-operator.cc ('k') | src/preparser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698