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

Function compileAsIRString

compiler/companion/src/native/NativeCompiler.spec.ts:16–38  ·  view source on GitHub ↗
(
  text: string,
  options: NativeCompilerOptions,
  setupWorkspace: ((workpace: Workspace) => void) | undefined,
  filterIR: (ir: NativeCompilerIR.Base) => boolean,
)

Source from the content-addressed store, hash-verified

14}
15
16function compileAsIRString(
17 text: string,
18 options: NativeCompilerOptions,
19 setupWorkspace: ((workpace: Workspace) => void) | undefined,
20 filterIR: (ir: NativeCompilerIR.Base) => boolean,
21): string {
22 const workspace = new Workspace('/', false, undefined, {
23 target: ts.ScriptTarget.ESNext,
24 module: ts.ModuleKind.CommonJS,
25 lib: ['lib.es2015.d.ts'],
26 });
27
28 const filePath = 'file.ts';
29 workspace.registerInMemoryFile(filePath, text);
30 workspace.addSourceFileAtPath(filePath);
31 if (setupWorkspace) {
32 setupWorkspace(workspace);
33 }
34 const irs = compileFile(workspace, true, options, filePath, filePath);
35
36 const filteredIRs = irs.filter(filterIR);
37 return IRtoString(filteredIRs).trim();
38}
39
40function compileAsC(
41 text: string,

Callers 1

configuredCompileFunction · 0.85

Calls 6

registerInMemoryFileMethod · 0.95
addSourceFileAtPathMethod · 0.95
compileFileFunction · 0.90
IRtoStringFunction · 0.90
filterMethod · 0.80
trimMethod · 0.45

Tested by

no test coverage detected