| 250 | } |
| 251 | |
| 252 | BytesView HermesJavaScriptContext::preCompile(const std::string_view& script, |
| 253 | const std::string_view& sourceFilename, |
| 254 | JSExceptionTracker& exceptionTracker) { |
| 255 | #ifdef HERMESVM_LEAN |
| 256 | exceptionTracker.onError("Hermes not compiled with compilation enabled"); |
| 257 | return BytesView(); |
| 258 | #else |
| 259 | hermes::vm::GCScope gcScope(*_runtime); |
| 260 | auto formattedScript = Valdi::formatJsModule(script); |
| 261 | |
| 262 | auto serializedBytecode = |
| 263 | HermesJavaScriptCompiler::get()->compileToSerializedBytecode(formattedScript, sourceFilename, exceptionTracker); |
| 264 | |
| 265 | if (!exceptionTracker) { |
| 266 | return BytesView(); |
| 267 | } |
| 268 | |
| 269 | return Valdi::makePreCompiledJsModule(serializedBytecode.data(), serializedBytecode.size()); |
| 270 | #endif |
| 271 | } |
| 272 | |
| 273 | JSValueRef HermesJavaScriptContext::evaluatePreCompiled(const BytesView& script, |
| 274 | const std::string_view& sourceFilename, |
nothing calls this directly
no test coverage detected