Skip to content

Commit 1fc633a

Browse files
committed
src: expose LookupAndCompile with parameters
1 parent 2649aab commit 1fc633a

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/node_builtins.cc

+11-3
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,6 @@ MaybeLocal<Function> BuiltinLoader::LookupAndCompileInternal(
373373
// Otherwise return a Local<Object> containing the cache.
374374
MaybeLocal<Function> BuiltinLoader::LookupAndCompile(
375375
Local<Context> context, const char* id, Environment* optional_env) {
376-
Result result;
377376
std::vector<Local<String>> parameters;
378377
Isolate* isolate = context->GetIsolate();
379378
// Detects parameters of the scripts based on module ids.
@@ -424,8 +423,17 @@ MaybeLocal<Function> BuiltinLoader::LookupAndCompile(
424423
};
425424
}
426425

427-
MaybeLocal<Function> maybe = GetInstance()->LookupAndCompileInternal(
428-
context, id, &parameters, &result);
426+
return LookupAndCompile(context, id, &parameters, optional_env);
427+
}
428+
429+
MaybeLocal<Function> BuiltinLoader::LookupAndCompile(
430+
Local<Context> context,
431+
const char* id,
432+
std::vector<Local<String>>* parameters,
433+
Environment* optional_env) {
434+
Result result;
435+
MaybeLocal<Function> maybe =
436+
GetInstance()->LookupAndCompileInternal(context, id, parameters, &result);
429437
if (optional_env != nullptr) {
430438
RecordResult(id, result, optional_env);
431439
}

src/node_builtins.h

+8
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ class NODE_EXTERN_PRIVATE BuiltinLoader {
5656
const char* id,
5757
Environment* optional_env);
5858

59+
// A variant of LookupAndCompile where parameters are explicitly
60+
// passed instead of guessed based on id pattern - used by embedders.
61+
static v8::MaybeLocal<v8::Function> LookupAndCompile(
62+
v8::Local<v8::Context> context,
63+
const char* id,
64+
std::vector<v8::Local<v8::String>>* parameters,
65+
Environment* optional_env);
66+
5967
static v8::MaybeLocal<v8::Value> CompileAndCall(
6068
v8::Local<v8::Context> context,
6169
const char* id,

0 commit comments

Comments
 (0)