@samitouri / QOS-React-2 / commits / 8da443b673

Print HIR of function expressions for debugging

Example output: ``` bb0 (block): [1] Const mutate $9$ = read a$8 [2] Const store x$10:TObject$ = Object { a: read $9 } [3] Const mutate $11:TObject$ = capture x$10:TObject [4] Const store $12[4:6]:TFunction$ = Function @deps[read $11:TObject]: bb0 (block): [1] Const mutate q$7$ = capture x$6 [2] Const mutate $8$ = capture q$7 [3] Const mutate $9$ = PropertyLoad read $8.b [4] Const store $10[4:6]:TFunction$ = Function @deps[read $9]: bb0 (block): [1] Const mutate $7:TPrimitive$ = 1 [2] Const mutate $8[2:4]$ = capture q$6[0:4] [3] Const store $9$ = PropertyStore mutate $8[2:4].b = read $7:TPrimitive [4] Return [5] Const mutate $11$ = Call mutate $10[4:6]:TFunction() [6] Return [5] Const mutate $13$ = Call mutate $12[4:6]:TFunction() [6] Const mutate $14:TObject$ = capture x$10:TObject [7] Return freeze $14:TObject ```

Joe Savona committed Feb 22, 2023 at 13:03 UTC 8da443b6737fc00f61cc613475264fb971608867
1 file changed +6 -2
compiler/forget/src/HIR/PrintHIR.ts
+6 -2
@@ -333,11 +333,15 @@ export function printInstructionValue(instrValue: ReactiveValue): string {
333 break;
334 }
335 case "FunctionExpression": {
336 - const fn = generate(instrValue.expr).code;
336 + // const fn = generate(instrValue.expr).code;
337 + const fn = printFunction(instrValue.loweredFunc)
338 + .split("\n")
339 + .map((line) => ` ${line}`)
340 + .join("\n");
341 const deps = instrValue.dependencies
342 .map((i) => printIdentifier(i.identifier))
343 .join(",");
340 - value = `Function @deps[${deps}]{${fn}}`;
344 + value = `Function @deps[${deps}]:\n${fn}`;
345 break;
346 }
347 case "TaggedTemplateExpression": {