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

Side by Side Diff: src/parser.cc

Issue 1094963002: [modules] Parsing: add ModuleRequests where missing (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/cctest/test-parsing.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 1506 matching lines...) Expand 10 before | Expand all | Expand 10 after
1517 // '*' 'as' ImportedBinding 1517 // '*' 'as' ImportedBinding
1518 1518
1519 int pos = peek_position(); 1519 int pos = peek_position();
1520 Expect(Token::IMPORT, CHECK_OK); 1520 Expect(Token::IMPORT, CHECK_OK);
1521 1521
1522 Token::Value tok = peek(); 1522 Token::Value tok = peek();
1523 1523
1524 // 'import' ModuleSpecifier ';' 1524 // 'import' ModuleSpecifier ';'
1525 if (tok == Token::STRING) { 1525 if (tok == Token::STRING) {
1526 const AstRawString* module_specifier = ParseModuleSpecifier(CHECK_OK); 1526 const AstRawString* module_specifier = ParseModuleSpecifier(CHECK_OK);
1527 scope_->module()->AddModuleRequest(module_specifier, zone());
1527 ExpectSemicolon(CHECK_OK); 1528 ExpectSemicolon(CHECK_OK);
1528 // TODO(ES6): Add module to the requested modules of scope_->module().
1529 USE(module_specifier);
1530 return factory()->NewEmptyStatement(pos); 1529 return factory()->NewEmptyStatement(pos);
1531 } 1530 }
1532 1531
1533 // Parse ImportedDefaultBinding if present. 1532 // Parse ImportedDefaultBinding if present.
1534 ImportDeclaration* import_default_declaration = NULL; 1533 ImportDeclaration* import_default_declaration = NULL;
1535 if (tok != Token::MUL && tok != Token::LBRACE) { 1534 if (tok != Token::MUL && tok != Token::LBRACE) {
1536 const AstRawString* local_name = 1535 const AstRawString* local_name =
1537 ParseIdentifier(kDontAllowRestrictedIdentifiers, CHECK_OK); 1536 ParseIdentifier(kDontAllowRestrictedIdentifiers, CHECK_OK);
1538 VariableProxy* proxy = NewUnresolved(local_name, IMPORT); 1537 VariableProxy* proxy = NewUnresolved(local_name, IMPORT);
1539 import_default_declaration = factory()->NewImportDeclaration( 1538 import_default_declaration = factory()->NewImportDeclaration(
(...skipping 20 matching lines...) Expand all
1560 1559
1561 default: 1560 default:
1562 *ok = false; 1561 *ok = false;
1563 ReportUnexpectedToken(scanner()->current_token()); 1562 ReportUnexpectedToken(scanner()->current_token());
1564 return NULL; 1563 return NULL;
1565 } 1564 }
1566 } 1565 }
1567 1566
1568 ExpectContextualKeyword(CStrVector("from"), CHECK_OK); 1567 ExpectContextualKeyword(CStrVector("from"), CHECK_OK);
1569 const AstRawString* module_specifier = ParseModuleSpecifier(CHECK_OK); 1568 const AstRawString* module_specifier = ParseModuleSpecifier(CHECK_OK);
1570 ExpectSemicolon(CHECK_OK);
1571
1572 scope_->module()->AddModuleRequest(module_specifier, zone()); 1569 scope_->module()->AddModuleRequest(module_specifier, zone());
1573 1570
1574 if (module_instance_binding != NULL) { 1571 if (module_instance_binding != NULL) {
1575 // TODO(ES6): Set the module specifier for the module namespace binding. 1572 // TODO(ES6): Set the module specifier for the module namespace binding.
1576 } 1573 }
1577 1574
1578 if (import_default_declaration != NULL) { 1575 if (import_default_declaration != NULL) {
1579 import_default_declaration->set_module_specifier(module_specifier); 1576 import_default_declaration->set_module_specifier(module_specifier);
1580 } 1577 }
1581 1578
1582 if (named_declarations != NULL) { 1579 if (named_declarations != NULL) {
1583 for (int i = 0; i < named_declarations->length(); ++i) { 1580 for (int i = 0; i < named_declarations->length(); ++i) {
1584 named_declarations->at(i)->set_module_specifier(module_specifier); 1581 named_declarations->at(i)->set_module_specifier(module_specifier);
1585 } 1582 }
1586 } 1583 }
1587 1584
1585 ExpectSemicolon(CHECK_OK);
1588 return factory()->NewEmptyStatement(pos); 1586 return factory()->NewEmptyStatement(pos);
1589 } 1587 }
1590 1588
1591 1589
1592 Statement* Parser::ParseExportDefault(bool* ok) { 1590 Statement* Parser::ParseExportDefault(bool* ok) {
1593 // Supports the following productions, starting after the 'default' token: 1591 // Supports the following productions, starting after the 'default' token:
1594 // 'export' 'default' FunctionDeclaration 1592 // 'export' 'default' FunctionDeclaration
1595 // 'export' 'default' ClassDeclaration 1593 // 'export' 'default' ClassDeclaration
1596 // 'export' 'default' AssignmentExpression[In] ';' 1594 // 'export' 'default' AssignmentExpression[In] ';'
1597 1595
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1653 Statement* result = NULL; 1651 Statement* result = NULL;
1654 ZoneList<const AstRawString*> names(1, zone()); 1652 ZoneList<const AstRawString*> names(1, zone());
1655 switch (peek()) { 1653 switch (peek()) {
1656 case Token::DEFAULT: 1654 case Token::DEFAULT:
1657 return ParseExportDefault(ok); 1655 return ParseExportDefault(ok);
1658 1656
1659 case Token::MUL: { 1657 case Token::MUL: {
1660 Consume(Token::MUL); 1658 Consume(Token::MUL);
1661 ExpectContextualKeyword(CStrVector("from"), CHECK_OK); 1659 ExpectContextualKeyword(CStrVector("from"), CHECK_OK);
1662 const AstRawString* module_specifier = ParseModuleSpecifier(CHECK_OK); 1660 const AstRawString* module_specifier = ParseModuleSpecifier(CHECK_OK);
1661 scope_->module()->AddModuleRequest(module_specifier, zone());
1662 // TODO(ES6): scope_->module()->AddStarExport(...)
1663 ExpectSemicolon(CHECK_OK); 1663 ExpectSemicolon(CHECK_OK);
1664 // TODO(ES6): scope_->module()->AddStarExport(...)
1665 USE(module_specifier);
1666 return factory()->NewEmptyStatement(pos); 1664 return factory()->NewEmptyStatement(pos);
1667 } 1665 }
1668 1666
1669 case Token::LBRACE: { 1667 case Token::LBRACE: {
1670 // There are two cases here: 1668 // There are two cases here:
1671 // 1669 //
1672 // 'export' ExportClause ';' 1670 // 'export' ExportClause ';'
1673 // and 1671 // and
1674 // 'export' ExportClause FromClause ';' 1672 // 'export' ExportClause FromClause ';'
1675 // 1673 //
(...skipping 4105 matching lines...) Expand 10 before | Expand all | Expand 10 after
5781 5779
5782 Expression* Parser::SpreadCallNew(Expression* function, 5780 Expression* Parser::SpreadCallNew(Expression* function,
5783 ZoneList<v8::internal::Expression*>* args, 5781 ZoneList<v8::internal::Expression*>* args,
5784 int pos) { 5782 int pos) {
5785 args->InsertAt(0, function, zone()); 5783 args->InsertAt(0, function, zone());
5786 5784
5787 return factory()->NewCallRuntime( 5785 return factory()->NewCallRuntime(
5788 ast_value_factory()->reflect_construct_string(), NULL, args, pos); 5786 ast_value_factory()->reflect_construct_string(), NULL, args, pos);
5789 } 5787 }
5790 } } // namespace v8::internal 5788 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698