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

Method compileToBytecode

valdi/src/valdi/hermes/HermesJavaScriptCompiler.cpp:103–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101 return compileFlags;
102}
103
104Shared<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
135HermesJavaScriptCompiler* HermesJavaScriptCompiler::get() {

Callers

nothing calls this directly

Calls 4

getCompileFlagsFunction · 0.85
onErrorMethod · 0.65
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected