@@ -121,103 +121,72 @@ let%expect_test "direct calls with --effects=double-translation" =
121
121
: runtime.caml_call_gen(f, [a0, a1]))
122
122
: runtime.caml_trampoline_return(f, [a0, a1, a2], 0 );
123
123
}
124
- function caml_exact_trampoline_cps_call$ 0 (f, a0, a1, a2){
125
- return runtime.caml_stack_check_depth()
126
- ? f.cps ? f.cps.call(null, a0, a1, a2) : a2(f(a0, a1))
127
- : runtime.caml_trampoline_return(f, [a0, a1, a2], 0 );
128
- }
129
124
var
130
- dummy = 0 ,
131
125
global_data = runtime.caml_get_global_data() ,
132
- _z_ = [0 , [4 , 0 , 0 , 0 , 0 ], caml_string_of_jsbytes(" %d" )],
133
- cst_a$ 0 = caml_string_of_jsbytes(" a" ),
126
+ _k_ = [0 , [4 , 0 , 0 , 0 , 0 ], caml_string_of_jsbytes(" %d" )],
134
127
cst_a = caml_string_of_jsbytes(" a" ),
128
+ x = caml_string_of_jsbytes(" a" ),
135
129
Stdlib = global_data.Stdlib ,
136
130
Stdlib_Printf = global_data.Stdlib__Printf ;
137
131
function test1(param){
138
- function f(g, x){
139
- try {caml_call1(g, dummy); return;}
140
- catch(e$ 0 ){
141
- var e = caml_wrap_exception(e$ 0 );
142
- throw caml_maybe_attach_backtrace(e, 0 );
143
- }
132
+ try {}
133
+ catch(e$ 0 ){
134
+ var e = caml_wrap_exception(e$ 0 );
135
+ throw caml_maybe_attach_backtrace(e, 0 );
136
+ }
137
+ try {}
138
+ catch(e){
139
+ var e$ 0 = caml_wrap_exception(e);
140
+ throw caml_maybe_attach_backtrace(e$ 0 , 0 );
144
141
}
145
- f(function(x){});
146
- f(function(x){});
147
142
return 0 ;
148
143
}
149
- function f$ 0 () {
150
- function f$ 0 (g, x){
151
- try {caml_call1(g, x); return;}
152
- catch(e$ 0 ){
153
- var e = caml_wrap_exception(e$ 0 );
154
- throw caml_maybe_attach_backtrace(e, 0 );
155
- }
144
+ function test2$ 0 (param){
145
+ try {}
146
+ catch(e$ 0 ){
147
+ var e = caml_wrap_exception(e$ 0 );
148
+ throw caml_maybe_attach_backtrace(e, 0 );
156
149
}
157
- function f$ 1 (g, x, cont){
158
- runtime.caml_push_trap
159
- (function(e$ 0 ){
160
- var raise = caml_pop_trap() , e = caml_maybe_attach_backtrace(e$ 0 , 0 );
161
- return raise(e);
162
- });
163
- return caml_exact_trampoline_cps_call
164
- (g, x, function(_K_){caml_pop_trap() ; return cont() ;});
150
+ try {caml_call2(Stdlib [28 ], x, cst_a);}
151
+ catch(e){
152
+ var e$ 0 = caml_wrap_exception(e);
153
+ throw caml_maybe_attach_backtrace(e$ 0 , 0 );
165
154
}
166
- var f = caml_cps_closure(f$ 0 , f$ 1 );
167
- return f;
168
- }
169
- function _h_() {return function(x){};}
170
- function _j_() {
171
- return caml_cps_closure
172
- (function(x){return caml_call2(Stdlib [28 ], x, cst_a$ 0 );},
173
- function(x, cont){
174
- return caml_trampoline_cps_call3(Stdlib [28 ], x, cst_a$ 0 , cont);
175
- });
176
- }
177
- function test2$ 0 (param){
178
- var f = f$ 0 () ;
179
- f(_h_() , 7 );
180
- f(_j_() , cst_a);
181
155
return 0 ;
182
156
}
183
157
function test2$ 1 (param, cont){
184
- var f = f$ 0 () ;
185
- return caml_exact_trampoline_cps_call$ 0
186
- (f,
187
- _h_() ,
188
- 7 ,
189
- function(_I_){
190
- return caml_exact_trampoline_cps_call$ 0
191
- (f, _j_() , cst_a, function(_J_){return cont(0 );});
192
- });
193
- }
194
- var test2 = caml_cps_closure(test2$ 0 , test2$ 1 );
195
- function test3(x){
196
- function F (symbol){function f(x){return x + 1 | 0 ;} return [0 , f];}
197
- var M1 = F () , M2 = F () , _H_ = caml_call1(M2 [1 ], 2 );
198
- return [0 , caml_call1(M1 [1 ], 1 ), _H_];
199
- }
200
- function f() {
201
- function f$ 0 (x){return caml_call2(Stdlib_Printf [2 ], _z_, x);}
202
- function f$ 1 (x, cont){
203
- return caml_trampoline_cps_call3(Stdlib_Printf [2 ], _z_, x, cont);
158
+ try {}
159
+ catch(e$ 1 ){
160
+ var
161
+ e$ 0 = caml_wrap_exception(e$ 1 ),
162
+ raise = caml_pop_trap() ,
163
+ e = caml_maybe_attach_backtrace(e$ 0 , 0 );
164
+ return raise(e);
204
165
}
205
- var f = caml_cps_closure(f$ 0 , f$ 1 );
206
- return f;
166
+ runtime.caml_push_trap
167
+ (function(e$ 0 ){
168
+ var raise = caml_pop_trap() , e = caml_maybe_attach_backtrace(e$ 0 , 0 );
169
+ return raise(e);
170
+ });
171
+ return caml_trampoline_cps_call3
172
+ (Stdlib [28 ],
173
+ x,
174
+ cst_a,
175
+ function(_s_){caml_pop_trap() ; return cont(0 );});
207
176
}
208
- function F () {function F (symbol){var f$ 0 = f() ; return [0 , f$ 0 ];} return F ;}
177
+ var test2 = caml_cps_closure(test2$ 0 , test2$ 1 );
178
+ function test3(x){return [0 , 2 , 3 ];}
209
179
function test4$ 0 (x){
210
- var F $ 0 = F () , M1 = F $ 0 () , M2 = F $ 0 () ;
211
- caml_call1(M1 [1 ], 1 );
212
- return caml_call1(M2 [1 ], 2 );
180
+ caml_call2(Stdlib_Printf [2 ], _k_, 1 );
181
+ return caml_call2(Stdlib_Printf [2 ], _k_, 2 );
213
182
}
214
183
function test4$ 1 (x, cont){
215
- var F $ 0 = F () , M1 = F $ 0 () , M2 = F $ 0 () ;
216
- return caml_exact_trampoline_cps_call
217
- ( M1 [ 1 ] ,
184
+ return caml_trampoline_cps_call3
185
+ ( Stdlib_Printf [ 2 ],
186
+ _k_ ,
218
187
1 ,
219
- function(_G_ ){
220
- return caml_exact_trampoline_cps_call( M2 [ 1 ] , 2 , cont);
188
+ function(_r_ ){
189
+ return caml_trampoline_cps_call3( Stdlib_Printf [ 2 ], _k_ , 2 , cont);
221
190
});
222
191
}
223
192
var test4 = caml_cps_closure(test4$ 0 , test4$ 1 );
@@ -233,18 +202,18 @@ let%expect_test "direct calls with --effects=double-translation" =
233
202
tuple = recfuncs(x),
234
203
f = tuple[2 ],
235
204
h = tuple[1 ],
236
- _E_ = h(100 ),
237
- _F_ = f(12 ) + _E_ | 0 ;
238
- return caml_call1(Stdlib [44 ], _F_ );
205
+ _p_ = h(100 ),
206
+ _q_ = f(12 ) + _p_ | 0 ;
207
+ return caml_call1(Stdlib [44 ], _q_ );
239
208
}
240
209
function g$ 1 (x, cont){
241
210
var
242
211
tuple = recfuncs(x),
243
212
f = tuple[2 ],
244
213
h = tuple[1 ],
245
- _C_ = h(100 ),
246
- _D_ = f(12 ) + _C_ | 0 ;
247
- return caml_trampoline_cps_call2(Stdlib [44 ], _D_ , cont);
214
+ _n_ = h(100 ),
215
+ _o_ = f(12 ) + _n_ | 0 ;
216
+ return caml_trampoline_cps_call2(Stdlib [44 ], _o_ , cont);
248
217
}
249
218
var g = caml_cps_closure(g$ 0 , g$ 1 );
250
219
return g;
@@ -255,9 +224,9 @@ let%expect_test "direct calls with --effects=double-translation" =
255
224
return caml_exact_trampoline_cps_call
256
225
(g$ 0 ,
257
226
42 ,
258
- function(_A_ ){
227
+ function(_l_ ){
259
228
return caml_exact_trampoline_cps_call
260
- (g$ 0 , - 5 , function(_B_ ){return cont(0 );});
229
+ (g$ 0 , - 5 , function(_m_ ){return cont(0 );});
261
230
});
262
231
}
263
232
var
0 commit comments