OLD | NEW |
---|---|
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/parser.h" | 5 #include "src/parser.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 Loading... | |
339 LanguageMode language_mode) { | 339 LanguageMode language_mode) { |
340 int materialized_literal_count = -1; | 340 int materialized_literal_count = -1; |
341 int expected_property_count = -1; | 341 int expected_property_count = -1; |
342 int parameter_count = 0; | 342 int parameter_count = 0; |
343 const AstRawString* name = ast_value_factory()->empty_string(); | 343 const AstRawString* name = ast_value_factory()->empty_string(); |
344 | 344 |
345 | 345 |
346 FunctionKind kind = call_super ? FunctionKind::kDefaultSubclassConstructor | 346 FunctionKind kind = call_super ? FunctionKind::kDefaultSubclassConstructor |
347 : FunctionKind::kDefaultBaseConstructor; | 347 : FunctionKind::kDefaultBaseConstructor; |
348 Scope* function_scope = NewScope(scope, FUNCTION_SCOPE, kind); | 348 Scope* function_scope = NewScope(scope, FUNCTION_SCOPE, kind); |
349 function_scope->SetLanguageMode( | 349 SetLanguageMode(function_scope, |
350 static_cast<LanguageMode>(language_mode | STRICT)); | 350 static_cast<LanguageMode>(language_mode | STRICT)); |
351 // Set start and end position to the same value | 351 // Set start and end position to the same value |
352 function_scope->set_start_position(pos); | 352 function_scope->set_start_position(pos); |
353 function_scope->set_end_position(pos); | 353 function_scope->set_end_position(pos); |
354 ZoneList<Statement*>* body = NULL; | 354 ZoneList<Statement*>* body = NULL; |
355 | 355 |
356 { | 356 { |
357 AstNodeFactory function_factory(ast_value_factory()); | 357 AstNodeFactory function_factory(ast_value_factory()); |
358 FunctionState function_state(&function_state_, &scope_, function_scope, | 358 FunctionState function_state(&function_state_, &scope_, function_scope, |
359 kind, &function_factory); | 359 kind, &function_factory); |
360 | 360 |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1042 } | 1042 } |
1043 | 1043 |
1044 scope->set_start_position(0); | 1044 scope->set_start_position(0); |
1045 | 1045 |
1046 // Enter 'scope' with the given parsing mode. | 1046 // Enter 'scope' with the given parsing mode. |
1047 ParsingModeScope parsing_mode_scope(this, parsing_mode); | 1047 ParsingModeScope parsing_mode_scope(this, parsing_mode); |
1048 AstNodeFactory function_factory(ast_value_factory()); | 1048 AstNodeFactory function_factory(ast_value_factory()); |
1049 FunctionState function_state(&function_state_, &scope_, scope, | 1049 FunctionState function_state(&function_state_, &scope_, scope, |
1050 kNormalFunction, &function_factory); | 1050 kNormalFunction, &function_factory); |
1051 | 1051 |
1052 // Don't count the mode in the use counters--give the program a chance | |
adamk
2015/11/04 00:53:54
This doesn't sound right to me. I suspect it means
Dan Ehrenberg
2015/11/04 17:55:35
I think that's OK--the exact counting doesn't matt
| |
1053 // to enable script/module-wide strict/strong mode below. | |
1052 scope_->SetLanguageMode(info->language_mode()); | 1054 scope_->SetLanguageMode(info->language_mode()); |
1053 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone()); | 1055 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone()); |
1054 bool ok = true; | 1056 bool ok = true; |
1055 int beg_pos = scanner()->location().beg_pos; | 1057 int beg_pos = scanner()->location().beg_pos; |
1056 if (info->is_module()) { | 1058 if (info->is_module()) { |
1057 ParseModuleItemList(body, &ok); | 1059 ParseModuleItemList(body, &ok); |
1058 } else { | 1060 } else { |
1059 ParseStatementList(body, Token::EOS, &ok); | 1061 ParseStatementList(body, Token::EOS, &ok); |
1060 } | 1062 } |
1061 | 1063 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1184 FunctionLiteral::FunctionType function_type = shared_info->is_expression() | 1186 FunctionLiteral::FunctionType function_type = shared_info->is_expression() |
1185 ? (shared_info->is_anonymous() | 1187 ? (shared_info->is_anonymous() |
1186 ? FunctionLiteral::ANONYMOUS_EXPRESSION | 1188 ? FunctionLiteral::ANONYMOUS_EXPRESSION |
1187 : FunctionLiteral::NAMED_EXPRESSION) | 1189 : FunctionLiteral::NAMED_EXPRESSION) |
1188 : FunctionLiteral::DECLARATION; | 1190 : FunctionLiteral::DECLARATION; |
1189 bool ok = true; | 1191 bool ok = true; |
1190 | 1192 |
1191 if (shared_info->is_arrow()) { | 1193 if (shared_info->is_arrow()) { |
1192 Scope* scope = | 1194 Scope* scope = |
1193 NewScope(scope_, FUNCTION_SCOPE, FunctionKind::kArrowFunction); | 1195 NewScope(scope_, FUNCTION_SCOPE, FunctionKind::kArrowFunction); |
1194 scope->SetLanguageMode(shared_info->language_mode()); | 1196 SetLanguageMode(scope, shared_info->language_mode()); |
1195 scope->set_start_position(shared_info->start_position()); | 1197 scope->set_start_position(shared_info->start_position()); |
1196 ExpressionClassifier formals_classifier; | 1198 ExpressionClassifier formals_classifier; |
1197 ParserFormalParameters formals(scope); | 1199 ParserFormalParameters formals(scope); |
1198 Checkpoint checkpoint(this); | 1200 Checkpoint checkpoint(this); |
1199 { | 1201 { |
1200 // Parsing patterns as variable reference expression creates | 1202 // Parsing patterns as variable reference expression creates |
1201 // NewUnresolved references in current scope. Entrer arrow function | 1203 // NewUnresolved references in current scope. Entrer arrow function |
1202 // scope for formal parameter parsing. | 1204 // scope for formal parameter parsing. |
1203 BlockState block_state(&scope_, scope); | 1205 BlockState block_state(&scope_, scope); |
1204 if (Check(Token::LPAREN)) { | 1206 if (Check(Token::LPAREN)) { |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1329 bool use_strong_found = | 1331 bool use_strong_found = |
1330 allow_strong_mode() && | 1332 allow_strong_mode() && |
1331 literal->raw_value()->AsString() == | 1333 literal->raw_value()->AsString() == |
1332 ast_value_factory()->use_strong_string() && | 1334 ast_value_factory()->use_strong_string() && |
1333 token_loc.end_pos - token_loc.beg_pos == | 1335 token_loc.end_pos - token_loc.beg_pos == |
1334 ast_value_factory()->use_strong_string()->length() + 2; | 1336 ast_value_factory()->use_strong_string()->length() + 2; |
1335 if (use_strict_found || use_strong_found) { | 1337 if (use_strict_found || use_strong_found) { |
1336 // Strong mode implies strict mode. If there are several "use strict" | 1338 // Strong mode implies strict mode. If there are several "use strict" |
1337 // / "use strong" directives, do the strict mode changes only once. | 1339 // / "use strong" directives, do the strict mode changes only once. |
1338 if (is_sloppy(scope_->language_mode())) { | 1340 if (is_sloppy(scope_->language_mode())) { |
1339 scope_->SetLanguageMode( | 1341 EnableLanguageMode(STRICT); |
adamk
2015/11/03 22:23:15
I was expecting this function to be the only place
Dan Ehrenberg
2015/11/04 17:55:35
I think it'd be more useful to measure how often s
adamk
2015/11/04 20:18:53
I was assuming we were trying to measure developer
| |
1340 static_cast<LanguageMode>(scope_->language_mode() | STRICT)); | |
1341 } | 1342 } |
1342 | 1343 |
1343 if (use_strong_found) { | 1344 if (use_strong_found) { |
1344 scope_->SetLanguageMode( | 1345 EnableLanguageMode(STRONG); |
1345 static_cast<LanguageMode>(scope_->language_mode() | STRONG)); | |
1346 if (IsClassConstructor(function_state_->kind())) { | 1346 if (IsClassConstructor(function_state_->kind())) { |
1347 // "use strong" cannot occur in a class constructor body, to avoid | 1347 // "use strong" cannot occur in a class constructor body, to avoid |
1348 // unintuitive strong class object semantics. | 1348 // unintuitive strong class object semantics. |
1349 ParserTraits::ReportMessageAt( | 1349 ParserTraits::ReportMessageAt( |
1350 token_loc, MessageTemplate::kStrongConstructorDirective); | 1350 token_loc, MessageTemplate::kStrongConstructorDirective); |
1351 *ok = false; | 1351 *ok = false; |
1352 return nullptr; | 1352 return nullptr; |
1353 } | 1353 } |
1354 } | 1354 } |
1355 if (!scope_->HasSimpleParameters()) { | 1355 if (!scope_->HasSimpleParameters()) { |
(...skipping 15 matching lines...) Expand all Loading... | |
1371 // probably not a win. | 1371 // probably not a win. |
1372 if (scope_->is_eval_scope()) mode_ = PARSE_EAGERLY; | 1372 if (scope_->is_eval_scope()) mode_ = PARSE_EAGERLY; |
1373 } else if (literal->raw_value()->AsString() == | 1373 } else if (literal->raw_value()->AsString() == |
1374 ast_value_factory()->use_asm_string() && | 1374 ast_value_factory()->use_asm_string() && |
1375 token_loc.end_pos - token_loc.beg_pos == | 1375 token_loc.end_pos - token_loc.beg_pos == |
1376 ast_value_factory()->use_asm_string()->length() + 2) { | 1376 ast_value_factory()->use_asm_string()->length() + 2) { |
1377 // Store the usage count; The actual use counter on the isolate is | 1377 // Store the usage count; The actual use counter on the isolate is |
1378 // incremented after parsing is done. | 1378 // incremented after parsing is done. |
1379 ++use_counts_[v8::Isolate::kUseAsm]; | 1379 ++use_counts_[v8::Isolate::kUseAsm]; |
1380 scope_->SetAsmModule(); | 1380 scope_->SetAsmModule(); |
1381 } else { | |
1382 // Should not change mode, but will increment UseCounter | |
1383 // if appropriate. Ditto usages below. | |
1384 EnableLanguageMode(SLOPPY); | |
adamk
2015/11/04 00:53:54
I think the weird thing about this, to me, is that
Dan Ehrenberg
2015/11/04 17:55:35
Well, I could write the code instead like
else if
| |
1381 } | 1385 } |
1382 } else { | 1386 } else { |
1383 // End of the directive prologue. | 1387 // End of the directive prologue. |
1384 directive_prologue = false; | 1388 directive_prologue = false; |
1389 EnableLanguageMode(SLOPPY); | |
1385 } | 1390 } |
1391 } else { | |
1392 EnableLanguageMode(SLOPPY); | |
1386 } | 1393 } |
1387 | 1394 |
1388 body->Add(stat, zone()); | 1395 body->Add(stat, zone()); |
1389 } | 1396 } |
1390 | 1397 |
1391 return 0; | 1398 return 0; |
1392 } | 1399 } |
1393 | 1400 |
1394 | 1401 |
1395 Statement* Parser::ParseStatementListItem(bool* ok) { | 1402 Statement* Parser::ParseStatementListItem(bool* ok) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1452 | 1459 |
1453 void* Parser::ParseModuleItemList(ZoneList<Statement*>* body, bool* ok) { | 1460 void* Parser::ParseModuleItemList(ZoneList<Statement*>* body, bool* ok) { |
1454 // (Ecma 262 6th Edition, 15.2): | 1461 // (Ecma 262 6th Edition, 15.2): |
1455 // Module : | 1462 // Module : |
1456 // ModuleBody? | 1463 // ModuleBody? |
1457 // | 1464 // |
1458 // ModuleBody : | 1465 // ModuleBody : |
1459 // ModuleItem* | 1466 // ModuleItem* |
1460 | 1467 |
1461 DCHECK(scope_->is_module_scope()); | 1468 DCHECK(scope_->is_module_scope()); |
1462 scope_->SetLanguageMode( | 1469 EnableLanguageMode(STRICT); |
1463 static_cast<LanguageMode>(scope_->language_mode() | STRICT)); | |
1464 | 1470 |
1465 while (peek() != Token::EOS) { | 1471 while (peek() != Token::EOS) { |
1466 Statement* stat = ParseModuleItem(CHECK_OK); | 1472 Statement* stat = ParseModuleItem(CHECK_OK); |
1467 if (stat && !stat->IsEmpty()) { | 1473 if (stat && !stat->IsEmpty()) { |
1468 body->Add(stat, zone()); | 1474 body->Add(stat, zone()); |
1469 } | 1475 } |
1470 } | 1476 } |
1471 | 1477 |
1472 // Check that all exports are bound. | 1478 // Check that all exports are bound. |
1473 ModuleDescriptor* descriptor = scope_->module(); | 1479 ModuleDescriptor* descriptor = scope_->module(); |
(...skipping 2702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4176 // nested function, and hoisting works normally relative to that. | 4182 // nested function, and hoisting works normally relative to that. |
4177 Scope* declaration_scope = scope_->DeclarationScope(); | 4183 Scope* declaration_scope = scope_->DeclarationScope(); |
4178 Scope* original_declaration_scope = original_scope_->DeclarationScope(); | 4184 Scope* original_declaration_scope = original_scope_->DeclarationScope(); |
4179 Scope* scope = function_type == FunctionLiteral::DECLARATION && | 4185 Scope* scope = function_type == FunctionLiteral::DECLARATION && |
4180 is_sloppy(language_mode) && | 4186 is_sloppy(language_mode) && |
4181 !allow_harmony_sloppy_function() && | 4187 !allow_harmony_sloppy_function() && |
4182 (original_scope_ == original_declaration_scope || | 4188 (original_scope_ == original_declaration_scope || |
4183 declaration_scope != original_declaration_scope) | 4189 declaration_scope != original_declaration_scope) |
4184 ? NewScope(declaration_scope, FUNCTION_SCOPE, kind) | 4190 ? NewScope(declaration_scope, FUNCTION_SCOPE, kind) |
4185 : NewScope(scope_, FUNCTION_SCOPE, kind); | 4191 : NewScope(scope_, FUNCTION_SCOPE, kind); |
4186 scope->SetLanguageMode(language_mode); | 4192 SetLanguageMode(scope, language_mode); |
4187 ZoneList<Statement*>* body = NULL; | 4193 ZoneList<Statement*>* body = NULL; |
4188 int arity = -1; | 4194 int arity = -1; |
4189 int materialized_literal_count = -1; | 4195 int materialized_literal_count = -1; |
4190 int expected_property_count = -1; | 4196 int expected_property_count = -1; |
4191 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); | 4197 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); |
4192 ExpressionClassifier formals_classifier(&duplicate_finder); | 4198 ExpressionClassifier formals_classifier(&duplicate_finder); |
4193 FunctionLiteral::EagerCompileHint eager_compile_hint = | 4199 FunctionLiteral::EagerCompileHint eager_compile_hint = |
4194 parenthesized_function_ ? FunctionLiteral::kShouldEagerCompile | 4200 parenthesized_function_ ? FunctionLiteral::kShouldEagerCompile |
4195 : FunctionLiteral::kShouldLazyCompile; | 4201 : FunctionLiteral::kShouldLazyCompile; |
4196 bool should_be_used_once_hint = false; | 4202 bool should_be_used_once_hint = false; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4408 scanner()->SeekForward(entry.end_pos() - 1); | 4414 scanner()->SeekForward(entry.end_pos() - 1); |
4409 | 4415 |
4410 scope_->set_end_position(entry.end_pos()); | 4416 scope_->set_end_position(entry.end_pos()); |
4411 Expect(Token::RBRACE, ok); | 4417 Expect(Token::RBRACE, ok); |
4412 if (!*ok) { | 4418 if (!*ok) { |
4413 return; | 4419 return; |
4414 } | 4420 } |
4415 total_preparse_skipped_ += scope_->end_position() - function_block_pos; | 4421 total_preparse_skipped_ += scope_->end_position() - function_block_pos; |
4416 *materialized_literal_count = entry.literal_count(); | 4422 *materialized_literal_count = entry.literal_count(); |
4417 *expected_property_count = entry.property_count(); | 4423 *expected_property_count = entry.property_count(); |
4418 scope_->SetLanguageMode(entry.language_mode()); | 4424 SetLanguageMode(scope_, entry.language_mode()); |
adamk
2015/11/04 00:53:54
Why isn't this EnableLanguageMode()?
Dan Ehrenberg
2015/11/04 17:55:35
Because it doesn't bitor the language mode with th
| |
4419 if (entry.uses_super_property()) scope_->RecordSuperPropertyUsage(); | 4425 if (entry.uses_super_property()) scope_->RecordSuperPropertyUsage(); |
4420 if (entry.calls_eval()) scope_->RecordEvalCall(); | 4426 if (entry.calls_eval()) scope_->RecordEvalCall(); |
4421 return; | 4427 return; |
4422 } | 4428 } |
4423 cached_parse_data_->Reject(); | 4429 cached_parse_data_->Reject(); |
4424 } | 4430 } |
4425 // With no cached data, we partially parse the function, without building an | 4431 // With no cached data, we partially parse the function, without building an |
4426 // AST. This gathers the data needed to build a lazy function. | 4432 // AST. This gathers the data needed to build a lazy function. |
4427 SingletonLogger logger; | 4433 SingletonLogger logger; |
4428 PreParser::PreParseResult result = | 4434 PreParser::PreParseResult result = |
(...skipping 15 matching lines...) Expand all Loading... | |
4444 return; | 4450 return; |
4445 } | 4451 } |
4446 scope_->set_end_position(logger.end()); | 4452 scope_->set_end_position(logger.end()); |
4447 Expect(Token::RBRACE, ok); | 4453 Expect(Token::RBRACE, ok); |
4448 if (!*ok) { | 4454 if (!*ok) { |
4449 return; | 4455 return; |
4450 } | 4456 } |
4451 total_preparse_skipped_ += scope_->end_position() - function_block_pos; | 4457 total_preparse_skipped_ += scope_->end_position() - function_block_pos; |
4452 *materialized_literal_count = logger.literals(); | 4458 *materialized_literal_count = logger.literals(); |
4453 *expected_property_count = logger.properties(); | 4459 *expected_property_count = logger.properties(); |
4454 scope_->SetLanguageMode(logger.language_mode()); | 4460 SetLanguageMode(scope_, logger.language_mode()); |
adamk
2015/11/04 00:53:54
Same here as above, seems like this is EnableLangu
Dan Ehrenberg
2015/11/04 17:55:35
EnableLanguageMode means "the language mode should
| |
4455 if (logger.uses_super_property()) { | 4461 if (logger.uses_super_property()) { |
4456 scope_->RecordSuperPropertyUsage(); | 4462 scope_->RecordSuperPropertyUsage(); |
4457 } | 4463 } |
4458 if (logger.calls_eval()) { | 4464 if (logger.calls_eval()) { |
4459 scope_->RecordEvalCall(); | 4465 scope_->RecordEvalCall(); |
4460 } | 4466 } |
4461 if (produce_cached_parse_data()) { | 4467 if (produce_cached_parse_data()) { |
4462 DCHECK(log_); | 4468 DCHECK(log_); |
4463 // Position right after terminal '}'. | 4469 // Position right after terminal '}'. |
4464 int body_end = scanner()->location().end_pos; | 4470 int body_end = scanner()->location().end_pos; |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4737 zone()); | 4743 zone()); |
4738 } | 4744 } |
4739 } | 4745 } |
4740 | 4746 |
4741 Expect(Token::RBRACE, CHECK_OK); | 4747 Expect(Token::RBRACE, CHECK_OK); |
4742 scope_->set_end_position(scanner()->location().end_pos); | 4748 scope_->set_end_position(scanner()->location().end_pos); |
4743 | 4749 |
4744 if (!parameters.is_simple) { | 4750 if (!parameters.is_simple) { |
4745 DCHECK_NOT_NULL(inner_scope); | 4751 DCHECK_NOT_NULL(inner_scope); |
4746 DCHECK_EQ(body, inner_block->statements()); | 4752 DCHECK_EQ(body, inner_block->statements()); |
4747 scope_->SetLanguageMode(inner_scope->language_mode()); | 4753 SetLanguageMode(scope_, inner_scope->language_mode()); |
4748 Block* init_block = BuildParameterInitializationBlock(parameters, CHECK_OK); | 4754 Block* init_block = BuildParameterInitializationBlock(parameters, CHECK_OK); |
4749 DCHECK_NOT_NULL(init_block); | 4755 DCHECK_NOT_NULL(init_block); |
4750 | 4756 |
4751 inner_scope->set_end_position(scanner()->location().end_pos); | 4757 inner_scope->set_end_position(scanner()->location().end_pos); |
4752 inner_scope = inner_scope->FinalizeBlockScope(); | 4758 inner_scope = inner_scope->FinalizeBlockScope(); |
4753 if (inner_scope != nullptr) { | 4759 if (inner_scope != nullptr) { |
4754 CheckConflictingVarDeclarations(inner_scope, CHECK_OK); | 4760 CheckConflictingVarDeclarations(inner_scope, CHECK_OK); |
4755 InsertShadowingVarBindingInitializers(inner_block); | 4761 InsertShadowingVarBindingInitializers(inner_block); |
4756 } | 4762 } |
4757 | 4763 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4841 return NULL; | 4847 return NULL; |
4842 } | 4848 } |
4843 if (is_strong(language_mode()) && IsUndefined(name)) { | 4849 if (is_strong(language_mode()) && IsUndefined(name)) { |
4844 ReportMessageAt(class_name_location, MessageTemplate::kStrongUndefined); | 4850 ReportMessageAt(class_name_location, MessageTemplate::kStrongUndefined); |
4845 *ok = false; | 4851 *ok = false; |
4846 return NULL; | 4852 return NULL; |
4847 } | 4853 } |
4848 | 4854 |
4849 Scope* block_scope = NewScope(scope_, BLOCK_SCOPE); | 4855 Scope* block_scope = NewScope(scope_, BLOCK_SCOPE); |
4850 BlockState block_state(&scope_, block_scope); | 4856 BlockState block_state(&scope_, block_scope); |
4851 scope_->SetLanguageMode( | 4857 EnableLanguageMode(STRICT); |
4852 static_cast<LanguageMode>(scope_->language_mode() | STRICT)); | |
4853 scope_->SetScopeName(name); | 4858 scope_->SetScopeName(name); |
4854 | 4859 |
4855 VariableProxy* proxy = NULL; | 4860 VariableProxy* proxy = NULL; |
4856 if (name != NULL) { | 4861 if (name != NULL) { |
4857 proxy = NewUnresolved(name, CONST); | 4862 proxy = NewUnresolved(name, CONST); |
4858 const bool is_class_declaration = true; | 4863 const bool is_class_declaration = true; |
4859 Declaration* declaration = factory()->NewVariableDeclaration( | 4864 Declaration* declaration = factory()->NewVariableDeclaration( |
4860 proxy, CONST, block_scope, pos, is_class_declaration, | 4865 proxy, CONST, block_scope, pos, is_class_declaration, |
4861 scope_->class_declaration_group_start()); | 4866 scope_->class_declaration_group_start()); |
4862 Declare(declaration, DeclarationDescriptor::NORMAL, true, CHECK_OK); | 4867 Declare(declaration, DeclarationDescriptor::NORMAL, true, CHECK_OK); |
(...skipping 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6379 } | 6384 } |
6380 | 6385 |
6381 | 6386 |
6382 Expression* Parser::SpreadCallNew(Expression* function, | 6387 Expression* Parser::SpreadCallNew(Expression* function, |
6383 ZoneList<v8::internal::Expression*>* args, | 6388 ZoneList<v8::internal::Expression*>* args, |
6384 int pos) { | 6389 int pos) { |
6385 args->InsertAt(0, function, zone()); | 6390 args->InsertAt(0, function, zone()); |
6386 | 6391 |
6387 return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args, pos); | 6392 return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args, pos); |
6388 } | 6393 } |
6394 | |
6395 | |
6396 void Parser::SetLanguageMode(Scope* scope, LanguageMode mode) { | |
6397 v8::Isolate::UseCounterFeature feature; | |
6398 if (is_sloppy(mode)) | |
6399 feature = v8::Isolate::kSloppyMode; | |
6400 else if (is_strict(mode)) | |
6401 feature = v8::Isolate::kStrictMode; | |
6402 else if (is_strong(mode)) | |
adamk
2015/11/03 22:23:15
This has to go before is_strict, since strong mode
Dan Ehrenberg
2015/11/04 17:55:36
Yeah, this needs to be fixed.
Dan Ehrenberg
2015/11/04 20:27:53
Fixed
| |
6403 feature = v8::Isolate::kStrongMode; | |
6404 else | |
6405 UNREACHABLE(); | |
6406 ++use_counts_[feature]; | |
6407 scope->SetLanguageMode(mode); | |
6408 } | |
6409 | |
6410 | |
6411 void Parser::EnableLanguageMode(LanguageMode mode) { | |
6412 SetLanguageMode(scope_, | |
6413 static_cast<LanguageMode>(scope_->language_mode() | mode)); | |
6414 } | |
6415 | |
6389 } // namespace internal | 6416 } // namespace internal |
6390 } // namespace v8 | 6417 } // namespace v8 |
OLD | NEW |