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

Side by Side Diff: src/parser.cc

Issue 1070633002: [strong] Implement static restrictions on binding/assignment to 'undefined' identifier. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase 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 unified diff | Download patch
« no previous file with comments | « src/parser.h ('k') | src/preparser.h » ('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/bailout-reason.h" 9 #include "src/bailout-reason.h"
10 #include "src/base/platform/platform.h" 10 #include "src/base/platform/platform.h"
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 458
459 bool ParserTraits::IsArguments(const AstRawString* identifier) const { 459 bool ParserTraits::IsArguments(const AstRawString* identifier) const {
460 return identifier == parser_->ast_value_factory()->arguments_string(); 460 return identifier == parser_->ast_value_factory()->arguments_string();
461 } 461 }
462 462
463 463
464 bool ParserTraits::IsEvalOrArguments(const AstRawString* identifier) const { 464 bool ParserTraits::IsEvalOrArguments(const AstRawString* identifier) const {
465 return IsEval(identifier) || IsArguments(identifier); 465 return IsEval(identifier) || IsArguments(identifier);
466 } 466 }
467 467
468 bool ParserTraits::IsUndefined(const AstRawString* identifier) const {
469 return identifier == parser_->ast_value_factory()->undefined_string();
470 }
468 471
469 bool ParserTraits::IsPrototype(const AstRawString* identifier) const { 472 bool ParserTraits::IsPrototype(const AstRawString* identifier) const {
470 return identifier == parser_->ast_value_factory()->prototype_string(); 473 return identifier == parser_->ast_value_factory()->prototype_string();
471 } 474 }
472 475
473 476
474 bool ParserTraits::IsConstructor(const AstRawString* identifier) const { 477 bool ParserTraits::IsConstructor(const AstRawString* identifier) const {
475 return identifier == parser_->ast_value_factory()->constructor_string(); 478 return identifier == parser_->ast_value_factory()->constructor_string();
476 } 479 }
477 480
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after
1469 local_name = ParseIdentifierName(CHECK_OK); 1472 local_name = ParseIdentifierName(CHECK_OK);
1470 } 1473 }
1471 if (!Token::IsIdentifier(scanner()->current_token(), STRICT, false)) { 1474 if (!Token::IsIdentifier(scanner()->current_token(), STRICT, false)) {
1472 *ok = false; 1475 *ok = false;
1473 ReportMessage("unexpected_reserved"); 1476 ReportMessage("unexpected_reserved");
1474 return NULL; 1477 return NULL;
1475 } else if (IsEvalOrArguments(local_name)) { 1478 } else if (IsEvalOrArguments(local_name)) {
1476 *ok = false; 1479 *ok = false;
1477 ReportMessage("strict_eval_arguments"); 1480 ReportMessage("strict_eval_arguments");
1478 return NULL; 1481 return NULL;
1482 } else if (is_strong(language_mode()) && IsUndefined(local_name)) {
1483 *ok = false;
1484 ReportMessage("strong_undefined");
1485 return NULL;
1479 } 1486 }
1480 VariableProxy* proxy = NewUnresolved(local_name, IMPORT); 1487 VariableProxy* proxy = NewUnresolved(local_name, IMPORT);
1481 ImportDeclaration* declaration = 1488 ImportDeclaration* declaration =
1482 factory()->NewImportDeclaration(proxy, import_name, NULL, scope_, pos); 1489 factory()->NewImportDeclaration(proxy, import_name, NULL, scope_, pos);
1483 Declare(declaration, true, CHECK_OK); 1490 Declare(declaration, true, CHECK_OK);
1484 result->Add(declaration, zone()); 1491 result->Add(declaration, zone());
1485 if (peek() == Token::RBRACE) break; 1492 if (peek() == Token::RBRACE) break;
1486 Expect(Token::COMMA, CHECK_OK); 1493 Expect(Token::COMMA, CHECK_OK);
1487 } 1494 }
1488 1495
(...skipping 29 matching lines...) Expand all
1518 ExpectSemicolon(CHECK_OK); 1525 ExpectSemicolon(CHECK_OK);
1519 // TODO(ES6): Add module to the requested modules of scope_->module(). 1526 // TODO(ES6): Add module to the requested modules of scope_->module().
1520 USE(module_specifier); 1527 USE(module_specifier);
1521 return factory()->NewEmptyStatement(pos); 1528 return factory()->NewEmptyStatement(pos);
1522 } 1529 }
1523 1530
1524 // Parse ImportedDefaultBinding if present. 1531 // Parse ImportedDefaultBinding if present.
1525 ImportDeclaration* import_default_declaration = NULL; 1532 ImportDeclaration* import_default_declaration = NULL;
1526 if (tok != Token::MUL && tok != Token::LBRACE) { 1533 if (tok != Token::MUL && tok != Token::LBRACE) {
1527 const AstRawString* local_name = 1534 const AstRawString* local_name =
1528 ParseIdentifier(kDontAllowEvalOrArguments, CHECK_OK); 1535 ParseIdentifier(kDontAllowRestrictedIdentifiers, CHECK_OK);
1529 VariableProxy* proxy = NewUnresolved(local_name, IMPORT); 1536 VariableProxy* proxy = NewUnresolved(local_name, IMPORT);
1530 import_default_declaration = factory()->NewImportDeclaration( 1537 import_default_declaration = factory()->NewImportDeclaration(
1531 proxy, ast_value_factory()->default_string(), NULL, scope_, pos); 1538 proxy, ast_value_factory()->default_string(), NULL, scope_, pos);
1532 Declare(import_default_declaration, true, CHECK_OK); 1539 Declare(import_default_declaration, true, CHECK_OK);
1533 } 1540 }
1534 1541
1535 const AstRawString* module_instance_binding = NULL; 1542 const AstRawString* module_instance_binding = NULL;
1536 ZoneList<ImportDeclaration*>* named_declarations = NULL; 1543 ZoneList<ImportDeclaration*>* named_declarations = NULL;
1537 if (import_default_declaration == NULL || Check(Token::COMMA)) { 1544 if (import_default_declaration == NULL || Check(Token::COMMA)) {
1538 switch (peek()) { 1545 switch (peek()) {
1539 case Token::MUL: { 1546 case Token::MUL: {
1540 Consume(Token::MUL); 1547 Consume(Token::MUL);
1541 ExpectContextualKeyword(CStrVector("as"), CHECK_OK); 1548 ExpectContextualKeyword(CStrVector("as"), CHECK_OK);
1542 module_instance_binding = 1549 module_instance_binding =
1543 ParseIdentifier(kDontAllowEvalOrArguments, CHECK_OK); 1550 ParseIdentifier(kDontAllowRestrictedIdentifiers, CHECK_OK);
1544 // TODO(ES6): Add an appropriate declaration. 1551 // TODO(ES6): Add an appropriate declaration.
1545 break; 1552 break;
1546 } 1553 }
1547 1554
1548 case Token::LBRACE: 1555 case Token::LBRACE:
1549 named_declarations = ParseNamedImports(pos, CHECK_OK); 1556 named_declarations = ParseNamedImports(pos, CHECK_OK);
1550 break; 1557 break;
1551 1558
1552 default: 1559 default:
1553 *ok = false; 1560 *ok = false;
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
2026 2033
2027 2034
2028 // Language extension which is only enabled for source files loaded 2035 // Language extension which is only enabled for source files loaded
2029 // through the API's extension mechanism. A native function 2036 // through the API's extension mechanism. A native function
2030 // declaration is resolved by looking up the function through a 2037 // declaration is resolved by looking up the function through a
2031 // callback provided by the extension. 2038 // callback provided by the extension.
2032 Statement* Parser::ParseNativeDeclaration(bool* ok) { 2039 Statement* Parser::ParseNativeDeclaration(bool* ok) {
2033 int pos = peek_position(); 2040 int pos = peek_position();
2034 Expect(Token::FUNCTION, CHECK_OK); 2041 Expect(Token::FUNCTION, CHECK_OK);
2035 // Allow "eval" or "arguments" for backward compatibility. 2042 // Allow "eval" or "arguments" for backward compatibility.
2036 const AstRawString* name = ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); 2043 const AstRawString* name =
2044 ParseIdentifier(kAllowRestrictedIdentifiers, CHECK_OK);
2037 Expect(Token::LPAREN, CHECK_OK); 2045 Expect(Token::LPAREN, CHECK_OK);
2038 bool done = (peek() == Token::RPAREN); 2046 bool done = (peek() == Token::RPAREN);
2039 while (!done) { 2047 while (!done) {
2040 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); 2048 ParseIdentifier(kAllowRestrictedIdentifiers, CHECK_OK);
2041 done = (peek() == Token::RPAREN); 2049 done = (peek() == Token::RPAREN);
2042 if (!done) { 2050 if (!done) {
2043 Expect(Token::COMMA, CHECK_OK); 2051 Expect(Token::COMMA, CHECK_OK);
2044 } 2052 }
2045 } 2053 }
2046 Expect(Token::RPAREN, CHECK_OK); 2054 Expect(Token::RPAREN, CHECK_OK);
2047 Expect(Token::SEMICOLON, CHECK_OK); 2055 Expect(Token::SEMICOLON, CHECK_OK);
2048 2056
2049 // Make sure that the function containing the native declaration 2057 // Make sure that the function containing the native declaration
2050 // isn't lazily compiled. The extension structures are only 2058 // isn't lazily compiled. The extension structures are only
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
2312 int nvars = 0; // the number of variables declared 2320 int nvars = 0; // the number of variables declared
2313 int bindings_start = peek_position(); 2321 int bindings_start = peek_position();
2314 const AstRawString* name = NULL; 2322 const AstRawString* name = NULL;
2315 const AstRawString* first_name = NULL; 2323 const AstRawString* first_name = NULL;
2316 bool is_for_iteration_variable; 2324 bool is_for_iteration_variable;
2317 do { 2325 do {
2318 if (fni_ != NULL) fni_->Enter(); 2326 if (fni_ != NULL) fni_->Enter();
2319 2327
2320 // Parse variable name. 2328 // Parse variable name.
2321 if (nvars > 0) Consume(Token::COMMA); 2329 if (nvars > 0) Consume(Token::COMMA);
2322 name = ParseIdentifier(kDontAllowEvalOrArguments, CHECK_OK); 2330 name = ParseIdentifier(kDontAllowRestrictedIdentifiers, CHECK_OK);
2323 if (!first_name) first_name = name; 2331 if (!first_name) first_name = name;
2324 Scanner::Location variable_loc = scanner()->location(); 2332 Scanner::Location variable_loc = scanner()->location();
2325 if (fni_ != NULL) fni_->PushVariableName(name); 2333 if (fni_ != NULL) fni_->PushVariableName(name);
2326 2334
2327 // Declare variable. 2335 // Declare variable.
2328 // Note that we *always* must treat the initial value via a separate init 2336 // Note that we *always* must treat the initial value via a separate init
2329 // assignment for variables and constants because the value must be assigned 2337 // assignment for variables and constants because the value must be assigned
2330 // when the variable is encountered in the source. But the variable/constant 2338 // when the variable is encountered in the source. But the variable/constant
2331 // is declared (and set to 'undefined') upon entering the function within 2339 // is declared (and set to 'undefined') upon entering the function within
2332 // which the variable or constant is declared. Only function variables have 2340 // which the variable or constant is declared. Only function variables have
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
2664 // ContinueStatement :: 2672 // ContinueStatement ::
2665 // 'continue' Identifier? ';' 2673 // 'continue' Identifier? ';'
2666 2674
2667 int pos = peek_position(); 2675 int pos = peek_position();
2668 Expect(Token::CONTINUE, CHECK_OK); 2676 Expect(Token::CONTINUE, CHECK_OK);
2669 const AstRawString* label = NULL; 2677 const AstRawString* label = NULL;
2670 Token::Value tok = peek(); 2678 Token::Value tok = peek();
2671 if (!scanner()->HasAnyLineTerminatorBeforeNext() && 2679 if (!scanner()->HasAnyLineTerminatorBeforeNext() &&
2672 tok != Token::SEMICOLON && tok != Token::RBRACE && tok != Token::EOS) { 2680 tok != Token::SEMICOLON && tok != Token::RBRACE && tok != Token::EOS) {
2673 // ECMA allows "eval" or "arguments" as labels even in strict mode. 2681 // ECMA allows "eval" or "arguments" as labels even in strict mode.
2674 label = ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); 2682 label = ParseIdentifier(kAllowRestrictedIdentifiers, CHECK_OK);
2675 } 2683 }
2676 IterationStatement* target = LookupContinueTarget(label, CHECK_OK); 2684 IterationStatement* target = LookupContinueTarget(label, CHECK_OK);
2677 if (target == NULL) { 2685 if (target == NULL) {
2678 // Illegal continue statement. 2686 // Illegal continue statement.
2679 const char* message = "illegal_continue"; 2687 const char* message = "illegal_continue";
2680 if (label != NULL) { 2688 if (label != NULL) {
2681 message = "unknown_label"; 2689 message = "unknown_label";
2682 } 2690 }
2683 ParserTraits::ReportMessage(message, label); 2691 ParserTraits::ReportMessage(message, label);
2684 *ok = false; 2692 *ok = false;
2685 return NULL; 2693 return NULL;
2686 } 2694 }
2687 ExpectSemicolon(CHECK_OK); 2695 ExpectSemicolon(CHECK_OK);
2688 return factory()->NewContinueStatement(target, pos); 2696 return factory()->NewContinueStatement(target, pos);
2689 } 2697 }
2690 2698
2691 2699
2692 Statement* Parser::ParseBreakStatement(ZoneList<const AstRawString*>* labels, 2700 Statement* Parser::ParseBreakStatement(ZoneList<const AstRawString*>* labels,
2693 bool* ok) { 2701 bool* ok) {
2694 // BreakStatement :: 2702 // BreakStatement ::
2695 // 'break' Identifier? ';' 2703 // 'break' Identifier? ';'
2696 2704
2697 int pos = peek_position(); 2705 int pos = peek_position();
2698 Expect(Token::BREAK, CHECK_OK); 2706 Expect(Token::BREAK, CHECK_OK);
2699 const AstRawString* label = NULL; 2707 const AstRawString* label = NULL;
2700 Token::Value tok = peek(); 2708 Token::Value tok = peek();
2701 if (!scanner()->HasAnyLineTerminatorBeforeNext() && 2709 if (!scanner()->HasAnyLineTerminatorBeforeNext() &&
2702 tok != Token::SEMICOLON && tok != Token::RBRACE && tok != Token::EOS) { 2710 tok != Token::SEMICOLON && tok != Token::RBRACE && tok != Token::EOS) {
2703 // ECMA allows "eval" or "arguments" as labels even in strict mode. 2711 // ECMA allows "eval" or "arguments" as labels even in strict mode.
2704 label = ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); 2712 label = ParseIdentifier(kAllowRestrictedIdentifiers, CHECK_OK);
2705 } 2713 }
2706 // Parse labeled break statements that target themselves into 2714 // Parse labeled break statements that target themselves into
2707 // empty statements, e.g. 'l1: l2: l3: break l2;' 2715 // empty statements, e.g. 'l1: l2: l3: break l2;'
2708 if (label != NULL && ContainsLabel(labels, label)) { 2716 if (label != NULL && ContainsLabel(labels, label)) {
2709 ExpectSemicolon(CHECK_OK); 2717 ExpectSemicolon(CHECK_OK);
2710 return factory()->NewEmptyStatement(pos); 2718 return factory()->NewEmptyStatement(pos);
2711 } 2719 }
2712 BreakableStatement* target = NULL; 2720 BreakableStatement* target = NULL;
2713 target = LookupBreakTarget(label, CHECK_OK); 2721 target = LookupBreakTarget(label, CHECK_OK);
2714 if (target == NULL) { 2722 if (target == NULL) {
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
2919 Scope* catch_scope = NULL; 2927 Scope* catch_scope = NULL;
2920 Variable* catch_variable = NULL; 2928 Variable* catch_variable = NULL;
2921 Block* catch_block = NULL; 2929 Block* catch_block = NULL;
2922 const AstRawString* name = NULL; 2930 const AstRawString* name = NULL;
2923 if (tok == Token::CATCH) { 2931 if (tok == Token::CATCH) {
2924 Consume(Token::CATCH); 2932 Consume(Token::CATCH);
2925 2933
2926 Expect(Token::LPAREN, CHECK_OK); 2934 Expect(Token::LPAREN, CHECK_OK);
2927 catch_scope = NewScope(scope_, CATCH_SCOPE); 2935 catch_scope = NewScope(scope_, CATCH_SCOPE);
2928 catch_scope->set_start_position(scanner()->location().beg_pos); 2936 catch_scope->set_start_position(scanner()->location().beg_pos);
2929 name = ParseIdentifier(kDontAllowEvalOrArguments, CHECK_OK); 2937 name = ParseIdentifier(kDontAllowRestrictedIdentifiers, CHECK_OK);
2930 2938
2931 Expect(Token::RPAREN, CHECK_OK); 2939 Expect(Token::RPAREN, CHECK_OK);
2932 2940
2933 catch_variable = catch_scope->DeclareLocal(name, VAR, kCreatedInitialized, 2941 catch_variable = catch_scope->DeclareLocal(name, VAR, kCreatedInitialized,
2934 Variable::NORMAL); 2942 Variable::NORMAL);
2935 BlockState block_state(&scope_, catch_scope); 2943 BlockState block_state(&scope_, catch_scope);
2936 catch_block = ParseBlock(NULL, CHECK_OK); 2944 catch_block = ParseBlock(NULL, CHECK_OK);
2937 2945
2938 catch_scope->set_end_position(scanner()->location().end_pos); 2946 catch_scope->set_end_position(scanner()->location().end_pos);
2939 tok = peek(); 2947 tok = peek();
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after
3866 Expect(Token::LPAREN, CHECK_OK); 3874 Expect(Token::LPAREN, CHECK_OK);
3867 scope->set_start_position(scanner()->location().beg_pos); 3875 scope->set_start_position(scanner()->location().beg_pos);
3868 3876
3869 // We don't yet know if the function will be strict, so we cannot yet 3877 // We don't yet know if the function will be strict, so we cannot yet
3870 // produce errors for parameter names or duplicates. However, we remember 3878 // produce errors for parameter names or duplicates. However, we remember
3871 // the locations of these errors if they occur and produce the errors later. 3879 // the locations of these errors if they occur and produce the errors later.
3872 Scanner::Location eval_args_error_loc = Scanner::Location::invalid(); 3880 Scanner::Location eval_args_error_loc = Scanner::Location::invalid();
3873 Scanner::Location dupe_error_loc = Scanner::Location::invalid(); 3881 Scanner::Location dupe_error_loc = Scanner::Location::invalid();
3874 Scanner::Location reserved_error_loc = Scanner::Location::invalid(); 3882 Scanner::Location reserved_error_loc = Scanner::Location::invalid();
3875 3883
3884 // Similarly for strong mode.
3885 Scanner::Location undefined_error_loc = Scanner::Location::invalid();
3886
3876 bool is_rest = false; 3887 bool is_rest = false;
3877 bool done = arity_restriction == FunctionLiteral::GETTER_ARITY || 3888 bool done = arity_restriction == FunctionLiteral::GETTER_ARITY ||
3878 (peek() == Token::RPAREN && 3889 (peek() == Token::RPAREN &&
3879 arity_restriction != FunctionLiteral::SETTER_ARITY); 3890 arity_restriction != FunctionLiteral::SETTER_ARITY);
3880 while (!done) { 3891 while (!done) {
3881 bool is_strict_reserved = false; 3892 bool is_strict_reserved = false;
3882 is_rest = peek() == Token::ELLIPSIS && allow_harmony_rest_params(); 3893 is_rest = peek() == Token::ELLIPSIS && allow_harmony_rest_params();
3883 if (is_rest) { 3894 if (is_rest) {
3884 Consume(Token::ELLIPSIS); 3895 Consume(Token::ELLIPSIS);
3885 } 3896 }
3886 3897
3887 const AstRawString* param_name = 3898 const AstRawString* param_name =
3888 ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK); 3899 ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK);
3889 3900
3890 // Store locations for possible future error reports. 3901 // Store locations for possible future error reports.
3891 if (!eval_args_error_loc.IsValid() && IsEvalOrArguments(param_name)) { 3902 if (!eval_args_error_loc.IsValid() && IsEvalOrArguments(param_name)) {
3892 eval_args_error_loc = scanner()->location(); 3903 eval_args_error_loc = scanner()->location();
3893 } 3904 }
3905 if (!undefined_error_loc.IsValid() && IsUndefined(param_name)) {
3906 undefined_error_loc = scanner()->location();
3907 }
3894 if (!reserved_error_loc.IsValid() && is_strict_reserved) { 3908 if (!reserved_error_loc.IsValid() && is_strict_reserved) {
3895 reserved_error_loc = scanner()->location(); 3909 reserved_error_loc = scanner()->location();
3896 } 3910 }
3897 if (!dupe_error_loc.IsValid() && 3911 if (!dupe_error_loc.IsValid() &&
3898 scope_->IsDeclaredParameter(param_name)) { 3912 scope_->IsDeclaredParameter(param_name)) {
3899 duplicate_parameters = FunctionLiteral::kHasDuplicateParameters; 3913 duplicate_parameters = FunctionLiteral::kHasDuplicateParameters;
3900 dupe_error_loc = scanner()->location(); 3914 dupe_error_loc = scanner()->location();
3901 } 3915 }
3902 3916
3903 Variable* var = scope_->DeclareParameter(param_name, VAR, is_rest); 3917 Variable* var = scope_->DeclareParameter(param_name, VAR, is_rest);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
4002 handler_count = function_state.handler_count(); 4016 handler_count = function_state.handler_count();
4003 } 4017 }
4004 4018
4005 // Validate name and parameter names. We can do this only after parsing the 4019 // Validate name and parameter names. We can do this only after parsing the
4006 // function, since the function can declare itself strict. 4020 // function, since the function can declare itself strict.
4007 CheckFunctionName(language_mode(), kind, function_name, 4021 CheckFunctionName(language_mode(), kind, function_name,
4008 name_is_strict_reserved, function_name_location, 4022 name_is_strict_reserved, function_name_location,
4009 CHECK_OK); 4023 CHECK_OK);
4010 const bool use_strict_params = is_rest || IsConciseMethod(kind); 4024 const bool use_strict_params = is_rest || IsConciseMethod(kind);
4011 CheckFunctionParameterNames(language_mode(), use_strict_params, 4025 CheckFunctionParameterNames(language_mode(), use_strict_params,
4012 eval_args_error_loc, dupe_error_loc, 4026 eval_args_error_loc, undefined_error_loc,
4013 reserved_error_loc, CHECK_OK); 4027 dupe_error_loc, reserved_error_loc, CHECK_OK);
4014 4028
4015 if (is_strict(language_mode())) { 4029 if (is_strict(language_mode())) {
4016 CheckStrictOctalLiteral(scope->start_position(), scope->end_position(), 4030 CheckStrictOctalLiteral(scope->start_position(), scope->end_position(),
4017 CHECK_OK); 4031 CHECK_OK);
4018 } 4032 }
4019 if (is_strict(language_mode())) { 4033 if (is_strict(language_mode())) {
4020 CheckConflictingVarDeclarations(scope, CHECK_OK); 4034 CheckConflictingVarDeclarations(scope, CHECK_OK);
4021 } 4035 }
4022 if (is_strong(language_mode()) && IsSubclassConstructor(kind)) { 4036 if (is_strong(language_mode()) && IsSubclassConstructor(kind)) {
4023 if (!function_state.super_call_location().IsValid()) { 4037 if (!function_state.super_call_location().IsValid()) {
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
4257 if (name_is_strict_reserved) { 4271 if (name_is_strict_reserved) {
4258 ReportMessageAt(class_name_location, "unexpected_strict_reserved"); 4272 ReportMessageAt(class_name_location, "unexpected_strict_reserved");
4259 *ok = false; 4273 *ok = false;
4260 return NULL; 4274 return NULL;
4261 } 4275 }
4262 if (IsEvalOrArguments(name)) { 4276 if (IsEvalOrArguments(name)) {
4263 ReportMessageAt(class_name_location, "strict_eval_arguments"); 4277 ReportMessageAt(class_name_location, "strict_eval_arguments");
4264 *ok = false; 4278 *ok = false;
4265 return NULL; 4279 return NULL;
4266 } 4280 }
4281 if (is_strong(language_mode()) && IsUndefined(name)) {
4282 ReportMessageAt(class_name_location, "strong_undefined");
4283 *ok = false;
4284 return NULL;
4285 }
4267 4286
4268 // Create a block scope which is additionally tagged as class scope; this is 4287 // Create a block scope which is additionally tagged as class scope; this is
4269 // important for resolving variable references to the class name in the strong 4288 // important for resolving variable references to the class name in the strong
4270 // mode. 4289 // mode.
4271 Scope* block_scope = NewScope(scope_, BLOCK_SCOPE); 4290 Scope* block_scope = NewScope(scope_, BLOCK_SCOPE);
4272 block_scope->tag_as_class_scope(); 4291 block_scope->tag_as_class_scope();
4273 BlockState block_state(&scope_, block_scope); 4292 BlockState block_state(&scope_, block_scope);
4274 scope_->SetLanguageMode( 4293 scope_->SetLanguageMode(
4275 static_cast<LanguageMode>(scope_->language_mode() | STRICT_BIT)); 4294 static_cast<LanguageMode>(scope_->language_mode() | STRICT_BIT));
4276 scope_->SetScopeName(name); 4295 scope_->SetScopeName(name);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
4348 } 4367 }
4349 4368
4350 4369
4351 Expression* Parser::ParseV8Intrinsic(bool* ok) { 4370 Expression* Parser::ParseV8Intrinsic(bool* ok) {
4352 // CallRuntime :: 4371 // CallRuntime ::
4353 // '%' Identifier Arguments 4372 // '%' Identifier Arguments
4354 4373
4355 int pos = peek_position(); 4374 int pos = peek_position();
4356 Expect(Token::MOD, CHECK_OK); 4375 Expect(Token::MOD, CHECK_OK);
4357 // Allow "eval" or "arguments" for backward compatibility. 4376 // Allow "eval" or "arguments" for backward compatibility.
4358 const AstRawString* name = ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); 4377 const AstRawString* name = ParseIdentifier(kAllowRestrictedIdentifiers,
4378 CHECK_OK);
4359 Scanner::Location spread_pos; 4379 Scanner::Location spread_pos;
4360 ZoneList<Expression*>* args = ParseArguments(&spread_pos, CHECK_OK); 4380 ZoneList<Expression*>* args = ParseArguments(&spread_pos, CHECK_OK);
4361 4381
4362 DCHECK(!spread_pos.IsValid()); 4382 DCHECK(!spread_pos.IsValid());
4363 4383
4364 if (extension_ != NULL) { 4384 if (extension_ != NULL) {
4365 // The extension structures are only accessible while parsing the 4385 // The extension structures are only accessible while parsing the
4366 // very first time not when reparsing because of lazy compilation. 4386 // very first time not when reparsing because of lazy compilation.
4367 scope_->DeclarationScope()->ForceEagerCompilation(); 4387 scope_->DeclarationScope()->ForceEagerCompilation();
4368 } 4388 }
(...skipping 1366 matching lines...) Expand 10 before | Expand all | Expand 10 after
5735 5755
5736 Expression* Parser::SpreadCallNew(Expression* function, 5756 Expression* Parser::SpreadCallNew(Expression* function,
5737 ZoneList<v8::internal::Expression*>* args, 5757 ZoneList<v8::internal::Expression*>* args,
5738 int pos) { 5758 int pos) {
5739 args->InsertAt(0, function, zone()); 5759 args->InsertAt(0, function, zone());
5740 5760
5741 return factory()->NewCallRuntime( 5761 return factory()->NewCallRuntime(
5742 ast_value_factory()->reflect_construct_string(), NULL, args, pos); 5762 ast_value_factory()->reflect_construct_string(), NULL, args, pos);
5743 } 5763 }
5744 } } // namespace v8::internal 5764 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/parser.h ('k') | src/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698