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

Unified Diff: src/parser.cc

Issue 958213006: Create ImportDeclarations for default imports. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/cctest/test-parsing.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index f4828a0d5ca5f9a1e13c1ee934f8f4b043a62e1a..aa6ee8ccb6c67a3d210a39b18e97a31f9808ea32 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -1422,16 +1422,19 @@ Statement* Parser::ParseImportDeclaration(bool* ok) {
}
// Parse ImportedDefaultBinding if present.
- const AstRawString* imported_default_binding = NULL;
+ ImportDeclaration* import_default_declaration = NULL;
if (tok != Token::MUL && tok != Token::LBRACE) {
- imported_default_binding =
+ const AstRawString* local_name =
ParseIdentifier(kDontAllowEvalOrArguments, CHECK_OK);
- // TODO(ES6): Add an appropriate declaration.
+ VariableProxy* proxy = NewUnresolved(local_name, IMPORT);
+ import_default_declaration = factory()->NewImportDeclaration(
+ proxy, ast_value_factory()->default_string(), NULL, scope_, pos);
+ Declare(import_default_declaration, true, CHECK_OK);
}
const AstRawString* module_instance_binding = NULL;
ZoneList<ImportDeclaration*>* named_declarations = NULL;
- if (imported_default_binding == NULL || Check(Token::COMMA)) {
+ if (import_default_declaration == NULL || Check(Token::COMMA)) {
switch (peek()) {
case Token::MUL: {
Consume(Token::MUL);
@@ -1461,8 +1464,8 @@ Statement* Parser::ParseImportDeclaration(bool* ok) {
// TODO(ES6): Set the module specifier for the module namespace binding.
}
- if (imported_default_binding != NULL) {
- // TODO(ES6): Set the module specifier for the default binding.
+ if (import_default_declaration != NULL) {
+ import_default_declaration->set_module_specifier(module_specifier);
}
if (named_declarations != NULL) {
« 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