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

Method compile

valdi/src/valdi/hermes/HermesJavaScriptCompiler.cpp:30–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28
29#ifndef HERMESVM_LEAN
30Shared<hermes::hbc::BCProvider> HermesJavaScriptCompiler::compile(const std::string& script,
31 const std::string_view& sourceFilename,
32 JSExceptionTracker& exceptionTracker) {
33 std::lock_guard<Mutex> lock(_mutex);
34 auto entry = _cache.find(script);
35 if (entry != _cache.end()) {
36 return entry->value();
37 }
38
39 auto compiledBytecode = compileToBytecode(script,
40 sourceFilename,
41 hermes::OutputFormatKind::Execute,
42 {},
43 hermes::BytecodeGenerationOptions::defaults(),
44 exceptionTracker);
45
46 if (!exceptionTracker) {
47 return nullptr;
48 }
49
50 _cache.insert(script, compiledBytecode);
51
52 return compiledBytecode;
53}
54
55BytesView HermesJavaScriptCompiler::compileToSerializedBytecode(const std::string& script,
56 const std::string_view& sourceFilename,

Callers 6

_parse_interfacesFunction · 0.45
_parse_type_aliasesFunction · 0.45
_parse_enumsFunction · 0.45
_parse_class_methodsFunction · 0.45
evaluateMethod · 0.45
parse_iconsFunction · 0.45

Calls 4

endMethod · 0.65
valueMethod · 0.65
insertMethod · 0.65
findMethod · 0.45

Tested by

no test coverage detected