Skip to content

Commit

Permalink
src: expose LookupAndCompile with parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Oct 26, 2022
1 parent 2649aab commit 5f9feee
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
12 changes: 10 additions & 2 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(
};
}

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);
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

0 comments on commit 5f9feee

Please sign in to comment.