Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions src/module_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,8 @@ ModuleCacheKey ModuleCacheKey::From(Local<Context> context,
DCHECK(DataIsString(import_attributes->Get(context, i)));
DCHECK(DataIsString(import_attributes->Get(context, i + 1)));

Local<String> v8_key = import_attributes->Get(context, i).As<String>();
Local<String> v8_value =
import_attributes->Get(context, i + 1).As<String>();
Local<String> v8_key = import_attributes->Get(i).As<String>();
Local<String> v8_value = import_attributes->Get(i + 1).As<String>();
Utf8Value key_utf8(isolate, v8_key);
Utf8Value value_utf8(isolate, v8_value);

Expand Down Expand Up @@ -547,8 +546,8 @@ static Local<Object> createImportAttributesContainer(
LocalVector<Value> values(isolate, num_attributes);

for (int i = 0; i < raw_attributes->Length(); i += elements_per_attribute) {
Local<Data> key = raw_attributes->Get(realm->context(), i);
Local<Data> value = raw_attributes->Get(realm->context(), i + 1);
Local<Data> key = raw_attributes->Get(i);
Local<Data> value = raw_attributes->Get(i + 1);
DCHECK(DataIsString(key));
DCHECK(DataIsString(value));

Expand All @@ -573,7 +572,7 @@ static Local<Array> createModuleRequestsContainer(
for (int i = 0; i < raw_requests->Length(); i++) {
DCHECK(raw_requests->Get(context, i)->IsModuleRequest());
Local<ModuleRequest> module_request =
raw_requests->Get(realm->context(), i).As<ModuleRequest>();
raw_requests->Get(i).As<ModuleRequest>();

Local<String> specifier = module_request->GetSpecifier();

Expand Down Expand Up @@ -661,8 +660,8 @@ void ModuleWrap::Link(const FunctionCallbackInfo<Value>& args) {
// TODO(joyeecheung): merge this with the serializeKey() in module_map.js.
// This currently doesn't sort the import attributes.
Local<Value> module_value = modules_vector[i].Get(isolate);
ModuleCacheKey module_cache_key = ModuleCacheKey::From(
context, requests->Get(context, i).As<ModuleRequest>());
ModuleCacheKey module_cache_key =
ModuleCacheKey::From(context, requests->Get(i).As<ModuleRequest>());
auto it = module_request_map.find(module_cache_key);
if (it == module_request_map.end()) {
// This is the first request with this identity, record it - any mismatch
Expand Down Expand Up @@ -1055,12 +1054,11 @@ MaybeLocal<Object> ModuleWrap::ResolveSourceCallback(
return module_source_object.As<Object>();
}

static std::string GetSpecifierFromModuleRequest(Local<Context> context,
Local<Module> referrer,
static std::string GetSpecifierFromModuleRequest(Local<Module> referrer,
size_t module_request_index) {
Local<ModuleRequest> raw_request =
referrer->GetModuleRequests()
->Get(context, static_cast<int>(module_request_index))
->Get(static_cast<int>(module_request_index))
.As<ModuleRequest>();
Local<String> specifier = raw_request->GetSpecifier();
Utf8Value specifier_utf8(Isolate::GetCurrent(), specifier);
Expand All @@ -1083,14 +1081,14 @@ Maybe<ModuleWrap*> ModuleWrap::ResolveModule(Local<Context> context,
ModuleWrap* dependent = ModuleWrap::GetFromModule(env, referrer);
if (dependent == nullptr) {
std::string specifier =
GetSpecifierFromModuleRequest(context, referrer, module_request_index);
GetSpecifierFromModuleRequest(referrer, module_request_index);
THROW_ERR_VM_MODULE_LINK_FAILURE(
env, "request for '%s' is from invalid module", specifier);
return Nothing<ModuleWrap*>();
}
if (!dependent->IsLinked()) {
std::string specifier =
GetSpecifierFromModuleRequest(context, referrer, module_request_index);
GetSpecifierFromModuleRequest(referrer, module_request_index);
THROW_ERR_VM_MODULE_LINK_FAILURE(env,
"request for '%s' can not be resolved on "
"module '%s' that is not linked",
Expand Down Expand Up @@ -1140,7 +1138,7 @@ static MaybeLocal<Promise> ImportModuleDynamicallyWithPhase(
// If the host-defined options are empty, get the referrer id symbol
// from the realm global object.
if (options->Length() == HostDefinedOptions::kLength) {
id = options->Get(context, HostDefinedOptions::kID).As<Symbol>();
id = options->Get(HostDefinedOptions::kID).As<Symbol>();
} else if (!context->Global()
->GetPrivate(context, env->host_defined_option_symbol())
.ToLocal(&id)) {
Expand Down
2 changes: 1 addition & 1 deletion src/node_builtins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ MaybeLocal<Module> BuiltinLoader::LoadBuiltinSourceTextModule(Realm* realm,
// Pre-fetch all dependencies.
if (requests->Length() > 0) {
for (int i = 0; i < requests->Length(); i++) {
Local<ModuleRequest> req = requests->Get(context, i).As<ModuleRequest>();
Local<ModuleRequest> req = requests->Get(i).As<ModuleRequest>();
std::string specifier =
Utf8Value(isolate, req->GetSpecifier()).ToString();
std::string resolved_id = ResolveRequestForBuiltin(specifier);
Expand Down
Loading