Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: expose LookupAndCompile with parameters #45142

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/node_builtins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,6 @@ MaybeLocal<Function> BuiltinLoader::LookupAndCompileInternal(
// Otherwise return a Local<Object> containing the cache.
MaybeLocal<Function> BuiltinLoader::LookupAndCompile(
Local<Context> context, const char* id, Environment* optional_env) {
Result result;
std::vector<Local<String>> parameters;
Isolate* isolate = context->GetIsolate();
// Detects parameters of the scripts based on module ids.
Expand Down Expand Up @@ -424,8 +423,17 @@ MaybeLocal<Function> BuiltinLoader::LookupAndCompile(
};
}

MaybeLocal<Function> maybe = GetInstance()->LookupAndCompileInternal(
context, id, &parameters, &result);
return LookupAndCompile(context, id, &parameters, optional_env);
}

MaybeLocal<Function> BuiltinLoader::LookupAndCompile(
Local<Context> context,
const char* id,
std::vector<Local<String>>* parameters,
Environment* optional_env) {
Result result;
MaybeLocal<Function> maybe =
GetInstance()->LookupAndCompileInternal(context, id, parameters, &result);
if (optional_env != nullptr) {
RecordResult(id, result, optional_env);
}
Expand Down
8 changes: 8 additions & 0 deletions src/node_builtins.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ class NODE_EXTERN_PRIVATE BuiltinLoader {
const char* id,
Environment* optional_env);

// A variant of LookupAndCompile where parameters are explicitly
// passed instead of guessed based on id pattern - used by embedders.
static v8::MaybeLocal<v8::Function> LookupAndCompile(
v8::Local<v8::Context> context,
const char* id,
std::vector<v8::Local<v8::String>>* parameters,
Environment* optional_env);

static v8::MaybeLocal<v8::Value> CompileAndCall(
v8::Local<v8::Context> context,
const char* id,
Expand Down