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/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 Loading... |
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 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1468 local_name = ParseIdentifierName(CHECK_OK); | 1471 local_name = ParseIdentifierName(CHECK_OK); |
1469 } | 1472 } |
1470 if (!Token::IsIdentifier(scanner()->current_token(), STRICT, false)) { | 1473 if (!Token::IsIdentifier(scanner()->current_token(), STRICT, false)) { |
1471 *ok = false; | 1474 *ok = false; |
1472 ReportMessage("unexpected_reserved"); | 1475 ReportMessage("unexpected_reserved"); |
1473 return NULL; | 1476 return NULL; |
1474 } else if (IsEvalOrArguments(local_name)) { | 1477 } else if (IsEvalOrArguments(local_name)) { |
1475 *ok = false; | 1478 *ok = false; |
1476 ReportMessage("strict_eval_arguments"); | 1479 ReportMessage("strict_eval_arguments"); |
1477 return NULL; | 1480 return NULL; |
| 1481 } else if (is_strong(language_mode()) && IsUndefined(local_name)) { |
| 1482 *ok = false; |
| 1483 ReportMessage("strong_undefined"); |
| 1484 return NULL; |
1478 } | 1485 } |
1479 VariableProxy* proxy = NewUnresolved(local_name, IMPORT); | 1486 VariableProxy* proxy = NewUnresolved(local_name, IMPORT); |
1480 ImportDeclaration* declaration = | 1487 ImportDeclaration* declaration = |
1481 factory()->NewImportDeclaration(proxy, import_name, NULL, scope_, pos); | 1488 factory()->NewImportDeclaration(proxy, import_name, NULL, scope_, pos); |
1482 Declare(declaration, true, CHECK_OK); | 1489 Declare(declaration, true, CHECK_OK); |
1483 result->Add(declaration, zone()); | 1490 result->Add(declaration, zone()); |
1484 if (peek() == Token::RBRACE) break; | 1491 if (peek() == Token::RBRACE) break; |
1485 Expect(Token::COMMA, CHECK_OK); | 1492 Expect(Token::COMMA, CHECK_OK); |
1486 } | 1493 } |
1487 | 1494 |
(...skipping 29 matching lines...) Expand all Loading... |
1517 ExpectSemicolon(CHECK_OK); | 1524 ExpectSemicolon(CHECK_OK); |
1518 // TODO(ES6): Add module to the requested modules of scope_->module(). | 1525 // TODO(ES6): Add module to the requested modules of scope_->module(). |
1519 USE(module_specifier); | 1526 USE(module_specifier); |
1520 return factory()->NewEmptyStatement(pos); | 1527 return factory()->NewEmptyStatement(pos); |
1521 } | 1528 } |
1522 | 1529 |
1523 // Parse ImportedDefaultBinding if present. | 1530 // Parse ImportedDefaultBinding if present. |
1524 ImportDeclaration* import_default_declaration = NULL; | 1531 ImportDeclaration* import_default_declaration = NULL; |
1525 if (tok != Token::MUL && tok != Token::LBRACE) { | 1532 if (tok != Token::MUL && tok != Token::LBRACE) { |
1526 const AstRawString* local_name = | 1533 const AstRawString* local_name = |
1527 ParseIdentifier(kDontAllowEvalOrArguments, CHECK_OK); | 1534 ParseIdentifier(kDontAllowRestrictedIdentifiers, CHECK_OK); |
1528 VariableProxy* proxy = NewUnresolved(local_name, IMPORT); | 1535 VariableProxy* proxy = NewUnresolved(local_name, IMPORT); |
1529 import_default_declaration = factory()->NewImportDeclaration( | 1536 import_default_declaration = factory()->NewImportDeclaration( |
1530 proxy, ast_value_factory()->default_string(), NULL, scope_, pos); | 1537 proxy, ast_value_factory()->default_string(), NULL, scope_, pos); |
1531 Declare(import_default_declaration, true, CHECK_OK); | 1538 Declare(import_default_declaration, true, CHECK_OK); |
1532 } | 1539 } |
1533 | 1540 |
1534 const AstRawString* module_instance_binding = NULL; | 1541 const AstRawString* module_instance_binding = NULL; |
1535 ZoneList<ImportDeclaration*>* named_declarations = NULL; | 1542 ZoneList<ImportDeclaration*>* named_declarations = NULL; |
1536 if (import_default_declaration == NULL || Check(Token::COMMA)) { | 1543 if (import_default_declaration == NULL || Check(Token::COMMA)) { |
1537 switch (peek()) { | 1544 switch (peek()) { |
1538 case Token::MUL: { | 1545 case Token::MUL: { |
1539 Consume(Token::MUL); | 1546 Consume(Token::MUL); |
1540 ExpectContextualKeyword(CStrVector("as"), CHECK_OK); | 1547 ExpectContextualKeyword(CStrVector("as"), CHECK_OK); |
1541 module_instance_binding = | 1548 module_instance_binding = |
1542 ParseIdentifier(kDontAllowEvalOrArguments, CHECK_OK); | 1549 ParseIdentifier(kDontAllowRestrictedIdentifiers, CHECK_OK); |
1543 // TODO(ES6): Add an appropriate declaration. | 1550 // TODO(ES6): Add an appropriate declaration. |
1544 break; | 1551 break; |
1545 } | 1552 } |
1546 | 1553 |
1547 case Token::LBRACE: | 1554 case Token::LBRACE: |
1548 named_declarations = ParseNamedImports(pos, CHECK_OK); | 1555 named_declarations = ParseNamedImports(pos, CHECK_OK); |
1549 break; | 1556 break; |
1550 | 1557 |
1551 default: | 1558 default: |
1552 *ok = false; | 1559 *ok = false; |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2021 | 2028 |
2022 | 2029 |
2023 // Language extension which is only enabled for source files loaded | 2030 // Language extension which is only enabled for source files loaded |
2024 // through the API's extension mechanism. A native function | 2031 // through the API's extension mechanism. A native function |
2025 // declaration is resolved by looking up the function through a | 2032 // declaration is resolved by looking up the function through a |
2026 // callback provided by the extension. | 2033 // callback provided by the extension. |
2027 Statement* Parser::ParseNativeDeclaration(bool* ok) { | 2034 Statement* Parser::ParseNativeDeclaration(bool* ok) { |
2028 int pos = peek_position(); | 2035 int pos = peek_position(); |
2029 Expect(Token::FUNCTION, CHECK_OK); | 2036 Expect(Token::FUNCTION, CHECK_OK); |
2030 // Allow "eval" or "arguments" for backward compatibility. | 2037 // Allow "eval" or "arguments" for backward compatibility. |
2031 const AstRawString* name = ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); | 2038 const AstRawString* name = |
| 2039 ParseIdentifier(kAllowRestrictedIdentifiers, CHECK_OK); |
2032 Expect(Token::LPAREN, CHECK_OK); | 2040 Expect(Token::LPAREN, CHECK_OK); |
2033 bool done = (peek() == Token::RPAREN); | 2041 bool done = (peek() == Token::RPAREN); |
2034 while (!done) { | 2042 while (!done) { |
2035 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); | 2043 ParseIdentifier(kAllowRestrictedIdentifiers, CHECK_OK); |
2036 done = (peek() == Token::RPAREN); | 2044 done = (peek() == Token::RPAREN); |
2037 if (!done) { | 2045 if (!done) { |
2038 Expect(Token::COMMA, CHECK_OK); | 2046 Expect(Token::COMMA, CHECK_OK); |
2039 } | 2047 } |
2040 } | 2048 } |
2041 Expect(Token::RPAREN, CHECK_OK); | 2049 Expect(Token::RPAREN, CHECK_OK); |
2042 Expect(Token::SEMICOLON, CHECK_OK); | 2050 Expect(Token::SEMICOLON, CHECK_OK); |
2043 | 2051 |
2044 // Make sure that the function containing the native declaration | 2052 // Make sure that the function containing the native declaration |
2045 // isn't lazily compiled. The extension structures are only | 2053 // isn't lazily compiled. The extension structures are only |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2304 // Create new block with one expected declaration. | 2312 // Create new block with one expected declaration. |
2305 Block* block = factory()->NewBlock(NULL, 1, true, pos); | 2313 Block* block = factory()->NewBlock(NULL, 1, true, pos); |
2306 int nvars = 0; // the number of variables declared | 2314 int nvars = 0; // the number of variables declared |
2307 const AstRawString* name = NULL; | 2315 const AstRawString* name = NULL; |
2308 bool is_for_iteration_variable; | 2316 bool is_for_iteration_variable; |
2309 do { | 2317 do { |
2310 if (fni_ != NULL) fni_->Enter(); | 2318 if (fni_ != NULL) fni_->Enter(); |
2311 | 2319 |
2312 // Parse variable name. | 2320 // Parse variable name. |
2313 if (nvars > 0) Consume(Token::COMMA); | 2321 if (nvars > 0) Consume(Token::COMMA); |
2314 name = ParseIdentifier(kDontAllowEvalOrArguments, CHECK_OK); | 2322 name = ParseIdentifier(kDontAllowRestrictedIdentifiers, CHECK_OK); |
2315 Scanner::Location variable_loc = scanner()->location(); | 2323 Scanner::Location variable_loc = scanner()->location(); |
2316 if (fni_ != NULL) fni_->PushVariableName(name); | 2324 if (fni_ != NULL) fni_->PushVariableName(name); |
2317 | 2325 |
2318 // Declare variable. | 2326 // Declare variable. |
2319 // Note that we *always* must treat the initial value via a separate init | 2327 // Note that we *always* must treat the initial value via a separate init |
2320 // assignment for variables and constants because the value must be assigned | 2328 // assignment for variables and constants because the value must be assigned |
2321 // when the variable is encountered in the source. But the variable/constant | 2329 // when the variable is encountered in the source. But the variable/constant |
2322 // is declared (and set to 'undefined') upon entering the function within | 2330 // is declared (and set to 'undefined') upon entering the function within |
2323 // which the variable or constant is declared. Only function variables have | 2331 // which the variable or constant is declared. Only function variables have |
2324 // an initial value in the declaration (because they are initialized upon | 2332 // an initial value in the declaration (because they are initialized upon |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2653 // ContinueStatement :: | 2661 // ContinueStatement :: |
2654 // 'continue' Identifier? ';' | 2662 // 'continue' Identifier? ';' |
2655 | 2663 |
2656 int pos = peek_position(); | 2664 int pos = peek_position(); |
2657 Expect(Token::CONTINUE, CHECK_OK); | 2665 Expect(Token::CONTINUE, CHECK_OK); |
2658 const AstRawString* label = NULL; | 2666 const AstRawString* label = NULL; |
2659 Token::Value tok = peek(); | 2667 Token::Value tok = peek(); |
2660 if (!scanner()->HasAnyLineTerminatorBeforeNext() && | 2668 if (!scanner()->HasAnyLineTerminatorBeforeNext() && |
2661 tok != Token::SEMICOLON && tok != Token::RBRACE && tok != Token::EOS) { | 2669 tok != Token::SEMICOLON && tok != Token::RBRACE && tok != Token::EOS) { |
2662 // ECMA allows "eval" or "arguments" as labels even in strict mode. | 2670 // ECMA allows "eval" or "arguments" as labels even in strict mode. |
2663 label = ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); | 2671 label = ParseIdentifier(kAllowRestrictedIdentifiers, CHECK_OK); |
2664 } | 2672 } |
2665 IterationStatement* target = LookupContinueTarget(label, CHECK_OK); | 2673 IterationStatement* target = LookupContinueTarget(label, CHECK_OK); |
2666 if (target == NULL) { | 2674 if (target == NULL) { |
2667 // Illegal continue statement. | 2675 // Illegal continue statement. |
2668 const char* message = "illegal_continue"; | 2676 const char* message = "illegal_continue"; |
2669 if (label != NULL) { | 2677 if (label != NULL) { |
2670 message = "unknown_label"; | 2678 message = "unknown_label"; |
2671 } | 2679 } |
2672 ParserTraits::ReportMessage(message, label); | 2680 ParserTraits::ReportMessage(message, label); |
2673 *ok = false; | 2681 *ok = false; |
2674 return NULL; | 2682 return NULL; |
2675 } | 2683 } |
2676 ExpectSemicolon(CHECK_OK); | 2684 ExpectSemicolon(CHECK_OK); |
2677 return factory()->NewContinueStatement(target, pos); | 2685 return factory()->NewContinueStatement(target, pos); |
2678 } | 2686 } |
2679 | 2687 |
2680 | 2688 |
2681 Statement* Parser::ParseBreakStatement(ZoneList<const AstRawString*>* labels, | 2689 Statement* Parser::ParseBreakStatement(ZoneList<const AstRawString*>* labels, |
2682 bool* ok) { | 2690 bool* ok) { |
2683 // BreakStatement :: | 2691 // BreakStatement :: |
2684 // 'break' Identifier? ';' | 2692 // 'break' Identifier? ';' |
2685 | 2693 |
2686 int pos = peek_position(); | 2694 int pos = peek_position(); |
2687 Expect(Token::BREAK, CHECK_OK); | 2695 Expect(Token::BREAK, CHECK_OK); |
2688 const AstRawString* label = NULL; | 2696 const AstRawString* label = NULL; |
2689 Token::Value tok = peek(); | 2697 Token::Value tok = peek(); |
2690 if (!scanner()->HasAnyLineTerminatorBeforeNext() && | 2698 if (!scanner()->HasAnyLineTerminatorBeforeNext() && |
2691 tok != Token::SEMICOLON && tok != Token::RBRACE && tok != Token::EOS) { | 2699 tok != Token::SEMICOLON && tok != Token::RBRACE && tok != Token::EOS) { |
2692 // ECMA allows "eval" or "arguments" as labels even in strict mode. | 2700 // ECMA allows "eval" or "arguments" as labels even in strict mode. |
2693 label = ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); | 2701 label = ParseIdentifier(kAllowRestrictedIdentifiers, CHECK_OK); |
2694 } | 2702 } |
2695 // Parse labeled break statements that target themselves into | 2703 // Parse labeled break statements that target themselves into |
2696 // empty statements, e.g. 'l1: l2: l3: break l2;' | 2704 // empty statements, e.g. 'l1: l2: l3: break l2;' |
2697 if (label != NULL && ContainsLabel(labels, label)) { | 2705 if (label != NULL && ContainsLabel(labels, label)) { |
2698 ExpectSemicolon(CHECK_OK); | 2706 ExpectSemicolon(CHECK_OK); |
2699 return factory()->NewEmptyStatement(pos); | 2707 return factory()->NewEmptyStatement(pos); |
2700 } | 2708 } |
2701 BreakableStatement* target = NULL; | 2709 BreakableStatement* target = NULL; |
2702 target = LookupBreakTarget(label, CHECK_OK); | 2710 target = LookupBreakTarget(label, CHECK_OK); |
2703 if (target == NULL) { | 2711 if (target == NULL) { |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2908 Scope* catch_scope = NULL; | 2916 Scope* catch_scope = NULL; |
2909 Variable* catch_variable = NULL; | 2917 Variable* catch_variable = NULL; |
2910 Block* catch_block = NULL; | 2918 Block* catch_block = NULL; |
2911 const AstRawString* name = NULL; | 2919 const AstRawString* name = NULL; |
2912 if (tok == Token::CATCH) { | 2920 if (tok == Token::CATCH) { |
2913 Consume(Token::CATCH); | 2921 Consume(Token::CATCH); |
2914 | 2922 |
2915 Expect(Token::LPAREN, CHECK_OK); | 2923 Expect(Token::LPAREN, CHECK_OK); |
2916 catch_scope = NewScope(scope_, CATCH_SCOPE); | 2924 catch_scope = NewScope(scope_, CATCH_SCOPE); |
2917 catch_scope->set_start_position(scanner()->location().beg_pos); | 2925 catch_scope->set_start_position(scanner()->location().beg_pos); |
2918 name = ParseIdentifier(kDontAllowEvalOrArguments, CHECK_OK); | 2926 name = ParseIdentifier(kDontAllowRestrictedIdentifiers, CHECK_OK); |
2919 | 2927 |
2920 Expect(Token::RPAREN, CHECK_OK); | 2928 Expect(Token::RPAREN, CHECK_OK); |
2921 | 2929 |
2922 catch_variable = catch_scope->DeclareLocal(name, VAR, kCreatedInitialized, | 2930 catch_variable = catch_scope->DeclareLocal(name, VAR, kCreatedInitialized, |
2923 Variable::NORMAL); | 2931 Variable::NORMAL); |
2924 BlockState block_state(&scope_, catch_scope); | 2932 BlockState block_state(&scope_, catch_scope); |
2925 catch_block = ParseBlock(NULL, CHECK_OK); | 2933 catch_block = ParseBlock(NULL, CHECK_OK); |
2926 | 2934 |
2927 catch_scope->set_end_position(scanner()->location().end_pos); | 2935 catch_scope->set_end_position(scanner()->location().end_pos); |
2928 tok = peek(); | 2936 tok = peek(); |
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3833 Expect(Token::LPAREN, CHECK_OK); | 3841 Expect(Token::LPAREN, CHECK_OK); |
3834 scope->set_start_position(scanner()->location().beg_pos); | 3842 scope->set_start_position(scanner()->location().beg_pos); |
3835 | 3843 |
3836 // We don't yet know if the function will be strict, so we cannot yet | 3844 // We don't yet know if the function will be strict, so we cannot yet |
3837 // produce errors for parameter names or duplicates. However, we remember | 3845 // produce errors for parameter names or duplicates. However, we remember |
3838 // the locations of these errors if they occur and produce the errors later. | 3846 // the locations of these errors if they occur and produce the errors later. |
3839 Scanner::Location eval_args_error_loc = Scanner::Location::invalid(); | 3847 Scanner::Location eval_args_error_loc = Scanner::Location::invalid(); |
3840 Scanner::Location dupe_error_loc = Scanner::Location::invalid(); | 3848 Scanner::Location dupe_error_loc = Scanner::Location::invalid(); |
3841 Scanner::Location reserved_error_loc = Scanner::Location::invalid(); | 3849 Scanner::Location reserved_error_loc = Scanner::Location::invalid(); |
3842 | 3850 |
| 3851 // Similarly for strong mode. |
| 3852 Scanner::Location undefined_error_loc = Scanner::Location::invalid(); |
| 3853 |
3843 bool is_rest = false; | 3854 bool is_rest = false; |
3844 bool done = arity_restriction == FunctionLiteral::GETTER_ARITY || | 3855 bool done = arity_restriction == FunctionLiteral::GETTER_ARITY || |
3845 (peek() == Token::RPAREN && | 3856 (peek() == Token::RPAREN && |
3846 arity_restriction != FunctionLiteral::SETTER_ARITY); | 3857 arity_restriction != FunctionLiteral::SETTER_ARITY); |
3847 while (!done) { | 3858 while (!done) { |
3848 bool is_strict_reserved = false; | 3859 bool is_strict_reserved = false; |
3849 is_rest = peek() == Token::ELLIPSIS && allow_harmony_rest_params(); | 3860 is_rest = peek() == Token::ELLIPSIS && allow_harmony_rest_params(); |
3850 if (is_rest) { | 3861 if (is_rest) { |
3851 Consume(Token::ELLIPSIS); | 3862 Consume(Token::ELLIPSIS); |
3852 } | 3863 } |
3853 | 3864 |
3854 const AstRawString* param_name = | 3865 const AstRawString* param_name = |
3855 ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK); | 3866 ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK); |
3856 | 3867 |
3857 // Store locations for possible future error reports. | 3868 // Store locations for possible future error reports. |
3858 if (!eval_args_error_loc.IsValid() && IsEvalOrArguments(param_name)) { | 3869 if (!eval_args_error_loc.IsValid() && IsEvalOrArguments(param_name)) { |
3859 eval_args_error_loc = scanner()->location(); | 3870 eval_args_error_loc = scanner()->location(); |
3860 } | 3871 } |
| 3872 if (!undefined_error_loc.IsValid() && IsUndefined(param_name)) { |
| 3873 undefined_error_loc = scanner()->location(); |
| 3874 } |
3861 if (!reserved_error_loc.IsValid() && is_strict_reserved) { | 3875 if (!reserved_error_loc.IsValid() && is_strict_reserved) { |
3862 reserved_error_loc = scanner()->location(); | 3876 reserved_error_loc = scanner()->location(); |
3863 } | 3877 } |
3864 if (!dupe_error_loc.IsValid() && | 3878 if (!dupe_error_loc.IsValid() && |
3865 scope_->IsDeclaredParameter(param_name)) { | 3879 scope_->IsDeclaredParameter(param_name)) { |
3866 duplicate_parameters = FunctionLiteral::kHasDuplicateParameters; | 3880 duplicate_parameters = FunctionLiteral::kHasDuplicateParameters; |
3867 dupe_error_loc = scanner()->location(); | 3881 dupe_error_loc = scanner()->location(); |
3868 } | 3882 } |
3869 | 3883 |
3870 Variable* var = scope_->DeclareParameter(param_name, VAR, is_rest); | 3884 Variable* var = scope_->DeclareParameter(param_name, VAR, is_rest); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3969 handler_count = function_state.handler_count(); | 3983 handler_count = function_state.handler_count(); |
3970 } | 3984 } |
3971 | 3985 |
3972 // Validate name and parameter names. We can do this only after parsing the | 3986 // Validate name and parameter names. We can do this only after parsing the |
3973 // function, since the function can declare itself strict. | 3987 // function, since the function can declare itself strict. |
3974 CheckFunctionName(language_mode(), kind, function_name, | 3988 CheckFunctionName(language_mode(), kind, function_name, |
3975 name_is_strict_reserved, function_name_location, | 3989 name_is_strict_reserved, function_name_location, |
3976 CHECK_OK); | 3990 CHECK_OK); |
3977 const bool use_strict_params = is_rest || IsConciseMethod(kind); | 3991 const bool use_strict_params = is_rest || IsConciseMethod(kind); |
3978 CheckFunctionParameterNames(language_mode(), use_strict_params, | 3992 CheckFunctionParameterNames(language_mode(), use_strict_params, |
3979 eval_args_error_loc, dupe_error_loc, | 3993 eval_args_error_loc, undefined_error_loc, |
3980 reserved_error_loc, CHECK_OK); | 3994 dupe_error_loc, reserved_error_loc, CHECK_OK); |
3981 | 3995 |
3982 if (is_strict(language_mode())) { | 3996 if (is_strict(language_mode())) { |
3983 CheckStrictOctalLiteral(scope->start_position(), scope->end_position(), | 3997 CheckStrictOctalLiteral(scope->start_position(), scope->end_position(), |
3984 CHECK_OK); | 3998 CHECK_OK); |
3985 } | 3999 } |
3986 if (is_strict(language_mode())) { | 4000 if (is_strict(language_mode())) { |
3987 CheckConflictingVarDeclarations(scope, CHECK_OK); | 4001 CheckConflictingVarDeclarations(scope, CHECK_OK); |
3988 } | 4002 } |
3989 if (is_strong(language_mode()) && IsSubclassConstructor(kind)) { | 4003 if (is_strong(language_mode()) && IsSubclassConstructor(kind)) { |
3990 if (!function_state.super_call_location().IsValid()) { | 4004 if (!function_state.super_call_location().IsValid()) { |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4222 if (name_is_strict_reserved) { | 4236 if (name_is_strict_reserved) { |
4223 ReportMessageAt(class_name_location, "unexpected_strict_reserved"); | 4237 ReportMessageAt(class_name_location, "unexpected_strict_reserved"); |
4224 *ok = false; | 4238 *ok = false; |
4225 return NULL; | 4239 return NULL; |
4226 } | 4240 } |
4227 if (IsEvalOrArguments(name)) { | 4241 if (IsEvalOrArguments(name)) { |
4228 ReportMessageAt(class_name_location, "strict_eval_arguments"); | 4242 ReportMessageAt(class_name_location, "strict_eval_arguments"); |
4229 *ok = false; | 4243 *ok = false; |
4230 return NULL; | 4244 return NULL; |
4231 } | 4245 } |
| 4246 if (is_strong(language_mode()) && IsUndefined(name)) { |
| 4247 ReportMessageAt(class_name_location, "strong_undefined"); |
| 4248 *ok = false; |
| 4249 return NULL; |
| 4250 } |
4232 | 4251 |
4233 // Create a block scope which is additionally tagged as class scope; this is | 4252 // Create a block scope which is additionally tagged as class scope; this is |
4234 // important for resolving variable references to the class name in the strong | 4253 // important for resolving variable references to the class name in the strong |
4235 // mode. | 4254 // mode. |
4236 Scope* block_scope = NewScope(scope_, BLOCK_SCOPE); | 4255 Scope* block_scope = NewScope(scope_, BLOCK_SCOPE); |
4237 block_scope->tag_as_class_scope(); | 4256 block_scope->tag_as_class_scope(); |
4238 BlockState block_state(&scope_, block_scope); | 4257 BlockState block_state(&scope_, block_scope); |
4239 scope_->SetLanguageMode( | 4258 scope_->SetLanguageMode( |
4240 static_cast<LanguageMode>(scope_->language_mode() | STRICT_BIT)); | 4259 static_cast<LanguageMode>(scope_->language_mode() | STRICT_BIT)); |
4241 scope_->SetScopeName(name); | 4260 scope_->SetScopeName(name); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4313 } | 4332 } |
4314 | 4333 |
4315 | 4334 |
4316 Expression* Parser::ParseV8Intrinsic(bool* ok) { | 4335 Expression* Parser::ParseV8Intrinsic(bool* ok) { |
4317 // CallRuntime :: | 4336 // CallRuntime :: |
4318 // '%' Identifier Arguments | 4337 // '%' Identifier Arguments |
4319 | 4338 |
4320 int pos = peek_position(); | 4339 int pos = peek_position(); |
4321 Expect(Token::MOD, CHECK_OK); | 4340 Expect(Token::MOD, CHECK_OK); |
4322 // Allow "eval" or "arguments" for backward compatibility. | 4341 // Allow "eval" or "arguments" for backward compatibility. |
4323 const AstRawString* name = ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); | 4342 const AstRawString* name = |
| 4343 ParseIdentifier(kAllowRestrictedIdentifiers, CHECK_OK); |
4324 ZoneList<Expression*>* args = ParseArguments(CHECK_OK); | 4344 ZoneList<Expression*>* args = ParseArguments(CHECK_OK); |
4325 | 4345 |
4326 if (extension_ != NULL) { | 4346 if (extension_ != NULL) { |
4327 // The extension structures are only accessible while parsing the | 4347 // The extension structures are only accessible while parsing the |
4328 // very first time not when reparsing because of lazy compilation. | 4348 // very first time not when reparsing because of lazy compilation. |
4329 scope_->DeclarationScope()->ForceEagerCompilation(); | 4349 scope_->DeclarationScope()->ForceEagerCompilation(); |
4330 } | 4350 } |
4331 | 4351 |
4332 const Runtime::Function* function = Runtime::FunctionForName(name->string()); | 4352 const Runtime::Function* function = Runtime::FunctionForName(name->string()); |
4333 | 4353 |
(...skipping 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5580 } else { | 5600 } else { |
5581 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); | 5601 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); |
5582 running_hash = StringHasher::ComputeRunningHash(running_hash, data, | 5602 running_hash = StringHasher::ComputeRunningHash(running_hash, data, |
5583 raw_string->length()); | 5603 raw_string->length()); |
5584 } | 5604 } |
5585 } | 5605 } |
5586 | 5606 |
5587 return running_hash; | 5607 return running_hash; |
5588 } | 5608 } |
5589 } } // namespace v8::internal | 5609 } } // namespace v8::internal |
OLD | NEW |