summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGus Caplan <me@gus.host>2019-09-09 12:20:16 -0500
committerRich Trott <rtrott@gmail.com>2019-10-02 15:54:35 -0700
commit5e7946fe79193633e9a78aae48548635cbc11023 (patch)
tree4ef3ab236df6aa8d570e22453dbe56b37487ad63 /src
parent6ba9471f6fcaaf377f22621c4d193d30e3877566 (diff)
downloadandroid-node-v8-5e7946fe79193633e9a78aae48548635cbc11023.tar.gz
android-node-v8-5e7946fe79193633e9a78aae48548635cbc11023.tar.bz2
android-node-v8-5e7946fe79193633e9a78aae48548635cbc11023.zip
vm: refactor SourceTextModule
- Removes redundant `instantiate` method - Refactors `link` to match the spec linking steps more accurately - Removes URL validation from SourceTextModule specifiers - DRYs some dynamic import logic Closes: https://github.com/nodejs/node/issues/29030 Co-Authored-By: Michaël Zasso <targos@protonmail.com> PR-URL: https://github.com/nodejs/node/pull/29776 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Diffstat (limited to 'src')
-rw-r--r--src/module_wrap.cc12
-rw-r--r--src/module_wrap.h2
2 files changed, 9 insertions, 5 deletions
diff --git a/src/module_wrap.cc b/src/module_wrap.cc
index aeb44675f6..4a572c00e1 100644
--- a/src/module_wrap.cc
+++ b/src/module_wrap.cc
@@ -331,7 +331,7 @@ void ModuleWrap::Evaluate(const FunctionCallbackInfo<Value>& args) {
args.GetReturnValue().Set(result.ToLocalChecked());
}
-void ModuleWrap::Namespace(const FunctionCallbackInfo<Value>& args) {
+void ModuleWrap::GetNamespace(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
Isolate* isolate = args.GetIsolate();
ModuleWrap* obj;
@@ -1328,8 +1328,12 @@ void ModuleWrap::HostInitializeImportMetaObjectCallback(
Local<Function> callback =
env->host_initialize_import_meta_object_callback();
Local<Value> args[] = { wrap, meta };
- callback->Call(context, Undefined(env->isolate()), arraysize(args), args)
- .ToLocalChecked();
+ TryCatchScope try_catch(env);
+ USE(callback->Call(
+ context, Undefined(env->isolate()), arraysize(args), args));
+ if (try_catch.HasCaught() && !try_catch.HasTerminated()) {
+ try_catch.ReThrow();
+ }
}
void ModuleWrap::SetInitializeImportMetaObjectCallback(
@@ -1360,7 +1364,7 @@ void ModuleWrap::Initialize(Local<Object> target,
env->SetProtoMethod(tpl, "link", Link);
env->SetProtoMethod(tpl, "instantiate", Instantiate);
env->SetProtoMethod(tpl, "evaluate", Evaluate);
- env->SetProtoMethodNoSideEffect(tpl, "namespace", Namespace);
+ env->SetProtoMethodNoSideEffect(tpl, "getNamespace", GetNamespace);
env->SetProtoMethodNoSideEffect(tpl, "getStatus", GetStatus);
env->SetProtoMethodNoSideEffect(tpl, "getError", GetError);
env->SetProtoMethodNoSideEffect(tpl, "getStaticDependencySpecifiers",
diff --git a/src/module_wrap.h b/src/module_wrap.h
index 6c79781a9d..9e2aa3b948 100644
--- a/src/module_wrap.h
+++ b/src/module_wrap.h
@@ -57,7 +57,7 @@ class ModuleWrap : public BaseObject {
static void Link(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Instantiate(const v8::FunctionCallbackInfo<v8::Value>& args);
static void Evaluate(const v8::FunctionCallbackInfo<v8::Value>& args);
- static void Namespace(const v8::FunctionCallbackInfo<v8::Value>& args);
+ static void GetNamespace(const v8::FunctionCallbackInfo<v8::Value>& args);
static void GetStatus(const v8::FunctionCallbackInfo<v8::Value>& args);
static void GetError(const v8::FunctionCallbackInfo<v8::Value>& args);
static void GetStaticDependencySpecifiers(