@@ -24,11 +24,6 @@ open Code_generation
2424module Make (Target : Target_sig.S ) = struct
2525 open Target
2626
27- let func_type n =
28- { W. params = List. init ~len: (n + 1 ) ~f: (fun _ -> Value. value)
29- ; result = [ Value. value ]
30- }
31-
3227 let bind_parameters l =
3328 List. fold_left
3429 ~f: (fun l x ->
@@ -102,7 +97,7 @@ module Make (Target : Target_sig.S) = struct
10297 let param_names = args @ [ f ] in
10398 let locals, body = function_body ~context ~param_names ~body in
10499 W. Function
105- { name; exported_name = None ; typ = func_type 1 ; param_names; locals; body }
100+ { name; exported_name = None ; typ = Type. func_type 1 ; param_names; locals; body }
106101
107102 let curry_name n m = Printf. sprintf " curry_%d_%d" n m
108103
@@ -130,7 +125,7 @@ module Make (Target : Target_sig.S) = struct
130125 let param_names = [ x; f ] in
131126 let locals, body = function_body ~context ~param_names ~body in
132127 W. Function
133- { name; exported_name = None ; typ = func_type 1 ; param_names; locals; body }
128+ { name; exported_name = None ; typ = Type. func_type 1 ; param_names; locals; body }
134129 :: functions
135130
136131 let curry ~arity ~name = curry ~arity arity ~name
@@ -174,7 +169,7 @@ module Make (Target : Target_sig.S) = struct
174169 let param_names = args @ [ f ] in
175170 let locals, body = function_body ~context ~param_names ~body in
176171 W. Function
177- { name; exported_name = None ; typ = func_type 2 ; param_names; locals; body }
172+ { name; exported_name = None ; typ = Type. func_type 2 ; param_names; locals; body }
178173
179174 let cps_curry_name n m = Printf. sprintf " cps_curry_%d_%d" n m
180175
@@ -206,7 +201,7 @@ module Make (Target : Target_sig.S) = struct
206201 let param_names = [ x; cont; f ] in
207202 let locals, body = function_body ~context ~param_names ~body in
208203 W. Function
209- { name; exported_name = None ; typ = func_type 2 ; param_names; locals; body }
204+ { name; exported_name = None ; typ = Type. func_type 2 ; param_names; locals; body }
210205 :: functions
211206
212207 let cps_curry ~arity ~name = cps_curry ~arity arity ~name
@@ -243,7 +238,13 @@ module Make (Target : Target_sig.S) = struct
243238 let param_names = l @ [ f ] in
244239 let locals, body = function_body ~context ~param_names ~body in
245240 W. Function
246- { name; exported_name = None ; typ = func_type arity; param_names; locals; body }
241+ { name
242+ ; exported_name = None
243+ ; typ = Type. primitive_type (arity + 1 )
244+ ; param_names
245+ ; locals
246+ ; body
247+ }
247248
248249 let cps_apply ~context ~arity ~name =
249250 assert (arity > 2 );
@@ -271,7 +272,7 @@ module Make (Target : Target_sig.S) = struct
271272 (List. map ~f: (fun x -> `Var x) (List. tl l))
272273 in
273274 let * make_iterator =
274- register_import ~name: " caml_apply_continuation" (Fun (func_type 0 ))
275+ register_import ~name: " caml_apply_continuation" (Fun (Type. primitive_type 1 ))
275276 in
276277 let iterate = Var. fresh_n " iterate" in
277278 let * () = store iterate (return (W. Call (make_iterator, [ args ]))) in
@@ -283,7 +284,13 @@ module Make (Target : Target_sig.S) = struct
283284 let param_names = l @ [ f ] in
284285 let locals, body = function_body ~context ~param_names ~body in
285286 W. Function
286- { name; exported_name = None ; typ = func_type arity; param_names; locals; body }
287+ { name
288+ ; exported_name = None
289+ ; typ = Type. primitive_type (arity + 1 )
290+ ; param_names
291+ ; locals
292+ ; body
293+ }
287294
288295 let dummy ~context ~cps ~arity ~name =
289296 let arity = if cps then arity + 1 else arity in
@@ -311,7 +318,13 @@ module Make (Target : Target_sig.S) = struct
311318 let param_names = l @ [ f ] in
312319 let locals, body = function_body ~context ~param_names ~body in
313320 W. Function
314- { name; exported_name = None ; typ = func_type arity; param_names; locals; body }
321+ { name
322+ ; exported_name = None
323+ ; typ = Type. func_type arity
324+ ; param_names
325+ ; locals
326+ ; body
327+ }
315328
316329 let f ~context =
317330 IntMap. iter
0 commit comments