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

Function outputIR

compiler/companion/src/native/IRtoString.ts:150–699  ·  view source on GitHub ↗
(ir: NativeCompilerIR.Base, output: IRStringWriter)

Source from the content-addressed store, hash-verified

148 }
149 this.append(' ]');
150 return this;
151 }
152
153 appendJumpTarget(jumpTarget: NativeCompilerBuilderJumpTargetID): IRStringWriter {
154 return this.appendQuotedString(jumpTarget.tag);
155 }
156}
157
158function outputIR(ir: NativeCompilerIR.Base, output: IRStringWriter): IRStringWriter {
159 switch (ir.kind) {
160 case NativeCompilerIR.Kind.Slot: {
161 const typedIR = ir as NativeCompilerIR.Slot;
162 // slot '<type>' <variable>
163 return output.append('slot').appendQuotedString(typedIR.value.getTypeString()).appendVariable(typedIR.value);
164 }
165 case NativeCompilerIR.Kind.Global: {
166 const typedIR = ir as NativeCompilerIR.Global;
167
168 // getglobal <output_variable>
169
170 return output.append(`getglobal`).appendVariable(typedIR.variable);
171 }
172 case NativeCompilerIR.Kind.Keyword: {
173 const typedIR = ir as NativeCompilerIR.Keyword;
174 // storeundefined <output_variable>
175 // storenull <output_variable>
176 // storethis <output_variable>
177
178 switch (typedIR.keyword) {
179 case NativeCompilerIR.KeywordKind.Undefined:
180 return output.append(`storeundefined`).appendVariable(typedIR.variable);
181 case NativeCompilerIR.KeywordKind.Null:
182 return output.append(`storenull`).appendVariable(typedIR.variable);
183 case NativeCompilerIR.KeywordKind.This:
184 return output.append(`storethis`).appendVariable(typedIR.variable);
185 }
186 }
187 case NativeCompilerIR.Kind.Exception: {
188 const typedIR = ir as NativeCompilerIR.Exception;
189
190 // storeexception <output_variable>
191
192 return output.append(`storeexception`).appendVariable(typedIR.variable);
193 }
194 case NativeCompilerIR.Kind.SetProperty: {
195 const typedIR = ir as NativeCompilerIR.SetProperty;
196
197 // setprop <object> <prop> <value>
198
199 if (typedIR.properties.length == 1) {
200 return output
201 .append('setprop')
202 .appendVariable(typedIR.object)
203 .appendAtom(typedIR.properties[0])
204 .appendVariable(typedIR.values[0]);
205 } else {
206 return output
207 .append('setprops')

Callers 1

IRtoStringFunction · 0.85

Calls 11

getUnaryOperatorNameFunction · 0.85
getBinaryOpOperatorNameFunction · 0.85
getBranchTypeNameFunction · 0.85
appendVariableMethod · 0.80
appendQuotedStringMethod · 0.80
getTypeStringMethod · 0.80
appendAtomMethod · 0.80
appendVariablesMethod · 0.80
appendAtomsMethod · 0.80
appendJumpTargetMethod · 0.80
appendMethod · 0.65

Tested by

no test coverage detected