@@ -194,19 +194,18 @@ let parse_declaration valdecl ~native_repr_args ~native_repr_res =
194194
195195open Outcometree
196196
197+ let add_attribute_list ty attrs =
198+ List. fold_left (fun ty attr -> Otyp_attribute (ty, attr)) ty attrs
199+
197200let rec add_native_repr_attributes ty attrs =
198201 match ty, attrs with
199- | Otyp_arrow (label , am , a , rm , r ), attr_opt :: rest ->
202+ | Otyp_arrow (label , am , a , rm , r ), attr_l :: rest ->
200203 let r = add_native_repr_attributes r rest in
201- let a =
202- match attr_opt with
203- | None -> a
204- | Some attr -> Otyp_attribute (a, attr)
205- in
204+ let a = add_attribute_list a attr_l in
206205 Otyp_arrow (label, am, a, rm, r)
207- | _ , [Some attr ] -> Otyp_attribute (ty, attr)
206+ | _ , [attr_l ] -> add_attribute_list ty attr_l
208207 | _ ->
209- assert (List. for_all (fun x -> x = None ) attrs);
208+ assert (List. for_all (fun x -> x = [] ) attrs);
210209 ty
211210
212211let oattr_unboxed = { oattr_name = " unboxed" }
@@ -216,6 +215,7 @@ let oattr_builtin = { oattr_name = "builtin" }
216215let oattr_no_effects = { oattr_name = " no_effects" }
217216let oattr_only_generative_effects = { oattr_name = " only_generative_effects" }
218217let oattr_no_coeffects = { oattr_name = " no_coeffects" }
218+ let oattr_local_opt = { oattr_name = " local_opt" }
219219
220220let print p osig_val_decl =
221221 let prims =
@@ -248,15 +248,20 @@ let print p osig_val_decl =
248248 else
249249 attrs
250250 in
251- let attr_of_native_repr = function
252- | _ , Same_as_ocaml_repr -> None
253- | _, Unboxed_float
254- | _ , Unboxed_integer _ -> if all_unboxed then None else Some oattr_unboxed
255- | _ , Untagged_int -> if all_untagged then None else Some oattr_untagged
251+ let attrs_of_mode_and_repr (m , repr ) =
252+ (match m with
253+ | Prim_local | Prim_global -> []
254+ | Prim_poly -> [oattr_local_opt])
255+ @
256+ (match repr with
257+ | Same_as_ocaml_repr -> []
258+ | Unboxed_float
259+ | Unboxed_integer _ -> if all_unboxed then [] else [oattr_unboxed]
260+ | Untagged_int -> if all_untagged then [] else [oattr_untagged])
256261 in
257262 let type_attrs =
258- List. map attr_of_native_repr p.prim_native_repr_args @
259- [attr_of_native_repr p.prim_native_repr_res]
263+ List. map attrs_of_mode_and_repr p.prim_native_repr_args @
264+ [attrs_of_mode_and_repr p.prim_native_repr_res]
260265 in
261266 { osig_val_decl with
262267 oval_prims = prims;
0 commit comments