| 271 | |
| 272 | bool QuickJSJavaScriptContext::checkCall(Valdi::JSExceptionTracker& exceptionTracker, int retValue) { |
| 273 | if (retValue < 0) { |
| 274 | setExceptionToTracker(exceptionTracker); |
| 275 | return false; |
| 276 | } |
| 277 | return true; |
| 278 | } |
| 279 | |
| 280 | Valdi::JSValueRef QuickJSJavaScriptContext::getGlobalObject(Valdi::JSExceptionTracker& exceptionTracker) { |
| 281 | auto guard = _threadAccessChecker.guard(); |
| 282 | return checkCallAndGetValue(exceptionTracker, JS_GetGlobalObject(_context)); |
| 283 | } |
| 284 | |
| 285 | bool QuickJSJavaScriptContext::supportsPreCompilation() const { |
| 286 | return true; |
| 287 | } |
| 288 | |
| 289 | Valdi::BytesView QuickJSJavaScriptContext::preCompile(const std::string_view& script, |
| 290 | const std::string_view& sourceFilename, |
| 291 | Valdi::JSExceptionTracker& exceptionTracker) { |
| 292 | auto guard = _threadAccessChecker.guard(); |
| 293 | auto formattedScript = Valdi::formatJsModule(script); |
| 294 | |
| 295 | auto evalResult = checkCallAndGetValue(exceptionTracker, |
| 296 | JS_Eval(_context, |
| 297 | reinterpret_cast<const char*>(formattedScript.data()), |
| 298 | formattedScript.length(), |
| 299 | sourceFilename.data(), |
| 300 | JS_EVAL_FLAG_COMPILE_ONLY)); |
| 301 | if (!exceptionTracker) { |
| 302 | return Valdi::BytesView(); |
| 303 | } |
| 304 | |
| 305 | size_t objectSize = 0; |
nothing calls this directly
no test coverage detected