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

Unified Diff: src/runtime/runtime-module.cc

Issue 2703563002: [ESNext] Implement DynamicImportCall (Closed)
Patch Set: use function_closure Created 3 years, 9 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
Index: src/runtime/runtime-module.cc
diff --git a/src/runtime/runtime-module.cc b/src/runtime/runtime-module.cc
index f36a09b410bf00a8658882f021f0918bd6aff2c3..0a6ff6a9a65e2937ba4b790326524052c0dcf3a6 100644
--- a/src/runtime/runtime-module.cc
+++ b/src/runtime/runtime-module.cc
@@ -13,9 +13,26 @@ namespace internal {
RUNTIME_FUNCTION(Runtime_DynamicImportCall) {
HandleScope scope(isolate);
- DCHECK_EQ(1, args.length());
- // TODO(gsathya): Implement ImportCall.
- return isolate->heap()->undefined_value();
+ DCHECK_EQ(2, args.length());
+ CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
+ CONVERT_ARG_HANDLE_CHECKED(Object, specifier, 1);
+
+ Handle<String> specifier_str;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, specifier_str,
+ Object::ToString(isolate, specifier));
+
+ Handle<String> source_url;
+ Handle<Script> script(Script::cast(function->shared()->script()));
+ if (script->name()->IsUndefined(isolate)) {
+ source_url = isolate->factory()->empty_string();
+ } else {
+ source_url = handle(String::cast(script->name()), isolate);
+ }
+
+ Handle<JSPromise> promise = isolate->factory()->NewJSPromise();
+ isolate->RunHostImportModuleDynamicallyCallback(source_url, specifier_str,
+ promise);
+ return *promise;
}
RUNTIME_FUNCTION(Runtime_GetModuleNamespace) {

Powered by Google App Engine
This is Rietveld 408576698