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

Unified Diff: src/interpreter/bytecode-generator.cc

Issue 2360063002: [modules] Basic support of import statements. (Closed)
Patch Set: . Created 4 years, 3 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 | « src/ast/modules.h ('k') | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/bytecode-generator.cc
diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc
index 330e638750bb156d609f16a21819d63b5853493f..5b3959f5c317e85875b160de8e97b7e1849c6ce9 100644
--- a/src/interpreter/bytecode-generator.cc
+++ b/src/interpreter/bytecode-generator.cc
@@ -2005,7 +2005,18 @@ void BytecodeGenerator::VisitVariableLoad(Variable* variable,
.StoreAccumulatorInRegister(export_name)
.CallRuntime(Runtime::kLoadModuleExport, export_name, 1);
} else {
- UNIMPLEMENTED();
+ auto it = descriptor->regular_imports().find(variable->raw_name());
rmcilroy 2016/09/22 10:18:13 Could you add some tests to test-bytecode-generato
+ DCHECK(it != descriptor->regular_imports().end());
+ register_allocator()->PrepareForConsecutiveAllocations(2);
+ Register import_name = register_allocator()->NextConsecutiveRegister();
+ Register module_request =
+ register_allocator()->NextConsecutiveRegister();
+ builder()
+ ->LoadLiteral(it->second->import_name->string())
+ .StoreAccumulatorInRegister(import_name)
+ .LoadLiteral(Smi::FromInt(it->second->module_request))
+ .StoreAccumulatorInRegister(module_request)
+ .CallRuntime(Runtime::kLoadModuleImport, import_name, 2);
}
break;
}
@@ -2205,6 +2216,8 @@ void BytecodeGenerator::VisitVariableAssignment(Variable* variable,
DCHECK(variable->IsExport());
ModuleDescriptor* mod = scope()->GetModuleScope()->module();
+ // There may be several export names for this local name, but it doesn't
+ // matter which one we pick, as they all map to the same cell.
auto it = mod->regular_exports().find(variable->raw_name());
DCHECK(it != mod->regular_exports().end());
« no previous file with comments | « src/ast/modules.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698