@@ -6,27 +6,29 @@ fun fib(a) = if
6
6
a <= 1 then a
7
7
else fib(a - 1) + fib(a - 2)
8
8
//│ JS:
9
+ //│ let tmp;
10
+ //│ tmp = this.Predef.TraceLogger.resetIndent(0) ?? null;
9
11
//│ function fib(...args) {
10
12
//│ globalThis.Predef.checkArgs("fib", 1, true, args.length);
11
13
//│ let a = args[0];
12
- //│ let scrut, traceLogEnterMsg, traceLogPrevIndent, traceLogRes, traceLogRetMsg, tmp, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
14
+ //│ let scrut, traceLogEnterMsg, traceLogPrevIndent, traceLogRes, traceLogRetMsg, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8 ;
13
15
//│ traceLogEnterMsg = globalThis.String.prototype.concat.call("calling: fib(", a, ")") ?? null;
14
- //│ tmp = globalThis.Predef.TraceLogger.log(traceLogEnterMsg) ?? null;
16
+ //│ tmp1 = globalThis.Predef.TraceLogger.log(traceLogEnterMsg) ?? null;
15
17
//│ traceLogPrevIndent = globalThis.Predef.TraceLogger.indent() ?? null;
16
18
//│ scrut = a <= 1;
17
19
//│ if (scrut) {
18
- //│ tmp1 = a;
20
+ //│ tmp2 = a;
19
21
//│ } else {
20
- //│ tmp2 = a - 1;
21
- //│ tmp3 = globalThis.fib(tmp2 ) ?? null;
22
- //│ tmp4 = a - 2;
23
- //│ tmp5 = globalThis.fib(tmp4 ) ?? null;
24
- //│ tmp1 = tmp3 + tmp5 ;
22
+ //│ tmp3 = a - 1;
23
+ //│ tmp4 = globalThis.fib(tmp3 ) ?? null;
24
+ //│ tmp5 = a - 2;
25
+ //│ tmp6 = globalThis.fib(tmp5 ) ?? null;
26
+ //│ tmp2 = tmp4 + tmp6 ;
25
27
//│ }
26
- //│ traceLogRes = tmp1 ;
28
+ //│ traceLogRes = tmp2 ;
27
29
//│ traceLogRetMsg = globalThis.String.prototype.concat.call("return: ", traceLogRes) ?? null;
28
- //│ tmp6 = globalThis.Predef.TraceLogger.resetIndent(traceLogPrevIndent) ?? null;
29
- //│ tmp7 = globalThis.Predef.TraceLogger.log(traceLogRetMsg) ?? null;
30
+ //│ tmp7 = globalThis.Predef.TraceLogger.resetIndent(traceLogPrevIndent) ?? null;
31
+ //│ tmp8 = globalThis.Predef.TraceLogger.log(traceLogRetMsg) ?? null;
30
32
//│ return traceLogRes;
31
33
//│ }
32
34
//│ undefined
@@ -86,32 +88,34 @@ fun g(z) =
86
88
fun f(x, y)(z) =
87
89
x + y + g(z)
88
90
//│ JS:
91
+ //│ let tmp;
92
+ //│ tmp = this.Predef.TraceLogger.resetIndent(0) ?? null;
89
93
//│ function f(...args) {
90
94
//│ globalThis.Predef.checkArgs("f", 2, true, args.length);
91
95
//│ let x = args[0];
92
96
//│ let y = args[1];
93
- //│ let traceLogEnterMsg, traceLogPrevIndent, traceLogRes, traceLogRetMsg, tmp, tmp1, tmp2;
97
+ //│ let traceLogEnterMsg, traceLogPrevIndent, traceLogRes, traceLogRetMsg, tmp1, tmp2, tmp3 ;
94
98
//│ traceLogEnterMsg = globalThis.String.prototype.concat.call("calling: f(", x, ", ", y, ")") ?? null;
95
- //│ tmp = globalThis.Predef.TraceLogger.log(traceLogEnterMsg) ?? null;
99
+ //│ tmp1 = globalThis.Predef.TraceLogger.log(traceLogEnterMsg) ?? null;
96
100
//│ traceLogPrevIndent = globalThis.Predef.TraceLogger.indent() ?? null;
97
101
//│ traceLogRes = (...args1) => {
98
102
//│ globalThis.Predef.checkArgs("", 1, true, args1.length);
99
103
//│ let z = args1[0];
100
- //│ let traceLogEnterMsg1, traceLogPrevIndent1, traceLogRes1, traceLogRetMsg1, tmp3, tmp4, tmp5, tmp6, tmp7;
104
+ //│ let traceLogEnterMsg1, traceLogPrevIndent1, traceLogRes1, traceLogRetMsg1, tmp4, tmp5, tmp6, tmp7, tmp8 ;
101
105
//│ traceLogEnterMsg1 = globalThis.String.prototype.concat.call("calling: [arrow function](", z, ")") ?? null;
102
- //│ tmp3 = globalThis.Predef.TraceLogger.log(traceLogEnterMsg1) ?? null;
106
+ //│ tmp4 = globalThis.Predef.TraceLogger.log(traceLogEnterMsg1) ?? null;
103
107
//│ traceLogPrevIndent1 = globalThis.Predef.TraceLogger.indent() ?? null;
104
- //│ tmp4 = x + y;
105
- //│ tmp5 = globalThis.g(z) ?? null;
106
- //│ traceLogRes1 = tmp4 + tmp5 ;
108
+ //│ tmp5 = x + y;
109
+ //│ tmp6 = globalThis.g(z) ?? null;
110
+ //│ traceLogRes1 = tmp5 + tmp6 ;
107
111
//│ traceLogRetMsg1 = globalThis.String.prototype.concat.call("return: ", traceLogRes1) ?? null;
108
- //│ tmp6 = globalThis.Predef.TraceLogger.resetIndent(traceLogPrevIndent1) ?? null;
109
- //│ tmp7 = globalThis.Predef.TraceLogger.log(traceLogRetMsg1) ?? null;
112
+ //│ tmp7 = globalThis.Predef.TraceLogger.resetIndent(traceLogPrevIndent1) ?? null;
113
+ //│ tmp8 = globalThis.Predef.TraceLogger.log(traceLogRetMsg1) ?? null;
110
114
//│ return traceLogRes1;
111
115
//│ };
112
116
//│ traceLogRetMsg = globalThis.String.prototype.concat.call("return: ", traceLogRes) ?? null;
113
- //│ tmp1 = globalThis.Predef.TraceLogger.resetIndent(traceLogPrevIndent) ?? null;
114
- //│ tmp2 = globalThis.Predef.TraceLogger.log(traceLogRetMsg) ?? null;
117
+ //│ tmp2 = globalThis.Predef.TraceLogger.resetIndent(traceLogPrevIndent) ?? null;
118
+ //│ tmp3 = globalThis.Predef.TraceLogger.log(traceLogRetMsg) ?? null;
115
119
//│ return traceLogRes;
116
120
//│ }
117
121
//│ undefined
@@ -120,12 +124,12 @@ fun f(x, y)(z) =
120
124
f(1,2)(0)
121
125
//│ ═══[RUNTIME ERROR] Error: oops
122
126
123
- // FIXME: always restore indent level at the beginning of each worksheet block
127
+
124
128
f(1,1)(1)
125
- //│ > | | calling: f(1, 1)
126
- //│ > | | return: (...args1) => { globalThis.Predef.checkArgs("", 1, true, args1.length); let z = args1[0]; let traceLogEnterMsg1, traceLogPrevIndent1, traceLogRes1, traceLogRetMsg1, tmp3, tmp4, tmp5, tmp6, tmp7; traceLogEnterMsg1 = globalThis.String.prototype.concat.call("calling: [arrow function](", z, ")") ?? null; tmp3 = globalThis.Predef.TraceLogger.log(traceLogEnterMsg1) ?? null; traceLogPrevIndent1 = globalThis.Predef.TraceLogger.indent() ?? null; tmp4 = x + y; tmp5 = globalThis.g(z) ?? null; traceLogRes1 = tmp4 + tmp5 ; traceLogRetMsg1 = globalThis.String.prototype.concat.call("return: ", traceLogRes1) ?? null; tmp6 = globalThis.Predef.TraceLogger.resetIndent(traceLogPrevIndent1) ?? null; tmp7 = globalThis.Predef.TraceLogger.log(traceLogRetMsg1) ?? null; return traceLogRes1; }
127
- //│ > | | calling: [arrow function](1)
128
- //│ > | | | calling: g(1)
129
- //│ > | | | return: 0
130
- //│ > | | return: 2
129
+ //│ > calling: f(1, 1)
130
+ //│ > return: (...args1) => { globalThis.Predef.checkArgs("", 1, true, args1.length); let z = args1[0]; let traceLogEnterMsg1, traceLogPrevIndent1, traceLogRes1, traceLogRetMsg1, tmp4, tmp5, tmp6, tmp7, tmp8 ; traceLogEnterMsg1 = globalThis.String.prototype.concat.call("calling: [arrow function](", z, ")") ?? null; tmp4 = globalThis.Predef.TraceLogger.log(traceLogEnterMsg1) ?? null; traceLogPrevIndent1 = globalThis.Predef.TraceLogger.indent() ?? null; tmp5 = x + y; tmp6 = globalThis.g(z) ?? null; traceLogRes1 = tmp5 + tmp6 ; traceLogRetMsg1 = globalThis.String.prototype.concat.call("return: ", traceLogRes1) ?? null; tmp7 = globalThis.Predef.TraceLogger.resetIndent(traceLogPrevIndent1) ?? null; tmp8 = globalThis.Predef.TraceLogger.log(traceLogRetMsg1) ?? null; return traceLogRes1; }
131
+ //│ > calling: [arrow function](1)
132
+ //│ > | calling: g(1)
133
+ //│ > | return: 0
134
+ //│ > return: 2
131
135
//│ = 2
0 commit comments