@@ -13,58 +13,37 @@ fun f() =
13
13
1
14
14
f() + f() + f()
15
15
//│ JS (unsanitized):
16
- //│ let Effect1, tmp, handleBlock$, Cont$func$f$1, Cont$handleBlock$h$1, hdlrFun, Handler$h$1, f$, doUnwind$, Cont$func$f$$ctor, Cont$func$f$$, Cont$handleBlock$h$$ctor, Cont$handleBlock$h$$, hdlrFun$;
16
+ //│ let f, Effect1, h, tmp, handleBlock$, hdlrFun, Handler$h$1, Cont$func$f$1, Cont$handleBlock$h$1, doUnwind$, Cont$func$f$$ctor, Cont$func$f$$, doUnwind$1 , Cont$handleBlock$h$$ctor, Cont$handleBlock$h$$, hdlrFun$;
17
17
//│ Effect1 = class Effect {
18
18
//│ constructor() {}
19
19
//│ toString() { return "Effect"; }
20
20
//│ };
21
- //│ hdlrFun$ = function hdlrFun$(Handler$h$$instance, k) {
22
- //│ return runtime.safeCall(k())
23
- //│ };
24
- //│ hdlrFun = function hdlrFun(Handler$h$$instance) {
25
- //│ return (k) => {
26
- //│ return hdlrFun$(Handler$h$$instance, k)
27
- //│ }
28
- //│ };
29
- //│ Handler$h$1 = class Handler$h$ extends Effect1 {
30
- //│ constructor() {
31
- //│ let tmp1;
32
- //│ tmp1 = super();
33
- //│ }
34
- //│ perform() {
35
- //│ let hdlrFun$this;
36
- //│ hdlrFun$this = runtime.safeCall(hdlrFun(this));
37
- //│ return runtime.mkEffect(this, hdlrFun$this)
38
- //│ }
39
- //│ toString() { return "Handler$h$"; }
40
- //│ };
41
- //│ Cont$handleBlock$h$$ = function Cont$handleBlock$h$$(h$0, tmp$1, tmp$2, tmp$3, tmp$4, pc) {
21
+ //│ Cont$handleBlock$h$$ = function Cont$handleBlock$h$$(tmp$0, tmp$1, tmp$2, tmp$3, pc) {
42
22
//│ let tmp1;
43
23
//│ tmp1 = new Cont$handleBlock$h$1.class(pc);
44
- //│ return tmp1(h $0, tmp$1, tmp$2, tmp$3, tmp$4 )
24
+ //│ return tmp1(tmp $0, tmp$1, tmp$2, tmp$3)
45
25
//│ };
46
- //│ Cont$handleBlock$h$$ctor = function Cont$handleBlock$h$$ctor(h $0, tmp$1, tmp$2, tmp$3, tmp$4 ) {
26
+ //│ Cont$handleBlock$h$$ctor = function Cont$handleBlock$h$$ctor(tmp $0, tmp$1, tmp$2, tmp$3) {
47
27
//│ return (pc) => {
48
28
//│ let tmp1;
49
29
//│ tmp1 = new Cont$handleBlock$h$1.class(pc);
50
- //│ return tmp1(h $0, tmp$1, tmp$2, tmp$3, tmp$4 )
30
+ //│ return tmp1(tmp $0, tmp$1, tmp$2, tmp$3)
51
31
//│ }
52
32
//│ };
53
33
//│ Cont$handleBlock$h$1 = function Cont$handleBlock$h$(pc1) {
54
- //│ return (h $01, tmp$11, tmp$21, tmp$31, tmp$41 ) => {
55
- //│ return new Cont$handleBlock$h$.class(pc1)(h $01, tmp$11, tmp$21, tmp$31, tmp$41 );
34
+ //│ return (tmp $01, tmp$11, tmp$21, tmp$31) => {
35
+ //│ return new Cont$handleBlock$h$.class(pc1)(tmp $01, tmp$11, tmp$21, tmp$31);
56
36
//│ }
57
37
//│ };
58
38
//│ Cont$handleBlock$h$1.class = class Cont$handleBlock$h$ extends runtime.FunctionContFrame.class {
59
39
//│ constructor(pc) {
60
- //│ return (h $0, tmp$1, tmp$2, tmp$3, tmp$4 ) => {
40
+ //│ return (tmp $0, tmp$1, tmp$2, tmp$3) => {
61
41
//│ let tmp1;
62
42
//│ tmp1 = super(null);
63
- //│ this.h $0 = h $0;
43
+ //│ this.tmp $0 = tmp $0;
64
44
//│ this.tmp$1 = tmp$1;
65
45
//│ this.tmp$2 = tmp$2;
66
46
//│ this.tmp$3 = tmp$3;
67
- //│ this.tmp$4 = tmp$4;
68
47
//│ this.pc = pc;
69
48
//│ return this;
70
49
//│ }
@@ -77,42 +56,53 @@ f() + f() + f()
77
56
//│ }
78
57
//│ resume(value$) {
79
58
//│ if (this.pc === 2) {
80
- //│ this.tmp$1 = value$;
59
+ //│ this.tmp$0 = value$;
81
60
//│ } else if (this.pc === 3) {
82
- //│ this.tmp$2 = value$;
61
+ //│ this.tmp$1 = value$;
83
62
//│ } else if (this.pc === 4) {
84
- //│ this.tmp$4 = value$;
63
+ //│ this.tmp$3 = value$;
85
64
//│ }
86
65
//│ contLoop: while (true) {
87
- //│ if (this.pc === 2) {
66
+ //│ if (this.pc === 0) {
67
+ //│ this.tmp$0 = f();
68
+ //│ if (this.tmp$0 instanceof runtime.EffectSig.class) {
69
+ //│ return this.doUnwind(this.tmp$0, 2)
70
+ //│ }
71
+ //│ this.pc = 2;
72
+ //│ continue contLoop;
73
+ //│ } else if (this.pc === 2) {
88
74
//│ this.pc = 6;
89
75
//│ continue contLoop;
90
76
//│ } else if (this.pc === 6) {
91
- //│ this.tmp$2 = f$(this.h$0 );
92
- //│ if (this.tmp$2 instanceof runtime.EffectSig.class) {
93
- //│ return this.doUnwind(this.tmp$2 , 3)
77
+ //│ this.tmp$1 = f( );
78
+ //│ if (this.tmp$1 instanceof runtime.EffectSig.class) {
79
+ //│ return this.doUnwind(this.tmp$1 , 3)
94
80
//│ }
95
81
//│ this.pc = 3;
96
82
//│ continue contLoop;
97
83
//│ } else if (this.pc === 3) {
98
- //│ this.tmp$3 = this.tmp$1 + this.tmp$2 ;
84
+ //│ this.tmp$2 = this.tmp$0 + this.tmp$1 ;
99
85
//│ this.pc = 5;
100
86
//│ continue contLoop;
101
87
//│ } else if (this.pc === 5) {
102
- //│ this.tmp$4 = f$(this.h$0 );
103
- //│ if (this.tmp$4 instanceof runtime.EffectSig.class) {
104
- //│ return this.doUnwind(this.tmp$4 , 4)
88
+ //│ this.tmp$3 = f( );
89
+ //│ if (this.tmp$3 instanceof runtime.EffectSig.class) {
90
+ //│ return this.doUnwind(this.tmp$3 , 4)
105
91
//│ }
106
92
//│ this.pc = 4;
107
93
//│ continue contLoop;
108
94
//│ } else if (this.pc === 4) {
109
- //│ return this.tmp$3 + this.tmp$4
95
+ //│ return this.tmp$2 + this.tmp$3
110
96
//│ }
111
97
//│ break;
112
98
//│ }
113
99
//│ }
114
100
//│ toString() { return "Cont$handleBlock$h$(" + runtime.render(this.pc) + ")"; }
115
101
//│ };
102
+ //│ doUnwind$1 = function doUnwind$(tmp1, tmp2, tmp3, tmp4, res, pc) {
103
+ //│ res.contTrace.last.next = Cont$handleBlock$h$$(tmp1, tmp2, tmp3, tmp4, pc);
104
+ //│ return runtime.handleBlockImpl(res, h)
105
+ //│ };
116
106
//│ Cont$func$f$$ = function Cont$func$f$$(tmp$0, pc) {
117
107
//│ let tmp1;
118
108
//│ tmp1 = new Cont$func$f$1.class(pc);
@@ -140,12 +130,25 @@ f() + f() + f()
140
130
//│ return this;
141
131
//│ }
142
132
//│ }
133
+ //│ doUnwind(res, newPc) {
134
+ //│ this.pc = newPc;
135
+ //│ res.contTrace.last.next = this;
136
+ //│ res.contTrace.last = this;
137
+ //│ return res
138
+ //│ }
143
139
//│ resume(value$) {
144
140
//│ if (this.pc === 1) {
145
141
//│ this.tmp$0 = value$;
146
142
//│ }
147
143
//│ contLoop: while (true) {
148
- //│ if (this.pc === 1) {
144
+ //│ if (this.pc === 0) {
145
+ //│ this.tmp$0 = runtime.safeCall(h.perform());
146
+ //│ if (this.tmp$0 instanceof runtime.EffectSig.class) {
147
+ //│ return this.doUnwind(this.tmp$0, 1)
148
+ //│ }
149
+ //│ this.pc = 1;
150
+ //│ continue contLoop;
151
+ //│ } else if (this.pc === 1) {
149
152
//│ return 1
150
153
//│ }
151
154
//│ break;
@@ -158,7 +161,7 @@ f() + f() + f()
158
161
//│ res.contTrace.last = res.contTrace.last.next;
159
162
//│ return res
160
163
//│ };
161
- //│ f$ = function f$(h ) {
164
+ //│ f = function f( ) {
162
165
//│ let tmp1;
163
166
//│ tmp1 = runtime.safeCall(h.perform());
164
167
//│ if (tmp1 instanceof runtime.EffectSig.class) {
@@ -167,26 +170,43 @@ f() + f() + f()
167
170
//│ return 1
168
171
//│ };
169
172
//│ handleBlock$ = function handleBlock$() {
170
- //│ let h, tmp1, tmp2, tmp3, tmp4;
171
- //│ h = new Handler$h$1();
172
- //│ tmp1 = f$(h);
173
+ //│ let tmp1, tmp2, tmp3, tmp4;
174
+ //│ tmp1 = f();
173
175
//│ if (tmp1 instanceof runtime.EffectSig.class) {
174
- //│ tmp1.contTrace.last.next = Cont$handleBlock$h$$(h, tmp1, tmp2, tmp3, tmp4, 2);
175
- //│ return runtime.handleBlockImpl(tmp1, h)
176
+ //│ return doUnwind$1(tmp1, tmp2, tmp3, tmp4, tmp1, 2)
176
177
//│ }
177
- //│ tmp2 = f$(h );
178
+ //│ tmp2 = f( );
178
179
//│ if (tmp2 instanceof runtime.EffectSig.class) {
179
- //│ tmp2.contTrace.last.next = Cont$handleBlock$h$$(h, tmp1, tmp2, tmp3, tmp4, 3);
180
- //│ return runtime.handleBlockImpl(tmp2, h)
180
+ //│ return doUnwind$1(tmp1, tmp2, tmp3, tmp4, tmp2, 3)
181
181
//│ }
182
182
//│ tmp3 = tmp1 + tmp2;
183
- //│ tmp4 = f$(h );
183
+ //│ tmp4 = f( );
184
184
//│ if (tmp4 instanceof runtime.EffectSig.class) {
185
- //│ tmp4.contTrace.last.next = Cont$handleBlock$h$$(h, tmp1, tmp2, tmp3, tmp4, 4);
186
- //│ return runtime.handleBlockImpl(tmp4, h)
185
+ //│ return doUnwind$1(tmp1, tmp2, tmp3, tmp4, tmp4, 4)
187
186
//│ }
188
187
//│ return tmp3 + tmp4
189
188
//│ };
189
+ //│ hdlrFun$ = function hdlrFun$(Handler$h$$instance, k) {
190
+ //│ return runtime.safeCall(k())
191
+ //│ };
192
+ //│ hdlrFun = function hdlrFun(Handler$h$$instance) {
193
+ //│ return (k) => {
194
+ //│ return hdlrFun$(Handler$h$$instance, k)
195
+ //│ }
196
+ //│ };
197
+ //│ Handler$h$1 = class Handler$h$ extends Effect1 {
198
+ //│ constructor() {
199
+ //│ let tmp1;
200
+ //│ tmp1 = super();
201
+ //│ }
202
+ //│ perform() {
203
+ //│ let hdlrFun$this;
204
+ //│ hdlrFun$this = runtime.safeCall(hdlrFun(this));
205
+ //│ return runtime.mkEffect(this, hdlrFun$this)
206
+ //│ }
207
+ //│ toString() { return "Handler$h$"; }
208
+ //│ };
209
+ //│ h = new Handler$h$1();
190
210
//│ tmp = handleBlock$();
191
211
//│ if (tmp instanceof runtime.EffectSig.class) {
192
212
//│ tmp = runtime.topLevelEffect(tmp, false);
@@ -202,7 +222,7 @@ fun f(x) =
202
222
Test()
203
223
f(1).get()
204
224
//│ JS (unsanitized):
205
- //│ let Test1, f , tmp1, Test$ctor, Test$;
225
+ //│ let Test1, f1 , tmp1, Test$ctor, Test$;
206
226
//│ Test$ = function Test$(x$0) {
207
227
//│ let tmp2;
208
228
//│ tmp2 = new Test1.class();
@@ -232,10 +252,10 @@ f(1).get()
232
252
//│ }
233
253
//│ toString() { return "Test(" + "" + ")"; }
234
254
//│ };
235
- //│ f = function f(x) {
255
+ //│ f1 = function f(x) {
236
256
//│ return Test$(x)
237
257
//│ };
238
- //│ tmp1 = f (1);
258
+ //│ tmp1 = f1 (1);
239
259
//│ runtime.safeCall(tmp1.get())
240
260
//│ = 1
241
261
@@ -252,7 +272,7 @@ fun f(used1, unused1) =
252
272
Test(unused1)
253
273
f(1, 2).get()
254
274
//│ JS (unsanitized):
255
- //│ let Test3, f1 , tmp2, Test$ctor1, Test$1, g$, h$;
275
+ //│ let Test3, f2 , tmp2, Test$ctor1, Test$1, g$, h$;
256
276
//│ h$ = function h$(used3) {
257
277
//│ return used3
258
278
//│ };
@@ -292,12 +312,12 @@ f(1, 2).get()
292
312
//│ }
293
313
//│ toString() { return "Test(" + runtime.render(this.a) + ")"; }
294
314
//│ };
295
- //│ f1 = function f(used1, unused1) {
315
+ //│ f2 = function f(used1, unused1) {
296
316
//│ let unused2;
297
317
//│ unused2 = 2;
298
318
//│ return Test$1(used1, unused1)
299
319
//│ };
300
- //│ tmp2 = f1 (1, 2);
320
+ //│ tmp2 = f2 (1, 2);
301
321
//│ runtime.safeCall(tmp2.get())
302
322
//│ = 1
303
323
@@ -327,7 +347,7 @@ fun f(used1, unused1) =
327
347
new Test
328
348
f(1, 2).get()
329
349
//│ JS (unsanitized):
330
- //│ let Test7, f3 , tmp4, Test$ctor3, Test$3, g$2, h$2;
350
+ //│ let Test7, f4 , tmp4, Test$ctor3, Test$3, g$2, h$2;
331
351
//│ h$2 = function h$(used3) {
332
352
//│ return used3
333
353
//│ };
@@ -364,12 +384,12 @@ f(1, 2).get()
364
384
//│ }
365
385
//│ toString() { return "Test"; }
366
386
//│ };
367
- //│ f3 = function f(used1, unused1) {
387
+ //│ f4 = function f(used1, unused1) {
368
388
//│ let unused2;
369
389
//│ unused2 = 2;
370
390
//│ return Test$3(used1)
371
391
//│ };
372
- //│ tmp4 = f3 (1, 2);
392
+ //│ tmp4 = f4 (1, 2);
373
393
//│ runtime.safeCall(tmp4.get())
374
394
//│ = 1
375
395
@@ -382,7 +402,7 @@ fun f(x) =
382
402
x
383
403
f(1)
384
404
//│ JS (unsanitized):
385
- //│ let A1, f4 , A$ctor, A$, f$capture1;
405
+ //│ let A1, f5 , A$ctor, A$, f$capture1;
386
406
//│ A$ = function A$(f$capture$0) {
387
407
//│ let tmp5;
388
408
//│ tmp5 = new A1.class();
@@ -422,14 +442,14 @@ f(1)
422
442
//│ }
423
443
//│ toString() { return "f$capture(" + runtime.render(this.x0$) + ")"; }
424
444
//│ };
425
- //│ f4 = function f(x) {
445
+ //│ f5 = function f(x) {
426
446
//│ let tmp5, tmp6, capture;
427
447
//│ capture = new f$capture1(x);
428
448
//│ tmp5 = A$(capture);
429
449
//│ tmp6 = runtime.safeCall(tmp5.f());
430
450
//│ return capture.x0$
431
451
//│ };
432
- //│ f4 (1)
452
+ //│ f5 (1)
433
453
//│ = 2
434
454
435
455
// only w should be in a capture
@@ -451,7 +471,7 @@ fun f() =
451
471
Good()
452
472
f().foo()
453
473
//│ JS (unsanitized):
454
- //│ let Bad1, Good1, f5 , tmp5, Bad$ctor, Bad$, Good$ctor, Good$, f$capture3;
474
+ //│ let Bad1, Good1, f6 , tmp5, Bad$ctor, Bad$, Good$ctor, Good$, f$capture3;
455
475
//│ Good$ = function Good$(x$1, y$2, z$3, f$capture$0) {
456
476
//│ let tmp6;
457
477
//│ tmp6 = new Good1.class();
@@ -527,7 +547,7 @@ f().foo()
527
547
//│ }
528
548
//│ toString() { return "f$capture(" + runtime.render(this.w0$) + ")"; }
529
549
//│ };
530
- //│ f5 = function f() {
550
+ //│ f6 = function f() {
531
551
//│ let x, y, z, tmp6, tmp7, capture;
532
552
//│ capture = new f$capture3(null);
533
553
//│ x = 1;
@@ -538,7 +558,7 @@ f().foo()
538
558
//│ tmp7 = runtime.safeCall(tmp6.foo());
539
559
//│ return Good$(x, y, z, capture)
540
560
//│ };
541
- //│ tmp5 = f5 ();
561
+ //│ tmp5 = f6 ();
542
562
//│ runtime.safeCall(tmp5.foo())
543
563
//│ = 10111
544
564
@@ -596,11 +616,11 @@ fun f(x) =
596
616
f(2).get()
597
617
//│ ═══[WARNING] Cannot yet lift class `Test` as it is used as a first-class class.
598
618
//│ JS (unsanitized):
599
- //│ let f8 , tmp11, h$3;
619
+ //│ let f9 , tmp11, h$3;
600
620
//│ h$3 = function h$(Test$instance, x) {
601
621
//│ return x
602
622
//│ };
603
- //│ f8 = function f(x) {
623
+ //│ f9 = function f(x) {
604
624
//│ let Test10, foo;
605
625
//│ Test10 = function Test() {
606
626
//│ return new Test.class();
@@ -615,7 +635,7 @@ f(2).get()
615
635
//│ foo = Test10;
616
636
//│ return runtime.safeCall(foo())
617
637
//│ };
618
- //│ tmp11 = f8 (2);
638
+ //│ tmp11 = f9 (2);
619
639
//│ runtime.safeCall(tmp11.get())
620
640
//│ ═══[WARNING] Cannot yet lift class `Test` as it is used as a first-class class.
621
641
//│ = 2
0 commit comments