@@ -123,53 +123,91 @@ let%expect_test "direct calls with --enable effects" =
123123 M1. f 1 ; M2. f 2
124124| }
125125 in
126- print_fun_decl code (Some " test1" );
127- print_fun_decl code (Some " test2" );
128- print_fun_decl code (Some " test3" );
129- print_fun_decl code (Some " test4" );
126+ print_fun_decl code (Some " test1$0" );
127+ print_fun_decl code (Some " test1$1" );
128+ print_var_decl code " test1" ;
129+ print_fun_decl code (Some " test2$0" );
130+ print_fun_decl code (Some " test2$1" );
131+ print_var_decl code " test2" ;
132+ print_fun_decl code (Some " test3$0" );
133+ print_fun_decl code (Some " test3$1" );
134+ print_var_decl code " test3" ;
135+ print_fun_decl code (Some " test4$0" );
136+ print_fun_decl code (Some " test4$1" );
137+ print_var_decl code " test4" ;
130138 [% expect
131139 {|
132- function test1(param, cont){
133- function f(g, x){return g(x);}
134- var _k_ = 7 ;
135- f(function(x){return x + 1 | 0 ;}, _k_);
136- var _l_ = 4. ;
137- f(function(x){return x * 2. ;}, _l_);
140+ function test1$ 0 (param){
141+ function f(g, x){return caml_call1(g, x);}
142+ var _H_ = 7 ;
143+ f(function(x){return x + 1 | 0 ;}, _H_);
144+ var _I_ = 4. ;
145+ f(function(x){return x * 2. ;}, _I_);
146+ return 0 ;
147+ }
148+ // end
149+ function test1$ 1 (param, cont){
150+ function f(g, x){return caml_call1(g, x);}
151+ var _F_ = 7 ;
152+ f(function(x){return x + 1 | 0 ;}, _F_);
153+ var _G_ = 4. ;
154+ f(function(x){return x * 2. ;}, _G_);
138155 return cont(0 );
139156 }
140157 // end
141- function test2(param, cont){
142- function f(g, x, cont){return caml_cps_exact_call2(g, x, cont);}
143- var _f_ = 7 ;
144- function _g_(x, cont){return cont(x + 1 | 0 );}
158+ var test1 = caml_cps_closure(test1$ 0 , test1$ 1 );
159+ // end
160+ function test2$ 0 (param){
161+ var f = f$ 0 () ;
162+ f(_h_() , 7 );
163+ f(_j_() , cst_a);
164+ return 0 ;
165+ }
166+ // end
167+ function test2$ 1 (param, cont){
168+ var f = f$ 0 () , _y_ = 7 , _z_ = _h_() ;
145169 return caml_cps_exact_call3
146170 (f,
147- _g_,
148- _f_,
149- function(_h_){
150- function _i_(x, cont){
151- return caml_cps_call3(Stdlib [28 ], x, cst_a$ 0 , cont);
152- }
171+ _z_,
172+ _y_,
173+ function(_A_){
174+ var _B_ = _j_() ;
153175 return caml_cps_exact_call3
154- (f, _i_ , cst_a, function(_j_ ){return cont(0 );});
176+ (f, _B_ , cst_a, function(_C_ ){return cont(0 );});
155177 });
156178 }
157179 // end
158- function test3(x, cont){
180+ var test2 = caml_cps_closure(test2$ 0 , test2$ 1 );
181+ // end
182+ function test3$ 0 (x){
159183 function F (symbol){function f(x){return x + 1 | 0 ;} return [0 , f];}
160- var M1 = F ([0 ]), M2 = F ([0 ]), _e_ = M2 [1 ].call(null , 2 );
161- return cont( [0 , M1 [1 ].call(null , 1 ), _e_]) ;
184+ var M1 = F ([0 ]), M2 = F ([0 ]), _x_ = caml_call1( M2 [1 ], 2 );
185+ return [0 , caml_call1( M1 [1 ], 1 ), _x_] ;
162186 }
163187 // end
164- function test4(x, cont){
165- function F (symbol){
166- function f(x, cont){return caml_cps_call3(Stdlib_Printf [2 ], _a_, x, cont);}
167- return [0 , f];
168- }
169- var M1 = F ([0 ]), M2 = F ([0 ]), _b_ = 1 , _c_ = M1 [1 ];
188+ function test3$ 1 (x, cont){
189+ function F (symbol){function f(x){return x + 1 | 0 ;} return [0 , f];}
190+ var M1 = F ([0 ]), M2 = F ([0 ]), _w_ = M2 [1 ].call(null, 2 );
191+ return cont([0 , M1 [1 ].call(null, 1 ), _w_]);
192+ }
193+ // end
194+ var test3 = caml_cps_closure(test3$ 0 , test3$ 1 );
195+ // end
196+ function test4$ 0 (x){
197+ function F (symbol){var f$ 0 = f() ; return [0 , f$ 0 ];}
198+ var M1 = F ([0 ]), M2 = F ([0 ]);
199+ caml_call1(M1 [1 ], 1 );
200+ return caml_call1(M2 [1 ], 2 );
201+ }
202+ // end
203+ function test4$ 1 (x, cont){
204+ function F (symbol){var f$ 0 = f() ; return [0 , f$ 0 ];}
205+ var M1 = F ([0 ]), M2 = F ([0 ]), _t_ = 1 , _u_ = M1 [1 ];
170206 return caml_cps_exact_call2
171- (_c_ ,
172- _b_ ,
173- function(_d_ ){return caml_cps_exact_call2(M2 [1 ], 2 , cont);});
207+ (_u_ ,
208+ _t_ ,
209+ function(_v_ ){return caml_cps_exact_call2(M2 [1 ], 2 , cont);});
174210 }
211+ // end
212+ var test4 = caml_cps_closure(test4$ 0 , test4$ 1 );
175213 // end | }]
0 commit comments