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

Side by Side Diff: src/parser.cc

Issue 1130133003: Migrate error messages, part 12. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@messages_11
Patch Set: Created 5 years, 7 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/pattern-rewriter.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/bailout-reason.h" 9 #include "src/bailout-reason.h"
10 #include "src/base/platform/platform.h" 10 #include "src/base/platform/platform.h"
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 } 629 }
630 // ...and one more time for '~foo' => 'foo^(~0)'. 630 // ...and one more time for '~foo' => 'foo^(~0)'.
631 if (op == Token::BIT_NOT) { 631 if (op == Token::BIT_NOT) {
632 return factory->NewBinaryOperation( 632 return factory->NewBinaryOperation(
633 Token::BIT_XOR, expression, factory->NewNumberLiteral(~0, pos), pos); 633 Token::BIT_XOR, expression, factory->NewNumberLiteral(~0, pos), pos);
634 } 634 }
635 return factory->NewUnaryOperation(op, expression, pos); 635 return factory->NewUnaryOperation(op, expression, pos);
636 } 636 }
637 637
638 638
639 Expression* ParserTraits::NewThrowReferenceError(const char* message, int pos) { 639 Expression* ParserTraits::NewThrowReferenceError(
640 MessageTemplate::Template message, int pos) {
640 return NewThrowError( 641 return NewThrowError(
641 parser_->ast_value_factory()->make_reference_error_string(), message, 642 parser_->ast_value_factory()->make_reference_error_string(), message,
642 parser_->ast_value_factory()->empty_string(), pos); 643 parser_->ast_value_factory()->empty_string(), pos);
643 } 644 }
644 645
645 646
646 Expression* ParserTraits::NewThrowSyntaxError( 647 Expression* ParserTraits::NewThrowSyntaxError(MessageTemplate::Template message,
647 const char* message, const AstRawString* arg, int pos) { 648 const AstRawString* arg,
649 int pos) {
648 return NewThrowError(parser_->ast_value_factory()->make_syntax_error_string(), 650 return NewThrowError(parser_->ast_value_factory()->make_syntax_error_string(),
649 message, arg, pos); 651 message, arg, pos);
650 } 652 }
651 653
652 654
653 Expression* ParserTraits::NewThrowTypeError( 655 Expression* ParserTraits::NewThrowTypeError(MessageTemplate::Template message,
654 const char* message, const AstRawString* arg, int pos) { 656 const AstRawString* arg, int pos) {
655 return NewThrowError(parser_->ast_value_factory()->make_type_error_string(), 657 return NewThrowError(parser_->ast_value_factory()->make_type_error_string(),
656 message, arg, pos); 658 message, arg, pos);
657 } 659 }
658 660
659 661
660 Expression* ParserTraits::NewThrowError( 662 Expression* ParserTraits::NewThrowError(const AstRawString* constructor,
661 const AstRawString* constructor, const char* message, 663 MessageTemplate::Template message,
662 const AstRawString* arg, int pos) { 664 const AstRawString* arg, int pos) {
663 Zone* zone = parser_->zone(); 665 Zone* zone = parser_->zone();
664 const AstRawString* type =
665 parser_->ast_value_factory()->GetOneByteString(message);
666 ZoneList<Expression*>* args = new (zone) ZoneList<Expression*>(2, zone); 666 ZoneList<Expression*>* args = new (zone) ZoneList<Expression*>(2, zone);
667 args->Add(parser_->factory()->NewStringLiteral(type, pos), zone); 667 args->Add(parser_->factory()->NewSmiLiteral(message, pos), zone);
668 args->Add(parser_->factory()->NewStringLiteral(arg, pos), zone); 668 args->Add(parser_->factory()->NewStringLiteral(arg, pos), zone);
669 CallRuntime* call_constructor = 669 CallRuntime* call_constructor =
670 parser_->factory()->NewCallRuntime(constructor, NULL, args, pos); 670 parser_->factory()->NewCallRuntime(constructor, NULL, args, pos);
671 return parser_->factory()->NewThrow(call_constructor, pos); 671 return parser_->factory()->NewThrow(call_constructor, pos);
672 } 672 }
673 673
674 674
675 void ParserTraits::ReportMessageAt(Scanner::Location source_location, 675 void ParserTraits::ReportMessageAt(Scanner::Location source_location,
676 const char* message, const char* arg, 676 MessageTemplate::Template message,
677 ParseErrorType error_type) { 677 const char* arg, ParseErrorType error_type) {
678 if (parser_->stack_overflow()) { 678 if (parser_->stack_overflow()) {
679 // Suppress the error message (syntax error or such) in the presence of a 679 // Suppress the error message (syntax error or such) in the presence of a
680 // stack overflow. The isolate allows only one pending exception at at time 680 // stack overflow. The isolate allows only one pending exception at at time
681 // and we want to report the stack overflow later. 681 // and we want to report the stack overflow later.
682 return; 682 return;
683 } 683 }
684 parser_->pending_error_handler_.ReportMessageAt(source_location.beg_pos, 684 parser_->pending_error_handler_.ReportMessageAt(source_location.beg_pos,
685 source_location.end_pos, 685 source_location.end_pos,
686 message, arg, error_type); 686 message, arg, error_type);
687 } 687 }
688 688
689 689
690 void ParserTraits::ReportMessage(const char* message, const char* arg, 690 void ParserTraits::ReportMessage(MessageTemplate::Template message,
691 ParseErrorType error_type) { 691 const char* arg, ParseErrorType error_type) {
692 Scanner::Location source_location = parser_->scanner()->location(); 692 Scanner::Location source_location = parser_->scanner()->location();
693 ReportMessageAt(source_location, message, arg, error_type); 693 ReportMessageAt(source_location, message, arg, error_type);
694 } 694 }
695 695
696 696
697 void ParserTraits::ReportMessage(const char* message, const AstRawString* arg, 697 void ParserTraits::ReportMessage(MessageTemplate::Template message,
698 const AstRawString* arg,
698 ParseErrorType error_type) { 699 ParseErrorType error_type) {
699 Scanner::Location source_location = parser_->scanner()->location(); 700 Scanner::Location source_location = parser_->scanner()->location();
700 ReportMessageAt(source_location, message, arg, error_type); 701 ReportMessageAt(source_location, message, arg, error_type);
701 } 702 }
702 703
703 704
704 void ParserTraits::ReportMessageAt(Scanner::Location source_location, 705 void ParserTraits::ReportMessageAt(Scanner::Location source_location,
705 const char* message, const AstRawString* arg, 706 MessageTemplate::Template message,
707 const AstRawString* arg,
706 ParseErrorType error_type) { 708 ParseErrorType error_type) {
707 if (parser_->stack_overflow()) { 709 if (parser_->stack_overflow()) {
708 // Suppress the error message (syntax error or such) in the presence of a 710 // Suppress the error message (syntax error or such) in the presence of a
709 // stack overflow. The isolate allows only one pending exception at at time 711 // stack overflow. The isolate allows only one pending exception at at time
710 // and we want to report the stack overflow later. 712 // and we want to report the stack overflow later.
711 return; 713 return;
712 } 714 }
713 parser_->pending_error_handler_.ReportMessageAt(source_location.beg_pos, 715 parser_->pending_error_handler_.ReportMessageAt(source_location.beg_pos,
714 source_location.end_pos, 716 source_location.end_pos,
715 message, arg, error_type); 717 message, arg, error_type);
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 if (ok && is_strict(language_mode())) { 1017 if (ok && is_strict(language_mode())) {
1016 CheckStrictOctalLiteral(beg_pos, scanner()->location().end_pos, &ok); 1018 CheckStrictOctalLiteral(beg_pos, scanner()->location().end_pos, &ok);
1017 CheckConflictingVarDeclarations(scope_, &ok); 1019 CheckConflictingVarDeclarations(scope_, &ok);
1018 } 1020 }
1019 1021
1020 if (ok && info->parse_restriction() == ONLY_SINGLE_FUNCTION_LITERAL) { 1022 if (ok && info->parse_restriction() == ONLY_SINGLE_FUNCTION_LITERAL) {
1021 if (body->length() != 1 || 1023 if (body->length() != 1 ||
1022 !body->at(0)->IsExpressionStatement() || 1024 !body->at(0)->IsExpressionStatement() ||
1023 !body->at(0)->AsExpressionStatement()-> 1025 !body->at(0)->AsExpressionStatement()->
1024 expression()->IsFunctionLiteral()) { 1026 expression()->IsFunctionLiteral()) {
1025 ReportMessage("single_function_literal"); 1027 ReportMessage(MessageTemplate::kSingleFunctionLiteral);
1026 ok = false; 1028 ok = false;
1027 } 1029 }
1028 } 1030 }
1029 1031
1030 if (ok) { 1032 if (ok) {
1031 result = factory()->NewFunctionLiteral( 1033 result = factory()->NewFunctionLiteral(
1032 ast_value_factory()->empty_string(), ast_value_factory(), scope_, 1034 ast_value_factory()->empty_string(), ast_value_factory(), scope_,
1033 body, function_state.materialized_literal_count(), 1035 body, function_state.materialized_literal_count(),
1034 function_state.expected_property_count(), 1036 function_state.expected_property_count(),
1035 function_state.handler_count(), 0, 1037 function_state.handler_count(), 0,
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 Scanner::Location old_super_loc = function_state_->super_location(); 1215 Scanner::Location old_super_loc = function_state_->super_location();
1214 Statement* stat = ParseStatementListItem(CHECK_OK); 1216 Statement* stat = ParseStatementListItem(CHECK_OK);
1215 1217
1216 if (is_strong(language_mode()) && 1218 if (is_strong(language_mode()) &&
1217 scope_->is_function_scope() && 1219 scope_->is_function_scope() &&
1218 i::IsConstructor(function_state_->kind())) { 1220 i::IsConstructor(function_state_->kind())) {
1219 Scanner::Location this_loc = function_state_->this_location(); 1221 Scanner::Location this_loc = function_state_->this_location();
1220 Scanner::Location super_loc = function_state_->super_location(); 1222 Scanner::Location super_loc = function_state_->super_location();
1221 if (this_loc.beg_pos != old_this_loc.beg_pos && 1223 if (this_loc.beg_pos != old_this_loc.beg_pos &&
1222 this_loc.beg_pos != token_loc.beg_pos) { 1224 this_loc.beg_pos != token_loc.beg_pos) {
1223 ReportMessageAt(this_loc, "strong_constructor_this"); 1225 ReportMessageAt(this_loc, MessageTemplate::kStrongConstructorThis);
1224 *ok = false; 1226 *ok = false;
1225 return nullptr; 1227 return nullptr;
1226 } 1228 }
1227 if (super_loc.beg_pos != old_super_loc.beg_pos && 1229 if (super_loc.beg_pos != old_super_loc.beg_pos &&
1228 super_loc.beg_pos != token_loc.beg_pos) { 1230 super_loc.beg_pos != token_loc.beg_pos) {
1229 ReportMessageAt(super_loc, "strong_constructor_super"); 1231 ReportMessageAt(super_loc, MessageTemplate::kStrongConstructorSuper);
1230 *ok = false; 1232 *ok = false;
1231 return nullptr; 1233 return nullptr;
1232 } 1234 }
1233 } 1235 }
1234 1236
1235 if (stat == NULL || stat->IsEmpty()) { 1237 if (stat == NULL || stat->IsEmpty()) {
1236 directive_prologue = false; // End of directive prologue. 1238 directive_prologue = false; // End of directive prologue.
1237 continue; 1239 continue;
1238 } 1240 }
1239 1241
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 } 1375 }
1374 1376
1375 // Check that all exports are bound. 1377 // Check that all exports are bound.
1376 ModuleDescriptor* descriptor = scope_->module(); 1378 ModuleDescriptor* descriptor = scope_->module();
1377 for (ModuleDescriptor::Iterator it = descriptor->iterator(); !it.done(); 1379 for (ModuleDescriptor::Iterator it = descriptor->iterator(); !it.done();
1378 it.Advance()) { 1380 it.Advance()) {
1379 if (scope_->LookupLocal(it.local_name()) == NULL) { 1381 if (scope_->LookupLocal(it.local_name()) == NULL) {
1380 // TODO(adamk): Pass both local_name and export_name once ParserTraits 1382 // TODO(adamk): Pass both local_name and export_name once ParserTraits
1381 // supports multiple arg error messages. 1383 // supports multiple arg error messages.
1382 // Also try to report this at a better location. 1384 // Also try to report this at a better location.
1383 ParserTraits::ReportMessage("module_export_undefined", it.local_name()); 1385 ParserTraits::ReportMessage(MessageTemplate::kModuleExportUndefined,
1386 it.local_name());
1384 *ok = false; 1387 *ok = false;
1385 return NULL; 1388 return NULL;
1386 } 1389 }
1387 } 1390 }
1388 1391
1389 scope_->module()->Freeze(); 1392 scope_->module()->Freeze();
1390 return NULL; 1393 return NULL;
1391 } 1394 }
1392 1395
1393 1396
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1470 const AstRawString* import_name = ParseIdentifierName(CHECK_OK); 1473 const AstRawString* import_name = ParseIdentifierName(CHECK_OK);
1471 const AstRawString* local_name = import_name; 1474 const AstRawString* local_name = import_name;
1472 // In the presence of 'as', the left-side of the 'as' can 1475 // In the presence of 'as', the left-side of the 'as' can
1473 // be any IdentifierName. But without 'as', it must be a valid 1476 // be any IdentifierName. But without 'as', it must be a valid
1474 // BindingIdentifier. 1477 // BindingIdentifier.
1475 if (CheckContextualKeyword(CStrVector("as"))) { 1478 if (CheckContextualKeyword(CStrVector("as"))) {
1476 local_name = ParseIdentifierName(CHECK_OK); 1479 local_name = ParseIdentifierName(CHECK_OK);
1477 } 1480 }
1478 if (!Token::IsIdentifier(scanner()->current_token(), STRICT, false)) { 1481 if (!Token::IsIdentifier(scanner()->current_token(), STRICT, false)) {
1479 *ok = false; 1482 *ok = false;
1480 ReportMessage("unexpected_reserved"); 1483 ReportMessage(MessageTemplate::kUnexpectedReserved);
1481 return NULL; 1484 return NULL;
1482 } else if (IsEvalOrArguments(local_name)) { 1485 } else if (IsEvalOrArguments(local_name)) {
1483 *ok = false; 1486 *ok = false;
1484 ReportMessage("strict_eval_arguments"); 1487 ReportMessage(MessageTemplate::kStrictEvalArguments);
1485 return NULL; 1488 return NULL;
1486 } else if (is_strong(language_mode()) && IsUndefined(local_name)) { 1489 } else if (is_strong(language_mode()) && IsUndefined(local_name)) {
1487 *ok = false; 1490 *ok = false;
1488 ReportMessage("strong_undefined"); 1491 ReportMessage(MessageTemplate::kStrongUndefined);
1489 return NULL; 1492 return NULL;
1490 } 1493 }
1491 VariableProxy* proxy = NewUnresolved(local_name, IMPORT); 1494 VariableProxy* proxy = NewUnresolved(local_name, IMPORT);
1492 ImportDeclaration* declaration = 1495 ImportDeclaration* declaration =
1493 factory()->NewImportDeclaration(proxy, import_name, NULL, scope_, pos); 1496 factory()->NewImportDeclaration(proxy, import_name, NULL, scope_, pos);
1494 Declare(declaration, true, CHECK_OK); 1497 Declare(declaration, true, CHECK_OK);
1495 result->Add(declaration, zone()); 1498 result->Add(declaration, zone());
1496 if (peek() == Token::RBRACE) break; 1499 if (peek() == Token::RBRACE) break;
1497 Expect(Token::COMMA, CHECK_OK); 1500 Expect(Token::COMMA, CHECK_OK);
1498 } 1501 }
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1622 break; 1625 break;
1623 } 1626 }
1624 } 1627 }
1625 1628
1626 const AstRawString* default_string = ast_value_factory()->default_string(); 1629 const AstRawString* default_string = ast_value_factory()->default_string();
1627 1630
1628 DCHECK_LE(names.length(), 1); 1631 DCHECK_LE(names.length(), 1);
1629 if (names.length() == 1) { 1632 if (names.length() == 1) {
1630 scope_->module()->AddLocalExport(default_string, names.first(), zone(), ok); 1633 scope_->module()->AddLocalExport(default_string, names.first(), zone(), ok);
1631 if (!*ok) { 1634 if (!*ok) {
1632 ParserTraits::ReportMessageAt(default_loc, "duplicate_export", 1635 ParserTraits::ReportMessageAt(
1633 default_string); 1636 default_loc, MessageTemplate::kDuplicateExport, default_string);
1634 return NULL; 1637 return NULL;
1635 } 1638 }
1636 } else { 1639 } else {
1637 // TODO(ES6): Assign result to a const binding with the name "*default*" 1640 // TODO(ES6): Assign result to a const binding with the name "*default*"
1638 // and add an export entry with "*default*" as the local name. 1641 // and add an export entry with "*default*" as the local name.
1639 } 1642 }
1640 1643
1641 return result; 1644 return result;
1642 } 1645 }
1643 1646
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1686 ZoneList<Scanner::Location> export_locations(1, zone()); 1689 ZoneList<Scanner::Location> export_locations(1, zone());
1687 ZoneList<const AstRawString*> local_names(1, zone()); 1690 ZoneList<const AstRawString*> local_names(1, zone());
1688 ParseExportClause(&export_names, &export_locations, &local_names, 1691 ParseExportClause(&export_names, &export_locations, &local_names,
1689 &reserved_loc, CHECK_OK); 1692 &reserved_loc, CHECK_OK);
1690 const AstRawString* indirect_export_module_specifier = NULL; 1693 const AstRawString* indirect_export_module_specifier = NULL;
1691 if (CheckContextualKeyword(CStrVector("from"))) { 1694 if (CheckContextualKeyword(CStrVector("from"))) {
1692 indirect_export_module_specifier = ParseModuleSpecifier(CHECK_OK); 1695 indirect_export_module_specifier = ParseModuleSpecifier(CHECK_OK);
1693 } else if (reserved_loc.IsValid()) { 1696 } else if (reserved_loc.IsValid()) {
1694 // No FromClause, so reserved words are invalid in ExportClause. 1697 // No FromClause, so reserved words are invalid in ExportClause.
1695 *ok = false; 1698 *ok = false;
1696 ReportMessageAt(reserved_loc, "unexpected_reserved"); 1699 ReportMessageAt(reserved_loc, MessageTemplate::kUnexpectedReserved);
1697 return NULL; 1700 return NULL;
1698 } 1701 }
1699 ExpectSemicolon(CHECK_OK); 1702 ExpectSemicolon(CHECK_OK);
1700 const int length = export_names.length(); 1703 const int length = export_names.length();
1701 DCHECK_EQ(length, local_names.length()); 1704 DCHECK_EQ(length, local_names.length());
1702 DCHECK_EQ(length, export_locations.length()); 1705 DCHECK_EQ(length, export_locations.length());
1703 if (indirect_export_module_specifier == NULL) { 1706 if (indirect_export_module_specifier == NULL) {
1704 for (int i = 0; i < length; ++i) { 1707 for (int i = 0; i < length; ++i) {
1705 scope_->module()->AddLocalExport(export_names[i], local_names[i], 1708 scope_->module()->AddLocalExport(export_names[i], local_names[i],
1706 zone(), ok); 1709 zone(), ok);
1707 if (!*ok) { 1710 if (!*ok) {
1708 ParserTraits::ReportMessageAt(export_locations[i], 1711 ParserTraits::ReportMessageAt(export_locations[i],
1709 "duplicate_export", export_names[i]); 1712 MessageTemplate::kDuplicateExport,
1713 export_names[i]);
1710 return NULL; 1714 return NULL;
1711 } 1715 }
1712 } 1716 }
1713 } else { 1717 } else {
1714 scope_->module()->AddModuleRequest(indirect_export_module_specifier, 1718 scope_->module()->AddModuleRequest(indirect_export_module_specifier,
1715 zone()); 1719 zone());
1716 for (int i = 0; i < length; ++i) { 1720 for (int i = 0; i < length; ++i) {
1717 // TODO(ES6): scope_->module()->AddIndirectExport(...);( 1721 // TODO(ES6): scope_->module()->AddIndirectExport(...);(
1718 } 1722 }
1719 } 1723 }
(...skipping 19 matching lines...) Expand all
1739 ReportUnexpectedToken(scanner()->current_token()); 1743 ReportUnexpectedToken(scanner()->current_token());
1740 return NULL; 1744 return NULL;
1741 } 1745 }
1742 1746
1743 // Extract declared names into export declarations. 1747 // Extract declared names into export declarations.
1744 ModuleDescriptor* descriptor = scope_->module(); 1748 ModuleDescriptor* descriptor = scope_->module();
1745 for (int i = 0; i < names.length(); ++i) { 1749 for (int i = 0; i < names.length(); ++i) {
1746 descriptor->AddLocalExport(names[i], names[i], zone(), ok); 1750 descriptor->AddLocalExport(names[i], names[i], zone(), ok);
1747 if (!*ok) { 1751 if (!*ok) {
1748 // TODO(adamk): Possibly report this error at the right place. 1752 // TODO(adamk): Possibly report this error at the right place.
1749 ParserTraits::ReportMessage("duplicate_export", names[i]); 1753 ParserTraits::ReportMessage(MessageTemplate::kDuplicateExport, names[i]);
1750 return NULL; 1754 return NULL;
1751 } 1755 }
1752 } 1756 }
1753 1757
1754 DCHECK_NOT_NULL(result); 1758 DCHECK_NOT_NULL(result);
1755 return result; 1759 return result;
1756 } 1760 }
1757 1761
1758 1762
1759 Statement* Parser::ParseStatement(ZoneList<const AstRawString*>* labels, 1763 Statement* Parser::ParseStatement(ZoneList<const AstRawString*>* labels,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1794 // iterations or 'switch' statements (i.e., BreakableStatements), 1798 // iterations or 'switch' statements (i.e., BreakableStatements),
1795 // labels can be simply ignored in all other cases; except for 1799 // labels can be simply ignored in all other cases; except for
1796 // trivial labeled break statements 'label: break label' which is 1800 // trivial labeled break statements 'label: break label' which is
1797 // parsed into an empty statement. 1801 // parsed into an empty statement.
1798 switch (peek()) { 1802 switch (peek()) {
1799 case Token::LBRACE: 1803 case Token::LBRACE:
1800 return ParseBlock(labels, ok); 1804 return ParseBlock(labels, ok);
1801 1805
1802 case Token::SEMICOLON: 1806 case Token::SEMICOLON:
1803 if (is_strong(language_mode())) { 1807 if (is_strong(language_mode())) {
1804 ReportMessageAt(scanner()->peek_location(), "strong_empty"); 1808 ReportMessageAt(scanner()->peek_location(),
1809 MessageTemplate::kStrongEmpty);
1805 *ok = false; 1810 *ok = false;
1806 return NULL; 1811 return NULL;
1807 } 1812 }
1808 Next(); 1813 Next();
1809 return factory()->NewEmptyStatement(RelocInfo::kNoPosition); 1814 return factory()->NewEmptyStatement(RelocInfo::kNoPosition);
1810 1815
1811 case Token::IF: 1816 case Token::IF:
1812 return ParseIfStatement(labels, ok); 1817 return ParseIfStatement(labels, ok);
1813 1818
1814 case Token::DO: 1819 case Token::DO:
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1851 // SourceElement: 1856 // SourceElement:
1852 // Statement 1857 // Statement
1853 // FunctionDeclaration 1858 // FunctionDeclaration
1854 // Common language extension is to allow function declaration in place 1859 // Common language extension is to allow function declaration in place
1855 // of any statement. This language extension is disabled in strict mode. 1860 // of any statement. This language extension is disabled in strict mode.
1856 // 1861 //
1857 // In Harmony mode, this case also handles the extension: 1862 // In Harmony mode, this case also handles the extension:
1858 // Statement: 1863 // Statement:
1859 // GeneratorDeclaration 1864 // GeneratorDeclaration
1860 if (is_strict(language_mode())) { 1865 if (is_strict(language_mode())) {
1861 ReportMessageAt(scanner()->peek_location(), "strict_function"); 1866 ReportMessageAt(scanner()->peek_location(),
1867 MessageTemplate::kStrictFunction);
1862 *ok = false; 1868 *ok = false;
1863 return NULL; 1869 return NULL;
1864 } 1870 }
1865 return ParseFunctionDeclaration(NULL, ok); 1871 return ParseFunctionDeclaration(NULL, ok);
1866 } 1872 }
1867 1873
1868 case Token::DEBUGGER: 1874 case Token::DEBUGGER:
1869 return ParseDebuggerStatement(ok); 1875 return ParseDebuggerStatement(ok);
1870 1876
1871 case Token::VAR: 1877 case Token::VAR:
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1975 // the special case 1981 // the special case
1976 // 1982 //
1977 // function () { let x; { var x; } } 1983 // function () { let x; { var x; } }
1978 // 1984 //
1979 // because the var declaration is hoisted to the function scope where 'x' 1985 // because the var declaration is hoisted to the function scope where 'x'
1980 // is already bound. 1986 // is already bound.
1981 DCHECK(IsDeclaredVariableMode(var->mode())); 1987 DCHECK(IsDeclaredVariableMode(var->mode()));
1982 if (is_strict(language_mode())) { 1988 if (is_strict(language_mode())) {
1983 // In harmony we treat re-declarations as early errors. See 1989 // In harmony we treat re-declarations as early errors. See
1984 // ES5 16 for a definition of early errors. 1990 // ES5 16 for a definition of early errors.
1985 ParserTraits::ReportMessage("var_redeclaration", name); 1991 ParserTraits::ReportMessage(MessageTemplate::kVarRedeclaration, name);
1986 *ok = false; 1992 *ok = false;
1987 return nullptr; 1993 return nullptr;
1988 } 1994 }
1989 Expression* expression = NewThrowTypeError( 1995 Expression* expression = NewThrowTypeError(
1990 "var_redeclaration", name, declaration->position()); 1996 MessageTemplate::kVarRedeclaration, name, declaration->position());
1991 declaration_scope->SetIllegalRedeclaration(expression); 1997 declaration_scope->SetIllegalRedeclaration(expression);
1992 } else if (mode == VAR) { 1998 } else if (mode == VAR) {
1993 var->set_maybe_assigned(); 1999 var->set_maybe_assigned();
1994 } 2000 }
1995 } 2001 }
1996 2002
1997 // We add a declaration node for every declaration. The compiler 2003 // We add a declaration node for every declaration. The compiler
1998 // will only generate code if necessary. In particular, declarations 2004 // will only generate code if necessary. In particular, declarations
1999 // for inner local variables that do not represent functions won't 2005 // for inner local variables that do not represent functions won't
2000 // result in any generated code. 2006 // result in any generated code.
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
2157 // class C { ... } 2163 // class C { ... }
2158 // 2164 //
2159 // has the same semantics as: 2165 // has the same semantics as:
2160 // 2166 //
2161 // let C = class C { ... }; 2167 // let C = class C { ... };
2162 // 2168 //
2163 // so rewrite it as such. 2169 // so rewrite it as such.
2164 2170
2165 Expect(Token::CLASS, CHECK_OK); 2171 Expect(Token::CLASS, CHECK_OK);
2166 if (!allow_harmony_sloppy() && is_sloppy(language_mode())) { 2172 if (!allow_harmony_sloppy() && is_sloppy(language_mode())) {
2167 ReportMessage("sloppy_lexical"); 2173 ReportMessage(MessageTemplate::kSloppyLexical);
2168 *ok = false; 2174 *ok = false;
2169 return NULL; 2175 return NULL;
2170 } 2176 }
2171 2177
2172 int pos = position(); 2178 int pos = position();
2173 bool is_strict_reserved = false; 2179 bool is_strict_reserved = false;
2174 const AstRawString* name = 2180 const AstRawString* name =
2175 ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK); 2181 ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK);
2176 ClassLiteral* value = ParseClassLiteral(name, scanner()->location(), 2182 ClassLiteral* value = ParseClassLiteral(name, scanner()->location(),
2177 is_strict_reserved, pos, CHECK_OK); 2183 is_strict_reserved, pos, CHECK_OK);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
2343 // True if the binding needs initialization. 'let' and 'const' declared 2349 // True if the binding needs initialization. 'let' and 'const' declared
2344 // bindings are created uninitialized by their declaration nodes and 2350 // bindings are created uninitialized by their declaration nodes and
2345 // need initialization. 'var' declared bindings are always initialized 2351 // need initialization. 'var' declared bindings are always initialized
2346 // immediately by their declaration nodes. 2352 // immediately by their declaration nodes.
2347 parsing_result->descriptor.needs_init = false; 2353 parsing_result->descriptor.needs_init = false;
2348 parsing_result->descriptor.is_const = false; 2354 parsing_result->descriptor.is_const = false;
2349 parsing_result->descriptor.init_op = Token::INIT_VAR; 2355 parsing_result->descriptor.init_op = Token::INIT_VAR;
2350 if (peek() == Token::VAR) { 2356 if (peek() == Token::VAR) {
2351 if (is_strong(language_mode())) { 2357 if (is_strong(language_mode())) {
2352 Scanner::Location location = scanner()->peek_location(); 2358 Scanner::Location location = scanner()->peek_location();
2353 ReportMessageAt(location, "strong_var"); 2359 ReportMessageAt(location, MessageTemplate::kStrongVar);
2354 *ok = false; 2360 *ok = false;
2355 return; 2361 return;
2356 } 2362 }
2357 Consume(Token::VAR); 2363 Consume(Token::VAR);
2358 } else if (peek() == Token::CONST) { 2364 } else if (peek() == Token::CONST) {
2359 Consume(Token::CONST); 2365 Consume(Token::CONST);
2360 if (is_sloppy(language_mode())) { 2366 if (is_sloppy(language_mode())) {
2361 parsing_result->descriptor.mode = CONST_LEGACY; 2367 parsing_result->descriptor.mode = CONST_LEGACY;
2362 parsing_result->descriptor.init_op = Token::INIT_CONST_LEGACY; 2368 parsing_result->descriptor.init_op = Token::INIT_CONST_LEGACY;
2363 ++use_counts_[v8::Isolate::kLegacyConst]; 2369 ++use_counts_[v8::Isolate::kLegacyConst];
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
2523 switch (peek()) { 2529 switch (peek()) {
2524 case Token::SEMICOLON: 2530 case Token::SEMICOLON:
2525 Consume(Token::SEMICOLON); 2531 Consume(Token::SEMICOLON);
2526 break; 2532 break;
2527 case Token::RBRACE: 2533 case Token::RBRACE:
2528 case Token::EOS: 2534 case Token::EOS:
2529 break; 2535 break;
2530 default: 2536 default:
2531 if (!scanner()->HasAnyLineTerminatorBeforeNext()) { 2537 if (!scanner()->HasAnyLineTerminatorBeforeNext()) {
2532 ReportMessageAt(function_state_->this_location(), 2538 ReportMessageAt(function_state_->this_location(),
2533 is_this ? "strong_constructor_this" 2539 is_this
2534 : "strong_constructor_super"); 2540 ? MessageTemplate::kStrongConstructorThis
2541 : MessageTemplate::kStrongConstructorSuper);
2535 *ok = false; 2542 *ok = false;
2536 return nullptr; 2543 return nullptr;
2537 } 2544 }
2538 } 2545 }
2539 return factory()->NewExpressionStatement(expr, pos); 2546 return factory()->NewExpressionStatement(expr, pos);
2540 } 2547 }
2541 break; 2548 break;
2542 2549
2543 // TODO(arv): Handle `let [` 2550 // TODO(arv): Handle `let [`
2544 // https://code.google.com/p/v8/issues/detail?id=3847 2551 // https://code.google.com/p/v8/issues/detail?id=3847
(...skipping 10 matching lines...) Expand all
2555 // Expression is a single identifier, and not, e.g., a parenthesized 2562 // Expression is a single identifier, and not, e.g., a parenthesized
2556 // identifier. 2563 // identifier.
2557 VariableProxy* var = expr->AsVariableProxy(); 2564 VariableProxy* var = expr->AsVariableProxy();
2558 const AstRawString* label = var->raw_name(); 2565 const AstRawString* label = var->raw_name();
2559 // TODO(1240780): We don't check for redeclaration of labels 2566 // TODO(1240780): We don't check for redeclaration of labels
2560 // during preparsing since keeping track of the set of active 2567 // during preparsing since keeping track of the set of active
2561 // labels requires nontrivial changes to the way scopes are 2568 // labels requires nontrivial changes to the way scopes are
2562 // structured. However, these are probably changes we want to 2569 // structured. However, these are probably changes we want to
2563 // make later anyway so we should go back and fix this then. 2570 // make later anyway so we should go back and fix this then.
2564 if (ContainsLabel(labels, label) || TargetStackContainsLabel(label)) { 2571 if (ContainsLabel(labels, label) || TargetStackContainsLabel(label)) {
2565 ParserTraits::ReportMessage("label_redeclaration", label); 2572 ParserTraits::ReportMessage(MessageTemplate::kLabelRedeclaration, label);
2566 *ok = false; 2573 *ok = false;
2567 return NULL; 2574 return NULL;
2568 } 2575 }
2569 if (labels == NULL) { 2576 if (labels == NULL) {
2570 labels = new(zone()) ZoneList<const AstRawString*>(4, zone()); 2577 labels = new(zone()) ZoneList<const AstRawString*>(4, zone());
2571 } 2578 }
2572 labels->Add(label, zone()); 2579 labels->Add(label, zone());
2573 // Remove the "ghost" variable that turned out to be a label 2580 // Remove the "ghost" variable that turned out to be a label
2574 // from the top scope. This way, we don't try to resolve it 2581 // from the top scope. This way, we don't try to resolve it
2575 // during the scope processing. 2582 // during the scope processing.
(...skipping 12 matching lines...) Expand all
2588 ast_value_factory()->native_string() && 2595 ast_value_factory()->native_string() &&
2589 !scanner()->literal_contains_escapes()) { 2596 !scanner()->literal_contains_escapes()) {
2590 return ParseNativeDeclaration(ok); 2597 return ParseNativeDeclaration(ok);
2591 } 2598 }
2592 2599
2593 // Parsed expression statement, followed by semicolon. 2600 // Parsed expression statement, followed by semicolon.
2594 // Detect attempts at 'let' declarations in sloppy mode. 2601 // Detect attempts at 'let' declarations in sloppy mode.
2595 if (peek() == Token::IDENTIFIER && expr->AsVariableProxy() != NULL && 2602 if (peek() == Token::IDENTIFIER && expr->AsVariableProxy() != NULL &&
2596 expr->AsVariableProxy()->raw_name() == 2603 expr->AsVariableProxy()->raw_name() ==
2597 ast_value_factory()->let_string()) { 2604 ast_value_factory()->let_string()) {
2598 ReportMessage("sloppy_lexical", NULL); 2605 ReportMessage(MessageTemplate::kSloppyLexical, NULL);
2599 *ok = false; 2606 *ok = false;
2600 return NULL; 2607 return NULL;
2601 } 2608 }
2602 ExpectSemicolon(CHECK_OK); 2609 ExpectSemicolon(CHECK_OK);
2603 return factory()->NewExpressionStatement(expr, pos); 2610 return factory()->NewExpressionStatement(expr, pos);
2604 } 2611 }
2605 2612
2606 2613
2607 IfStatement* Parser::ParseIfStatement(ZoneList<const AstRawString*>* labels, 2614 IfStatement* Parser::ParseIfStatement(ZoneList<const AstRawString*>* labels,
2608 bool* ok) { 2615 bool* ok) {
(...skipping 27 matching lines...) Expand all
2636 const AstRawString* label = NULL; 2643 const AstRawString* label = NULL;
2637 Token::Value tok = peek(); 2644 Token::Value tok = peek();
2638 if (!scanner()->HasAnyLineTerminatorBeforeNext() && 2645 if (!scanner()->HasAnyLineTerminatorBeforeNext() &&
2639 tok != Token::SEMICOLON && tok != Token::RBRACE && tok != Token::EOS) { 2646 tok != Token::SEMICOLON && tok != Token::RBRACE && tok != Token::EOS) {
2640 // ECMA allows "eval" or "arguments" as labels even in strict mode. 2647 // ECMA allows "eval" or "arguments" as labels even in strict mode.
2641 label = ParseIdentifier(kAllowRestrictedIdentifiers, CHECK_OK); 2648 label = ParseIdentifier(kAllowRestrictedIdentifiers, CHECK_OK);
2642 } 2649 }
2643 IterationStatement* target = LookupContinueTarget(label, CHECK_OK); 2650 IterationStatement* target = LookupContinueTarget(label, CHECK_OK);
2644 if (target == NULL) { 2651 if (target == NULL) {
2645 // Illegal continue statement. 2652 // Illegal continue statement.
2646 const char* message = "illegal_continue"; 2653 MessageTemplate::Template message = MessageTemplate::kIllegalContinue;
2647 if (label != NULL) { 2654 if (label != NULL) {
2648 message = "unknown_label"; 2655 message = MessageTemplate::kUnknownLabel;
2649 } 2656 }
2650 ParserTraits::ReportMessage(message, label); 2657 ParserTraits::ReportMessage(message, label);
2651 *ok = false; 2658 *ok = false;
2652 return NULL; 2659 return NULL;
2653 } 2660 }
2654 ExpectSemicolon(CHECK_OK); 2661 ExpectSemicolon(CHECK_OK);
2655 return factory()->NewContinueStatement(target, pos); 2662 return factory()->NewContinueStatement(target, pos);
2656 } 2663 }
2657 2664
2658 2665
(...skipping 14 matching lines...) Expand all
2673 // Parse labeled break statements that target themselves into 2680 // Parse labeled break statements that target themselves into
2674 // empty statements, e.g. 'l1: l2: l3: break l2;' 2681 // empty statements, e.g. 'l1: l2: l3: break l2;'
2675 if (label != NULL && ContainsLabel(labels, label)) { 2682 if (label != NULL && ContainsLabel(labels, label)) {
2676 ExpectSemicolon(CHECK_OK); 2683 ExpectSemicolon(CHECK_OK);
2677 return factory()->NewEmptyStatement(pos); 2684 return factory()->NewEmptyStatement(pos);
2678 } 2685 }
2679 BreakableStatement* target = NULL; 2686 BreakableStatement* target = NULL;
2680 target = LookupBreakTarget(label, CHECK_OK); 2687 target = LookupBreakTarget(label, CHECK_OK);
2681 if (target == NULL) { 2688 if (target == NULL) {
2682 // Illegal break statement. 2689 // Illegal break statement.
2683 const char* message = "illegal_break"; 2690 MessageTemplate::Template message = MessageTemplate::kIllegalBreak;
2684 if (label != NULL) { 2691 if (label != NULL) {
2685 message = "unknown_label"; 2692 message = MessageTemplate::kUnknownLabel;
2686 } 2693 }
2687 ParserTraits::ReportMessage(message, label); 2694 ParserTraits::ReportMessage(message, label);
2688 *ok = false; 2695 *ok = false;
2689 return NULL; 2696 return NULL;
2690 } 2697 }
2691 ExpectSemicolon(CHECK_OK); 2698 ExpectSemicolon(CHECK_OK);
2692 return factory()->NewBreakStatement(target, pos); 2699 return factory()->NewBreakStatement(target, pos);
2693 } 2700 }
2694 2701
2695 2702
(...skipping 18 matching lines...) Expand all
2714 if (IsSubclassConstructor(function_state_->kind())) { 2721 if (IsSubclassConstructor(function_state_->kind())) {
2715 return_value = ThisExpression(scope_, factory(), loc.beg_pos); 2722 return_value = ThisExpression(scope_, factory(), loc.beg_pos);
2716 } else { 2723 } else {
2717 return_value = GetLiteralUndefined(position()); 2724 return_value = GetLiteralUndefined(position());
2718 } 2725 }
2719 } else { 2726 } else {
2720 if (is_strong(language_mode()) && 2727 if (is_strong(language_mode()) &&
2721 i::IsConstructor(function_state_->kind())) { 2728 i::IsConstructor(function_state_->kind())) {
2722 int pos = peek_position(); 2729 int pos = peek_position();
2723 ReportMessageAt(Scanner::Location(pos, pos + 1), 2730 ReportMessageAt(Scanner::Location(pos, pos + 1),
2724 "strong_constructor_return_value"); 2731 MessageTemplate::kStrongConstructorReturnValue);
2725 *ok = false; 2732 *ok = false;
2726 return NULL; 2733 return NULL;
2727 } 2734 }
2728 2735
2729 int pos = peek_position(); 2736 int pos = peek_position();
2730 return_value = ParseExpression(true, CHECK_OK); 2737 return_value = ParseExpression(true, CHECK_OK);
2731 2738
2732 if (IsSubclassConstructor(function_state_->kind())) { 2739 if (IsSubclassConstructor(function_state_->kind())) {
2733 // For subclass constructors we need to return this in case of undefined 2740 // For subclass constructors we need to return this in case of undefined
2734 // and throw an exception in case of a non object. 2741 // and throw an exception in case of a non object.
2735 // 2742 //
2736 // return expr; 2743 // return expr;
2737 // 2744 //
2738 // Is rewritten as: 2745 // Is rewritten as:
2739 // 2746 //
2740 // return (temp = expr) === undefined ? this : 2747 // return (temp = expr) === undefined ? this :
2741 // %_IsSpecObject(temp) ? temp : throw new TypeError(...); 2748 // %_IsSpecObject(temp) ? temp : throw new TypeError(...);
2742 Variable* temp = scope_->DeclarationScope()->NewTemporary( 2749 Variable* temp = scope_->DeclarationScope()->NewTemporary(
2743 ast_value_factory()->empty_string()); 2750 ast_value_factory()->empty_string());
2744 Assignment* assign = factory()->NewAssignment( 2751 Assignment* assign = factory()->NewAssignment(
2745 Token::ASSIGN, factory()->NewVariableProxy(temp), return_value, pos); 2752 Token::ASSIGN, factory()->NewVariableProxy(temp), return_value, pos);
2746 2753
2747 Expression* throw_expression = 2754 Expression* throw_expression =
2748 NewThrowTypeError("derived_constructor_return", 2755 NewThrowTypeError(MessageTemplate::kDerivedConstructorReturn,
2749 ast_value_factory()->empty_string(), pos); 2756 ast_value_factory()->empty_string(), pos);
2750 2757
2751 // %_IsSpecObject(temp) 2758 // %_IsSpecObject(temp)
2752 ZoneList<Expression*>* is_spec_object_args = 2759 ZoneList<Expression*>* is_spec_object_args =
2753 new (zone()) ZoneList<Expression*>(1, zone()); 2760 new (zone()) ZoneList<Expression*>(1, zone());
2754 is_spec_object_args->Add(factory()->NewVariableProxy(temp), zone()); 2761 is_spec_object_args->Add(factory()->NewVariableProxy(temp), zone());
2755 Expression* is_spec_object_call = factory()->NewCallRuntime( 2762 Expression* is_spec_object_call = factory()->NewCallRuntime(
2756 ast_value_factory()->is_spec_object_string(), 2763 ast_value_factory()->is_spec_object_string(),
2757 Runtime::FunctionForId(Runtime::kInlineIsSpecObject), 2764 Runtime::FunctionForId(Runtime::kInlineIsSpecObject),
2758 is_spec_object_args, pos); 2765 is_spec_object_args, pos);
(...skipping 21 matching lines...) Expand all
2780 function_state_->generator_object_variable()); 2787 function_state_->generator_object_variable());
2781 Expression* yield = factory()->NewYield( 2788 Expression* yield = factory()->NewYield(
2782 generator, return_value, Yield::kFinal, loc.beg_pos); 2789 generator, return_value, Yield::kFinal, loc.beg_pos);
2783 result = factory()->NewExpressionStatement(yield, loc.beg_pos); 2790 result = factory()->NewExpressionStatement(yield, loc.beg_pos);
2784 } else { 2791 } else {
2785 result = factory()->NewReturnStatement(return_value, loc.beg_pos); 2792 result = factory()->NewReturnStatement(return_value, loc.beg_pos);
2786 } 2793 }
2787 2794
2788 Scope* decl_scope = scope_->DeclarationScope(); 2795 Scope* decl_scope = scope_->DeclarationScope();
2789 if (decl_scope->is_script_scope() || decl_scope->is_eval_scope()) { 2796 if (decl_scope->is_script_scope() || decl_scope->is_eval_scope()) {
2790 ReportMessageAt(loc, "illegal_return"); 2797 ReportMessageAt(loc, MessageTemplate::kIllegalReturn);
2791 *ok = false; 2798 *ok = false;
2792 return NULL; 2799 return NULL;
2793 } 2800 }
2794 return result; 2801 return result;
2795 } 2802 }
2796 2803
2797 2804
2798 Statement* Parser::ParseWithStatement(ZoneList<const AstRawString*>* labels, 2805 Statement* Parser::ParseWithStatement(ZoneList<const AstRawString*>* labels,
2799 bool* ok) { 2806 bool* ok) {
2800 // WithStatement :: 2807 // WithStatement ::
2801 // 'with' '(' Expression ')' Statement 2808 // 'with' '(' Expression ')' Statement
2802 2809
2803 Expect(Token::WITH, CHECK_OK); 2810 Expect(Token::WITH, CHECK_OK);
2804 int pos = position(); 2811 int pos = position();
2805 2812
2806 if (is_strict(language_mode())) { 2813 if (is_strict(language_mode())) {
2807 ReportMessage("strict_mode_with"); 2814 ReportMessage(MessageTemplate::kStrictWith);
2808 *ok = false; 2815 *ok = false;
2809 return NULL; 2816 return NULL;
2810 } 2817 }
2811 2818
2812 Expect(Token::LPAREN, CHECK_OK); 2819 Expect(Token::LPAREN, CHECK_OK);
2813 Expression* expr = ParseExpression(true, CHECK_OK); 2820 Expression* expr = ParseExpression(true, CHECK_OK);
2814 Expect(Token::RPAREN, CHECK_OK); 2821 Expect(Token::RPAREN, CHECK_OK);
2815 2822
2816 scope_->DeclarationScope()->RecordWithStatement(); 2823 scope_->DeclarationScope()->RecordWithStatement();
2817 Scope* with_scope = NewScope(scope_, WITH_SCOPE); 2824 Scope* with_scope = NewScope(scope_, WITH_SCOPE);
(...skipping 12 matching lines...) Expand all
2830 // 'case' Expression ':' StatementList 2837 // 'case' Expression ':' StatementList
2831 // 'default' ':' StatementList 2838 // 'default' ':' StatementList
2832 2839
2833 Expression* label = NULL; // NULL expression indicates default case 2840 Expression* label = NULL; // NULL expression indicates default case
2834 if (peek() == Token::CASE) { 2841 if (peek() == Token::CASE) {
2835 Expect(Token::CASE, CHECK_OK); 2842 Expect(Token::CASE, CHECK_OK);
2836 label = ParseExpression(true, CHECK_OK); 2843 label = ParseExpression(true, CHECK_OK);
2837 } else { 2844 } else {
2838 Expect(Token::DEFAULT, CHECK_OK); 2845 Expect(Token::DEFAULT, CHECK_OK);
2839 if (*default_seen_ptr) { 2846 if (*default_seen_ptr) {
2840 ReportMessage("multiple_defaults_in_switch"); 2847 ReportMessage(MessageTemplate::kMultipleDefaultsInSwitch);
2841 *ok = false; 2848 *ok = false;
2842 return NULL; 2849 return NULL;
2843 } 2850 }
2844 *default_seen_ptr = true; 2851 *default_seen_ptr = true;
2845 } 2852 }
2846 Expect(Token::COLON, CHECK_OK); 2853 Expect(Token::COLON, CHECK_OK);
2847 int pos = position(); 2854 int pos = position();
2848 ZoneList<Statement*>* statements = 2855 ZoneList<Statement*>* statements =
2849 new(zone()) ZoneList<Statement*>(5, zone()); 2856 new(zone()) ZoneList<Statement*>(5, zone());
2850 Statement* stat = NULL; 2857 Statement* stat = NULL;
2851 while (peek() != Token::CASE && 2858 while (peek() != Token::CASE &&
2852 peek() != Token::DEFAULT && 2859 peek() != Token::DEFAULT &&
2853 peek() != Token::RBRACE) { 2860 peek() != Token::RBRACE) {
2854 stat = ParseStatementListItem(CHECK_OK); 2861 stat = ParseStatementListItem(CHECK_OK);
2855 statements->Add(stat, zone()); 2862 statements->Add(stat, zone());
2856 } 2863 }
2857 if (is_strong(language_mode()) && stat != NULL && !stat->IsJump() && 2864 if (is_strong(language_mode()) && stat != NULL && !stat->IsJump() &&
2858 peek() != Token::RBRACE) { 2865 peek() != Token::RBRACE) {
2859 ReportMessageAt(scanner()->location(), "strong_switch_fallthrough"); 2866 ReportMessageAt(scanner()->location(),
2867 MessageTemplate::kStrongSwitchFallthrough);
2860 *ok = false; 2868 *ok = false;
2861 return NULL; 2869 return NULL;
2862 } 2870 }
2863 return factory()->NewCaseClause(label, statements, pos); 2871 return factory()->NewCaseClause(label, statements, pos);
2864 } 2872 }
2865 2873
2866 2874
2867 SwitchStatement* Parser::ParseSwitchStatement( 2875 SwitchStatement* Parser::ParseSwitchStatement(
2868 ZoneList<const AstRawString*>* labels, bool* ok) { 2876 ZoneList<const AstRawString*>* labels, bool* ok) {
2869 // SwitchStatement :: 2877 // SwitchStatement ::
(...skipping 22 matching lines...) Expand all
2892 } 2900 }
2893 2901
2894 2902
2895 Statement* Parser::ParseThrowStatement(bool* ok) { 2903 Statement* Parser::ParseThrowStatement(bool* ok) {
2896 // ThrowStatement :: 2904 // ThrowStatement ::
2897 // 'throw' Expression ';' 2905 // 'throw' Expression ';'
2898 2906
2899 Expect(Token::THROW, CHECK_OK); 2907 Expect(Token::THROW, CHECK_OK);
2900 int pos = position(); 2908 int pos = position();
2901 if (scanner()->HasAnyLineTerminatorBeforeNext()) { 2909 if (scanner()->HasAnyLineTerminatorBeforeNext()) {
2902 ReportMessage("newline_after_throw"); 2910 ReportMessage(MessageTemplate::kNewlineAfterThrow);
2903 *ok = false; 2911 *ok = false;
2904 return NULL; 2912 return NULL;
2905 } 2913 }
2906 Expression* exception = ParseExpression(true, CHECK_OK); 2914 Expression* exception = ParseExpression(true, CHECK_OK);
2907 ExpectSemicolon(CHECK_OK); 2915 ExpectSemicolon(CHECK_OK);
2908 2916
2909 return factory()->NewExpressionStatement( 2917 return factory()->NewExpressionStatement(
2910 factory()->NewThrow(exception, pos), pos); 2918 factory()->NewThrow(exception, pos), pos);
2911 } 2919 }
2912 2920
(...skipping 10 matching lines...) Expand all
2923 // Finally :: 2931 // Finally ::
2924 // 'finally' Block 2932 // 'finally' Block
2925 2933
2926 Expect(Token::TRY, CHECK_OK); 2934 Expect(Token::TRY, CHECK_OK);
2927 int pos = position(); 2935 int pos = position();
2928 2936
2929 Block* try_block = ParseBlock(NULL, CHECK_OK); 2937 Block* try_block = ParseBlock(NULL, CHECK_OK);
2930 2938
2931 Token::Value tok = peek(); 2939 Token::Value tok = peek();
2932 if (tok != Token::CATCH && tok != Token::FINALLY) { 2940 if (tok != Token::CATCH && tok != Token::FINALLY) {
2933 ReportMessage("no_catch_or_finally"); 2941 ReportMessage(MessageTemplate::kNoCatchOrFinally);
2934 *ok = false; 2942 *ok = false;
2935 return NULL; 2943 return NULL;
2936 } 2944 }
2937 2945
2938 Scope* catch_scope = NULL; 2946 Scope* catch_scope = NULL;
2939 Variable* catch_variable = NULL; 2947 Variable* catch_variable = NULL;
2940 Block* catch_block = NULL; 2948 Block* catch_block = NULL;
2941 const AstRawString* name = NULL; 2949 const AstRawString* name = NULL;
2942 if (tok == Token::CATCH) { 2950 if (tok == Token::CATCH) {
2943 Consume(Token::CATCH); 2951 Consume(Token::CATCH);
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
3405 bool accept_OF = true; 3413 bool accept_OF = true;
3406 ForEachStatement::VisitMode mode; 3414 ForEachStatement::VisitMode mode;
3407 int each_beg_pos = scanner()->location().beg_pos; 3415 int each_beg_pos = scanner()->location().beg_pos;
3408 int each_end_pos = scanner()->location().end_pos; 3416 int each_end_pos = scanner()->location().end_pos;
3409 3417
3410 if (accept_IN && CheckInOrOf(accept_OF, &mode, ok)) { 3418 if (accept_IN && CheckInOrOf(accept_OF, &mode, ok)) {
3411 if (!*ok) return nullptr; 3419 if (!*ok) return nullptr;
3412 if (num_decl != 1) { 3420 if (num_decl != 1) {
3413 const char* loop_type = 3421 const char* loop_type =
3414 mode == ForEachStatement::ITERATE ? "for-of" : "for-in"; 3422 mode == ForEachStatement::ITERATE ? "for-of" : "for-in";
3415 ParserTraits::ReportMessageAt(parsing_result.bindings_loc, 3423 ParserTraits::ReportMessageAt(
3416 "for_inof_loop_multi_bindings", 3424 parsing_result.bindings_loc,
3417 loop_type); 3425 MessageTemplate::kForInOfLoopMultiBindings, loop_type);
3418 *ok = false; 3426 *ok = false;
3419 return nullptr; 3427 return nullptr;
3420 } 3428 }
3421 if (parsing_result.first_initializer_loc.IsValid() && 3429 if (parsing_result.first_initializer_loc.IsValid() &&
3422 (is_strict(language_mode()) || mode == ForEachStatement::ITERATE)) { 3430 (is_strict(language_mode()) || mode == ForEachStatement::ITERATE)) {
3423 if (mode == ForEachStatement::ITERATE) { 3431 if (mode == ForEachStatement::ITERATE) {
3424 ReportMessageAt(parsing_result.first_initializer_loc, 3432 ReportMessageAt(parsing_result.first_initializer_loc,
3425 "for_of_loop_initializer"); 3433 MessageTemplate::kForOfLoopInitializer);
3426 } else { 3434 } else {
3427 // TODO(caitp): This should be an error in sloppy mode too. 3435 // TODO(caitp): This should be an error in sloppy mode too.
3428 ReportMessageAt(parsing_result.first_initializer_loc, 3436 ReportMessageAt(parsing_result.first_initializer_loc,
3429 "for_in_loop_initializer"); 3437 MessageTemplate::kForInLoopInitializer);
3430 } 3438 }
3431 *ok = false; 3439 *ok = false;
3432 return nullptr; 3440 return nullptr;
3433 } 3441 }
3434 ForEachStatement* loop = 3442 ForEachStatement* loop =
3435 factory()->NewForEachStatement(mode, labels, stmt_pos); 3443 factory()->NewForEachStatement(mode, labels, stmt_pos);
3436 Target target(&this->target_stack_, loop); 3444 Target target(&this->target_stack_, loop);
3437 3445
3438 Expression* enumerable = ParseExpression(true, CHECK_OK); 3446 Expression* enumerable = ParseExpression(true, CHECK_OK);
3439 Expect(Token::RPAREN, CHECK_OK); 3447 Expect(Token::RPAREN, CHECK_OK);
(...skipping 28 matching lines...) Expand all
3468 bool accept_OF = true; 3476 bool accept_OF = true;
3469 ForEachStatement::VisitMode mode; 3477 ForEachStatement::VisitMode mode;
3470 int each_beg_pos = scanner()->location().beg_pos; 3478 int each_beg_pos = scanner()->location().beg_pos;
3471 int each_end_pos = scanner()->location().end_pos; 3479 int each_end_pos = scanner()->location().end_pos;
3472 3480
3473 if (accept_IN && CheckInOrOf(accept_OF, &mode, ok)) { 3481 if (accept_IN && CheckInOrOf(accept_OF, &mode, ok)) {
3474 if (!*ok) return nullptr; 3482 if (!*ok) return nullptr;
3475 if (num_decl != 1) { 3483 if (num_decl != 1) {
3476 const char* loop_type = 3484 const char* loop_type =
3477 mode == ForEachStatement::ITERATE ? "for-of" : "for-in"; 3485 mode == ForEachStatement::ITERATE ? "for-of" : "for-in";
3478 ParserTraits::ReportMessageAt(parsing_result.bindings_loc, 3486 ParserTraits::ReportMessageAt(
3479 "for_inof_loop_multi_bindings", 3487 parsing_result.bindings_loc,
3480 loop_type); 3488 MessageTemplate::kForInOfLoopMultiBindings, loop_type);
3481 *ok = false; 3489 *ok = false;
3482 return nullptr; 3490 return nullptr;
3483 } 3491 }
3484 if (parsing_result.first_initializer_loc.IsValid() && 3492 if (parsing_result.first_initializer_loc.IsValid() &&
3485 (is_strict(language_mode()) || mode == ForEachStatement::ITERATE)) { 3493 (is_strict(language_mode()) || mode == ForEachStatement::ITERATE)) {
3486 if (mode == ForEachStatement::ITERATE) { 3494 if (mode == ForEachStatement::ITERATE) {
3487 ReportMessageAt(parsing_result.first_initializer_loc, 3495 ReportMessageAt(parsing_result.first_initializer_loc,
3488 "for_of_loop_initializer"); 3496 MessageTemplate::kForOfLoopInitializer);
3489 } else { 3497 } else {
3490 ReportMessageAt(parsing_result.first_initializer_loc, 3498 ReportMessageAt(parsing_result.first_initializer_loc,
3491 "for_in_loop_initializer"); 3499 MessageTemplate::kForInLoopInitializer);
3492 } 3500 }
3493 *ok = false; 3501 *ok = false;
3494 return nullptr; 3502 return nullptr;
3495 } 3503 }
3496 // Rewrite a for-in statement of the form 3504 // Rewrite a for-in statement of the form
3497 // 3505 //
3498 // for (let/const x in e) b 3506 // for (let/const x in e) b
3499 // 3507 //
3500 // into 3508 // into
3501 // 3509 //
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
3552 ForEachStatement::VisitMode mode; 3560 ForEachStatement::VisitMode mode;
3553 bool accept_OF = expression->IsVariableProxy(); 3561 bool accept_OF = expression->IsVariableProxy();
3554 is_let_identifier_expression = 3562 is_let_identifier_expression =
3555 expression->IsVariableProxy() && 3563 expression->IsVariableProxy() &&
3556 expression->AsVariableProxy()->raw_name() == 3564 expression->AsVariableProxy()->raw_name() ==
3557 ast_value_factory()->let_string(); 3565 ast_value_factory()->let_string();
3558 3566
3559 if (CheckInOrOf(accept_OF, &mode, ok)) { 3567 if (CheckInOrOf(accept_OF, &mode, ok)) {
3560 if (!*ok) return nullptr; 3568 if (!*ok) return nullptr;
3561 expression = this->CheckAndRewriteReferenceExpression( 3569 expression = this->CheckAndRewriteReferenceExpression(
3562 expression, lhs_location, "invalid_lhs_in_for", CHECK_OK); 3570 expression, lhs_location, MessageTemplate::kInvalidLhsInFor,
3571 CHECK_OK);
3563 3572
3564 ForEachStatement* loop = 3573 ForEachStatement* loop =
3565 factory()->NewForEachStatement(mode, labels, stmt_pos); 3574 factory()->NewForEachStatement(mode, labels, stmt_pos);
3566 Target target(&this->target_stack_, loop); 3575 Target target(&this->target_stack_, loop);
3567 3576
3568 Expression* enumerable = ParseExpression(true, CHECK_OK); 3577 Expression* enumerable = ParseExpression(true, CHECK_OK);
3569 Expect(Token::RPAREN, CHECK_OK); 3578 Expect(Token::RPAREN, CHECK_OK);
3570 3579
3571 Statement* body = ParseSubStatement(NULL, CHECK_OK); 3580 Statement* body = ParseSubStatement(NULL, CHECK_OK);
3572 InitializeForEachStatement(loop, expression, enumerable, body); 3581 InitializeForEachStatement(loop, expression, enumerable, body);
(...skipping 11 matching lines...) Expand all
3584 } 3593 }
3585 3594
3586 // Standard 'for' loop 3595 // Standard 'for' loop
3587 ForStatement* loop = factory()->NewForStatement(labels, stmt_pos); 3596 ForStatement* loop = factory()->NewForStatement(labels, stmt_pos);
3588 Target target(&this->target_stack_, loop); 3597 Target target(&this->target_stack_, loop);
3589 3598
3590 // Parsed initializer at this point. 3599 // Parsed initializer at this point.
3591 // Detect attempts at 'let' declarations in sloppy mode. 3600 // Detect attempts at 'let' declarations in sloppy mode.
3592 if (peek() == Token::IDENTIFIER && is_sloppy(language_mode()) && 3601 if (peek() == Token::IDENTIFIER && is_sloppy(language_mode()) &&
3593 is_let_identifier_expression) { 3602 is_let_identifier_expression) {
3594 ReportMessage("sloppy_lexical", NULL); 3603 ReportMessage(MessageTemplate::kSloppyLexical, NULL);
3595 *ok = false; 3604 *ok = false;
3596 return NULL; 3605 return NULL;
3597 } 3606 }
3598 Expect(Token::SEMICOLON, CHECK_OK); 3607 Expect(Token::SEMICOLON, CHECK_OK);
3599 3608
3600 // If there are let bindings, then condition and the next statement of the 3609 // If there are let bindings, then condition and the next statement of the
3601 // for loop must be parsed in a new scope. 3610 // for loop must be parsed in a new scope.
3602 Scope* inner_scope = NULL; 3611 Scope* inner_scope = NULL;
3603 if (lexical_bindings.length() > 0) { 3612 if (lexical_bindings.length() > 0) {
3604 inner_scope = NewScope(for_scope, BLOCK_SCOPE); 3613 inner_scope = NewScope(for_scope, BLOCK_SCOPE);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
3715 3724
3716 Handle<FixedArray> CompileTimeValue::GetElements(Handle<FixedArray> value) { 3725 Handle<FixedArray> CompileTimeValue::GetElements(Handle<FixedArray> value) {
3717 return Handle<FixedArray>(FixedArray::cast(value->get(kElementsSlot))); 3726 return Handle<FixedArray>(FixedArray::cast(value->get(kElementsSlot)));
3718 } 3727 }
3719 3728
3720 3729
3721 void ParserTraits::DeclareArrowFunctionParameters( 3730 void ParserTraits::DeclareArrowFunctionParameters(
3722 Scope* scope, Expression* expr, const Scanner::Location& params_loc, 3731 Scope* scope, Expression* expr, const Scanner::Location& params_loc,
3723 Scanner::Location* duplicate_loc, bool* ok) { 3732 Scanner::Location* duplicate_loc, bool* ok) {
3724 if (scope->num_parameters() >= Code::kMaxArguments) { 3733 if (scope->num_parameters() >= Code::kMaxArguments) {
3725 ReportMessageAt(params_loc, "malformed_arrow_function_parameter_list"); 3734 ReportMessageAt(params_loc, MessageTemplate::kMalformedArrowFunParamList);
3726 *ok = false; 3735 *ok = false;
3727 return; 3736 return;
3728 } 3737 }
3729 3738
3730 // ArrowFunctionFormals :: 3739 // ArrowFunctionFormals ::
3731 // Binary(Token::COMMA, ArrowFunctionFormals, VariableProxy) 3740 // Binary(Token::COMMA, ArrowFunctionFormals, VariableProxy)
3732 // VariableProxy 3741 // VariableProxy
3733 // 3742 //
3734 // As we need to visit the parameters in left-to-right order, we recurse on 3743 // As we need to visit the parameters in left-to-right order, we recurse on
3735 // the left-hand side of comma expressions. 3744 // the left-hand side of comma expressions.
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
3982 if (!is_lazily_parsed) { 3991 if (!is_lazily_parsed) {
3983 body = ParseEagerFunctionBody(function_name, pos, fvar, fvar_init_op, 3992 body = ParseEagerFunctionBody(function_name, pos, fvar, fvar_init_op,
3984 kind, CHECK_OK); 3993 kind, CHECK_OK);
3985 materialized_literal_count = function_state.materialized_literal_count(); 3994 materialized_literal_count = function_state.materialized_literal_count();
3986 expected_property_count = function_state.expected_property_count(); 3995 expected_property_count = function_state.expected_property_count();
3987 handler_count = function_state.handler_count(); 3996 handler_count = function_state.handler_count();
3988 3997
3989 if (is_strong(language_mode()) && IsSubclassConstructor(kind)) { 3998 if (is_strong(language_mode()) && IsSubclassConstructor(kind)) {
3990 if (!function_state.super_location().IsValid()) { 3999 if (!function_state.super_location().IsValid()) {
3991 ReportMessageAt(function_name_location, 4000 ReportMessageAt(function_name_location,
3992 "strong_super_call_missing", kReferenceError); 4001 MessageTemplate::kStrongSuperCallMissing,
4002 kReferenceError);
3993 *ok = false; 4003 *ok = false;
3994 return nullptr; 4004 return nullptr;
3995 } 4005 }
3996 } 4006 }
3997 } 4007 }
3998 4008
3999 // Validate name and parameter names. We can do this only after parsing the 4009 // Validate name and parameter names. We can do this only after parsing the
4000 // function, since the function can declare itself strict. 4010 // function, since the function can declare itself strict.
4001 CheckFunctionName(language_mode(), kind, function_name, 4011 CheckFunctionName(language_mode(), kind, function_name,
4002 name_is_strict_reserved, function_name_location, 4012 name_is_strict_reserved, function_name_location,
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
4246 return result; 4256 return result;
4247 } 4257 }
4248 4258
4249 4259
4250 ClassLiteral* Parser::ParseClassLiteral(const AstRawString* name, 4260 ClassLiteral* Parser::ParseClassLiteral(const AstRawString* name,
4251 Scanner::Location class_name_location, 4261 Scanner::Location class_name_location,
4252 bool name_is_strict_reserved, int pos, 4262 bool name_is_strict_reserved, int pos,
4253 bool* ok) { 4263 bool* ok) {
4254 // All parts of a ClassDeclaration and ClassExpression are strict code. 4264 // All parts of a ClassDeclaration and ClassExpression are strict code.
4255 if (name_is_strict_reserved) { 4265 if (name_is_strict_reserved) {
4256 ReportMessageAt(class_name_location, "unexpected_strict_reserved"); 4266 ReportMessageAt(class_name_location,
4267 MessageTemplate::kUnexpectedStrictReserved);
4257 *ok = false; 4268 *ok = false;
4258 return NULL; 4269 return NULL;
4259 } 4270 }
4260 if (IsEvalOrArguments(name)) { 4271 if (IsEvalOrArguments(name)) {
4261 ReportMessageAt(class_name_location, "strict_eval_arguments"); 4272 ReportMessageAt(class_name_location, MessageTemplate::kStrictEvalArguments);
4262 *ok = false; 4273 *ok = false;
4263 return NULL; 4274 return NULL;
4264 } 4275 }
4265 if (is_strong(language_mode()) && IsUndefined(name)) { 4276 if (is_strong(language_mode()) && IsUndefined(name)) {
4266 ReportMessageAt(class_name_location, "strong_undefined"); 4277 ReportMessageAt(class_name_location, MessageTemplate::kStrongUndefined);
4267 *ok = false; 4278 *ok = false;
4268 return NULL; 4279 return NULL;
4269 } 4280 }
4270 4281
4271 // Create a block scope which is additionally tagged as class scope; this is 4282 // Create a block scope which is additionally tagged as class scope; this is
4272 // important for resolving variable references to the class name in the strong 4283 // important for resolving variable references to the class name in the strong
4273 // mode. 4284 // mode.
4274 Scope* block_scope = NewScope(scope_, BLOCK_SCOPE); 4285 Scope* block_scope = NewScope(scope_, BLOCK_SCOPE);
4275 block_scope->tag_as_class_scope(); 4286 block_scope->tag_as_class_scope();
4276 BlockState block_state(&scope_, block_scope); 4287 BlockState block_state(&scope_, block_scope);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
4385 // Check for built-in IS_VAR macro. 4396 // Check for built-in IS_VAR macro.
4386 if (function != NULL && 4397 if (function != NULL &&
4387 function->intrinsic_type == Runtime::RUNTIME && 4398 function->intrinsic_type == Runtime::RUNTIME &&
4388 function->function_id == Runtime::kIS_VAR) { 4399 function->function_id == Runtime::kIS_VAR) {
4389 // %IS_VAR(x) evaluates to x if x is a variable, 4400 // %IS_VAR(x) evaluates to x if x is a variable,
4390 // leads to a parse error otherwise. Could be implemented as an 4401 // leads to a parse error otherwise. Could be implemented as an
4391 // inline function %_IS_VAR(x) to eliminate this special case. 4402 // inline function %_IS_VAR(x) to eliminate this special case.
4392 if (args->length() == 1 && args->at(0)->AsVariableProxy() != NULL) { 4403 if (args->length() == 1 && args->at(0)->AsVariableProxy() != NULL) {
4393 return args->at(0); 4404 return args->at(0);
4394 } else { 4405 } else {
4395 ReportMessage("not_isvar"); 4406 ReportMessage(MessageTemplate::kNotIsvar);
4396 *ok = false; 4407 *ok = false;
4397 return NULL; 4408 return NULL;
4398 } 4409 }
4399 } 4410 }
4400 4411
4401 // Check that the expected number of arguments are being passed. 4412 // Check that the expected number of arguments are being passed.
4402 if (function != NULL && 4413 if (function != NULL &&
4403 function->nargs != -1 && 4414 function->nargs != -1 &&
4404 function->nargs != args->length()) { 4415 function->nargs != args->length()) {
4405 ReportMessage("illegal_access"); 4416 ReportMessage(MessageTemplate::kIllegalAccess);
4406 *ok = false; 4417 *ok = false;
4407 return NULL; 4418 return NULL;
4408 } 4419 }
4409 4420
4410 // Check that the function is defined if it's an inline runtime call. 4421 // Check that the function is defined if it's an inline runtime call.
4411 if (function == NULL && name->FirstCharacter() == '_') { 4422 if (function == NULL && name->FirstCharacter() == '_') {
4412 ParserTraits::ReportMessage("not_defined", name); 4423 ParserTraits::ReportMessage(MessageTemplate::kNotDefined, name);
4413 *ok = false; 4424 *ok = false;
4414 return NULL; 4425 return NULL;
4415 } 4426 }
4416 4427
4417 // We have a valid intrinsics call or a call to a builtin. 4428 // We have a valid intrinsics call or a call to a builtin.
4418 return factory()->NewCallRuntime(name, function, args, pos); 4429 return factory()->NewCallRuntime(name, function, args, pos);
4419 } 4430 }
4420 4431
4421 4432
4422 Literal* Parser::GetLiteralUndefined(int position) { 4433 Literal* Parser::GetLiteralUndefined(int position) {
4423 return factory()->NewUndefinedLiteral(position); 4434 return factory()->NewUndefinedLiteral(position);
4424 } 4435 }
4425 4436
4426 4437
4427 void Parser::CheckConflictingVarDeclarations(Scope* scope, bool* ok) { 4438 void Parser::CheckConflictingVarDeclarations(Scope* scope, bool* ok) {
4428 Declaration* decl = scope->CheckConflictingVarDeclarations(); 4439 Declaration* decl = scope->CheckConflictingVarDeclarations();
4429 if (decl != NULL) { 4440 if (decl != NULL) {
4430 // In harmony mode we treat conflicting variable bindinds as early 4441 // In harmony mode we treat conflicting variable bindinds as early
4431 // errors. See ES5 16 for a definition of early errors. 4442 // errors. See ES5 16 for a definition of early errors.
4432 const AstRawString* name = decl->proxy()->raw_name(); 4443 const AstRawString* name = decl->proxy()->raw_name();
4433 int position = decl->proxy()->position(); 4444 int position = decl->proxy()->position();
4434 Scanner::Location location = position == RelocInfo::kNoPosition 4445 Scanner::Location location = position == RelocInfo::kNoPosition
4435 ? Scanner::Location::invalid() 4446 ? Scanner::Location::invalid()
4436 : Scanner::Location(position, position + 1); 4447 : Scanner::Location(position, position + 1);
4437 ParserTraits::ReportMessageAt(location, "var_redeclaration", name); 4448 ParserTraits::ReportMessageAt(location, MessageTemplate::kVarRedeclaration,
4449 name);
4438 *ok = false; 4450 *ok = false;
4439 } 4451 }
4440 } 4452 }
4441 4453
4442 4454
4443 // ---------------------------------------------------------------------------- 4455 // ----------------------------------------------------------------------------
4444 // Parser support 4456 // Parser support
4445 4457
4446 bool Parser::TargetStackContainsLabel(const AstRawString* label) { 4458 bool Parser::TargetStackContainsLabel(const AstRawString* label) {
4447 for (Target* t = target_stack_; t != NULL; t = t->previous()) { 4459 for (Target* t = target_stack_; t != NULL; t = t->previous()) {
(...skipping 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after
5748 5760
5749 Expression* Parser::SpreadCallNew(Expression* function, 5761 Expression* Parser::SpreadCallNew(Expression* function,
5750 ZoneList<v8::internal::Expression*>* args, 5762 ZoneList<v8::internal::Expression*>* args,
5751 int pos) { 5763 int pos) {
5752 args->InsertAt(0, function, zone()); 5764 args->InsertAt(0, function, zone());
5753 5765
5754 return factory()->NewCallRuntime( 5766 return factory()->NewCallRuntime(
5755 ast_value_factory()->reflect_construct_string(), NULL, args, pos); 5767 ast_value_factory()->reflect_construct_string(), NULL, args, pos);
5756 } 5768 }
5757 } } // namespace v8::internal 5769 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/parser.h ('k') | src/pattern-rewriter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698