| 101 | return compileFlags; |
| 102 | } |
| 103 | |
| 104 | Shared<hermes::hbc::BCProviderFromSrc> HermesJavaScriptCompiler::compileToBytecode( |
| 105 | const std::string& script, |
| 106 | const std::string_view& sourceFilename, |
| 107 | hermes::OutputFormatKind outputFormat, |
| 108 | std::function<void(hermes::Module&)> runOptimizations, |
| 109 | const hermes::BytecodeGenerationOptions& bytecodeGenerationsOptions, |
| 110 | JSExceptionTracker& exceptionTracker) { |
| 111 | auto compileFlags = getCompileFlags(outputFormat, !runOptimizations); |
| 112 | |
| 113 | auto buffer = |
| 114 | std::make_unique<hermes::OwnedMemoryBuffer>(llvh::MemoryBuffer::getMemBuffer(llvh::StringRef(script))); |
| 115 | |
| 116 | auto res = hermes::hbc::BCProviderFromSrc::createBCProviderFromSrc( |
| 117 | std::move(buffer), |
| 118 | llvh::StringRef(sourceFilename.data(), sourceFilename.size()), |
| 119 | nullptr, |
| 120 | compileFlags, |
| 121 | {}, |
| 122 | {}, |
| 123 | nullptr, |
| 124 | runOptimizations, |
| 125 | bytecodeGenerationsOptions); |
| 126 | |
| 127 | if (!res.first) { |
| 128 | exceptionTracker.onError(res.second); |
| 129 | return nullptr; |
| 130 | } |
| 131 | |
| 132 | return Shared<hermes::hbc::BCProviderFromSrc>(std::move(res.first)); |
| 133 | } |
| 134 | |
| 135 | HermesJavaScriptCompiler* HermesJavaScriptCompiler::get() { |
nothing calls this directly
no test coverage detected