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

Function configuredCompile

compiler/companion/src/native/NativeCompiler.spec.ts:89–146  ·  view source on GitHub ↗
(
  text: string,
  options: NativeCompilerOptions,
  includeFunctionArguments: boolean,
  includeRetainRelease: boolean,
  includeSlots: boolean,
  includeExceptionHandling: boolean,
  functionsToKeep: string[] | undefined,
  setupWorkspace?: ((workpace: Workspace) => void) | undefined,
)

Source from the content-addressed store, hash-verified

87 inComment = false;
88 }
89 if (inFunction && !inComment) {
90 output.push(line);
91 }
92 if (line.startsWith('}')) {
93 inFunction = false;
94 }
95 }
96 return output.join('\n');
97 }
98 return c_code;
99}
100
101function configuredCompile(
102 text: string,
103 options: NativeCompilerOptions,
104 includeFunctionArguments: boolean,
105 includeRetainRelease: boolean,
106 includeSlots: boolean,
107 includeExceptionHandling: boolean,
108 functionsToKeep: string[] | undefined,
109 setupWorkspace?: ((workpace: Workspace) => void) | undefined,
110): string {
111 let inExceptionJumpTarget = false;
112 let inRemovedFunction = false;
113 return compileAsIRString(text, options, setupWorkspace, (ir) => {
114 switch (ir.kind) {
115 case NativeCompilerIR.Kind.StartFunction: {
116 const typedIR = ir as NativeCompilerIR.StartFunction;
117 if (functionsToKeep === undefined || functionsToKeep.includes(typedIR.name)) {
118 return true;
119 } else {
120 inRemovedFunction = true;
121 return false;
122 }
123 }
124 case NativeCompilerIR.Kind.EndFunction: {
125 if (inRemovedFunction) {
126 inRemovedFunction = false;
127 return false;
128 } else {
129 return true;
130 }
131 }
132 case NativeCompilerIR.Kind.Slot:
133 return !inRemovedFunction && includeSlots;
134 case NativeCompilerIR.Kind.Retain:
135 return !inRemovedFunction && includeRetainRelease;
136 case NativeCompilerIR.Kind.Free:
137 return !inRemovedFunction && includeRetainRelease;
138 case NativeCompilerIR.Kind.GetFunctionArg:
139 return !inRemovedFunction && includeFunctionArguments;
140 case NativeCompilerIR.Kind.BindJumpTarget: {
141 const typedIR = ir as NativeCompilerIR.BindJumpTarget;
142
143 inExceptionJumpTarget = typedIR.target.tag === 'exception';
144 }
145 default: {
146 if (inRemovedFunction) {

Callers 2

compileSimplifiedFunction · 0.85

Calls 1

compileAsIRStringFunction · 0.85

Tested by

no test coverage detected