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

Side by Side 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 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 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1415 // 'import' ModuleSpecifier ';' 1415 // 'import' ModuleSpecifier ';'
1416 if (tok == Token::STRING) { 1416 if (tok == Token::STRING) {
1417 const AstRawString* module_specifier = ParseModuleSpecifier(CHECK_OK); 1417 const AstRawString* module_specifier = ParseModuleSpecifier(CHECK_OK);
1418 ExpectSemicolon(CHECK_OK); 1418 ExpectSemicolon(CHECK_OK);
1419 // TODO(ES6): Add module to the requested modules of scope_->module(). 1419 // TODO(ES6): Add module to the requested modules of scope_->module().
1420 USE(module_specifier); 1420 USE(module_specifier);
1421 return factory()->NewEmptyStatement(pos); 1421 return factory()->NewEmptyStatement(pos);
1422 } 1422 }
1423 1423
1424 // Parse ImportedDefaultBinding if present. 1424 // Parse ImportedDefaultBinding if present.
1425 const AstRawString* imported_default_binding = NULL; 1425 ImportDeclaration* import_default_declaration = NULL;
1426 if (tok != Token::MUL && tok != Token::LBRACE) { 1426 if (tok != Token::MUL && tok != Token::LBRACE) {
1427 imported_default_binding = 1427 const AstRawString* local_name =
1428 ParseIdentifier(kDontAllowEvalOrArguments, CHECK_OK); 1428 ParseIdentifier(kDontAllowEvalOrArguments, CHECK_OK);
1429 // TODO(ES6): Add an appropriate declaration. 1429 VariableProxy* proxy = NewUnresolved(local_name, IMPORT);
1430 import_default_declaration = factory()->NewImportDeclaration(
1431 proxy, ast_value_factory()->default_string(), NULL, scope_, pos);
1432 Declare(import_default_declaration, true, CHECK_OK);
1430 } 1433 }
1431 1434
1432 const AstRawString* module_instance_binding = NULL; 1435 const AstRawString* module_instance_binding = NULL;
1433 ZoneList<ImportDeclaration*>* named_declarations = NULL; 1436 ZoneList<ImportDeclaration*>* named_declarations = NULL;
1434 if (imported_default_binding == NULL || Check(Token::COMMA)) { 1437 if (import_default_declaration == NULL || Check(Token::COMMA)) {
1435 switch (peek()) { 1438 switch (peek()) {
1436 case Token::MUL: { 1439 case Token::MUL: {
1437 Consume(Token::MUL); 1440 Consume(Token::MUL);
1438 ExpectContextualKeyword(CStrVector("as"), CHECK_OK); 1441 ExpectContextualKeyword(CStrVector("as"), CHECK_OK);
1439 module_instance_binding = 1442 module_instance_binding =
1440 ParseIdentifier(kDontAllowEvalOrArguments, CHECK_OK); 1443 ParseIdentifier(kDontAllowEvalOrArguments, CHECK_OK);
1441 // TODO(ES6): Add an appropriate declaration. 1444 // TODO(ES6): Add an appropriate declaration.
1442 break; 1445 break;
1443 } 1446 }
1444 1447
1445 case Token::LBRACE: 1448 case Token::LBRACE:
1446 named_declarations = ParseNamedImports(pos, CHECK_OK); 1449 named_declarations = ParseNamedImports(pos, CHECK_OK);
1447 break; 1450 break;
1448 1451
1449 default: 1452 default:
1450 *ok = false; 1453 *ok = false;
1451 ReportUnexpectedToken(scanner()->current_token()); 1454 ReportUnexpectedToken(scanner()->current_token());
1452 return NULL; 1455 return NULL;
1453 } 1456 }
1454 } 1457 }
1455 1458
1456 ExpectContextualKeyword(CStrVector("from"), CHECK_OK); 1459 ExpectContextualKeyword(CStrVector("from"), CHECK_OK);
1457 const AstRawString* module_specifier = ParseModuleSpecifier(CHECK_OK); 1460 const AstRawString* module_specifier = ParseModuleSpecifier(CHECK_OK);
1458 ExpectSemicolon(CHECK_OK); 1461 ExpectSemicolon(CHECK_OK);
1459 1462
1460 if (module_instance_binding != NULL) { 1463 if (module_instance_binding != NULL) {
1461 // TODO(ES6): Set the module specifier for the module namespace binding. 1464 // TODO(ES6): Set the module specifier for the module namespace binding.
1462 } 1465 }
1463 1466
1464 if (imported_default_binding != NULL) { 1467 if (import_default_declaration != NULL) {
1465 // TODO(ES6): Set the module specifier for the default binding. 1468 import_default_declaration->set_module_specifier(module_specifier);
1466 } 1469 }
1467 1470
1468 if (named_declarations != NULL) { 1471 if (named_declarations != NULL) {
1469 for (int i = 0; i < named_declarations->length(); ++i) { 1472 for (int i = 0; i < named_declarations->length(); ++i) {
1470 named_declarations->at(i)->set_module_specifier(module_specifier); 1473 named_declarations->at(i)->set_module_specifier(module_specifier);
1471 } 1474 }
1472 } 1475 }
1473 1476
1474 return factory()->NewEmptyStatement(pos); 1477 return factory()->NewEmptyStatement(pos);
1475 } 1478 }
(...skipping 3964 matching lines...) Expand 10 before | Expand all | Expand 10 after
5440 } else { 5443 } else {
5441 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); 5444 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data());
5442 running_hash = StringHasher::ComputeRunningHash(running_hash, data, 5445 running_hash = StringHasher::ComputeRunningHash(running_hash, data,
5443 raw_string->length()); 5446 raw_string->length());
5444 } 5447 }
5445 } 5448 }
5446 5449
5447 return running_hash; 5450 return running_hash;
5448 } 5451 }
5449 } } // namespace v8::internal 5452 } } // 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