@@ -202,8 +202,10 @@ module Type = struct
202202 ]
203203 })
204204
205- let func_type n =
206- { W. params = List. init ~len: (n + 1 ) ~f: (fun _ -> value); result = [ value ] }
205+ let primitive_type n =
206+ { W. params = List. init ~len: n ~f: (fun _ -> value); result = [ value ] }
207+
208+ let func_type n = primitive_type (n + 1 )
207209
208210 let function_type ~cps n =
209211 let n = if cps then n + 1 else n in
@@ -423,8 +425,6 @@ module Type = struct
423425end
424426
425427module Value = struct
426- let value = Type. value
427-
428428 let block_type =
429429 let * t = Type. block_type in
430430 return (W. Ref { nullable = false ; typ = Type t })
@@ -743,13 +743,13 @@ module Memory = struct
743743 let a = Code.Var. fresh_n " a" in
744744 let i = Code.Var. fresh_n " i" in
745745 block_expr
746- { params = [] ; result = [ Value . value ] }
746+ { params = [] ; result = [ Type . value ] }
747747 (let * () = store a e in
748748 let * () = store ~typ: I32 i (Value. int_val e') in
749749 let * () =
750750 drop
751751 (block_expr
752- { params = [] ; result = [ Value . value ] }
752+ { params = [] ; result = [ Type . value ] }
753753 (let * block = Type. block_type in
754754 let * a = load a in
755755 let * e =
@@ -779,7 +779,7 @@ module Memory = struct
779779 (let * () =
780780 drop
781781 (block_expr
782- { params = [] ; result = [ Value . value ] }
782+ { params = [] ; result = [ Type . value ] }
783783 (let * block = Type. block_type in
784784 let * a = load a in
785785 let * () =
@@ -840,7 +840,7 @@ module Memory = struct
840840 let * () =
841841 drop
842842 (block_expr
843- { params = [] ; result = [ Value . value ] }
843+ { params = [] ; result = [ Type . value ] }
844844 (let * e =
845845 if_match
846846 ~typ: (Some (W. Ref { nullable = false ; typ = Type fun_ty }))
@@ -1406,7 +1406,7 @@ let internal_primitives =
14061406 let arity = List. length args in
14071407 (* [Type.func_type] counts one additional argument for the closure environment (absent
14081408 here) *)
1409- let * f = register_import ~name (Fun (Type. func_type ( arity - 1 ) )) in
1409+ let * f = register_import ~name (Fun (Type. primitive_type arity)) in
14101410 let args = List. map ~f: transl_prim_arg args in
14111411 let * args = expression_list Fun. id args in
14121412 return (W. Call (f, args))
@@ -1675,19 +1675,19 @@ let externref = W.Ref { nullable = true; typ = Extern }
16751675
16761676let handle_exceptions ~result_typ ~fall_through ~context body x exn_handler =
16771677 let * js_tag = register_import ~name: " javascript_exception" (Tag externref) in
1678- let * ocaml_tag = register_import ~name: " ocaml_exception" (Tag Value . value) in
1678+ let * ocaml_tag = register_import ~name: " ocaml_exception" (Tag Type . value) in
16791679 let * f =
16801680 register_import
16811681 ~name: " caml_wrap_exception"
1682- (Fun { params = [ externref ]; result = [ Value . value ] })
1682+ (Fun { params = [ externref ]; result = [ Type . value ] })
16831683 in
16841684 block
16851685 { params = [] ; result = result_typ }
16861686 (let * () =
16871687 store
16881688 x
16891689 (block_expr
1690- { params = [] ; result = [ Value . value ] }
1690+ { params = [] ; result = [ Type . value ] }
16911691 (let * exn =
16921692 block_expr
16931693 { params = [] ; result = [ externref ] }
@@ -1698,7 +1698,7 @@ let handle_exceptions ~result_typ ~fall_through ~context body x exn_handler =
16981698 ~result_typ: [ externref ]
16991699 ~fall_through: `Skip
17001700 ~context: (`Skip :: `Skip :: `Catch :: context))
1701- [ ocaml_tag, 1 , Value . value; js_tag, 0 , externref ]
1701+ [ ocaml_tag, 1 , Type . value; js_tag, 0 , externref ]
17021702 in
17031703 instr (W. Push e))
17041704 in
0 commit comments