MCPcopy Create free account
hub / github.com/Snapchat/Valdi / evaluatePreCompiled

Method evaluatePreCompiled

valdi/src/valdi/quickjs/QuickJSJavaScriptContext.cpp:304–319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

302 JS_Eval(_context,
303 reinterpret_cast<const char*>(formattedScript.data()),
304 formattedScript.length(),
305 sourceFilename.data(),
306 JS_EVAL_FLAG_COMPILE_ONLY));
307 if (!exceptionTracker) {
308 return Valdi::BytesView();
309 }
310
311 size_t objectSize = 0;
312
313 auto* buffer = JS_WriteObject(_context, &objectSize, fromValdiJSValue(evalResult.get()), JS_WRITE_OBJ_BYTECODE);
314 if (buffer == nullptr) {
315 checkCallAndGetValue(exceptionTracker, JS_ThrowInternalError(_context, "Could not write object"));
316 return Valdi::BytesView();
317 }
318
319 auto jsModule = Valdi::makePreCompiledJsModule(reinterpret_cast<const Valdi::Byte*>(buffer), objectSize);
320
321 js_free(_context, buffer);
322

Callers

nothing calls this directly

Calls 6

JS_DupValueFunction · 0.85
guardMethod · 0.80
fromValdiJSValueFunction · 0.70
getMethod · 0.65
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected