@@ -194,19 +194,18 @@ let parse_declaration valdecl ~native_repr_args ~native_repr_res =
194
194
195
195
open Outcometree
196
196
197
+ let add_attribute_list ty attrs =
198
+ List. fold_left (fun ty attr -> Otyp_attribute (ty, attr)) ty attrs
199
+
197
200
let rec add_native_repr_attributes ty attrs =
198
201
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 ->
200
203
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
206
205
Otyp_arrow (label, am, a, rm, r)
207
- | _ , [Some attr ] -> Otyp_attribute (ty, attr)
206
+ | _ , [attr_l ] -> add_attribute_list ty attr_l
208
207
| _ ->
209
- assert (List. for_all (fun x -> x = None ) attrs);
208
+ assert (List. for_all (fun x -> x = [] ) attrs);
210
209
ty
211
210
212
211
let oattr_unboxed = { oattr_name = " unboxed" }
@@ -216,6 +215,7 @@ let oattr_builtin = { oattr_name = "builtin" }
216
215
let oattr_no_effects = { oattr_name = " no_effects" }
217
216
let oattr_only_generative_effects = { oattr_name = " only_generative_effects" }
218
217
let oattr_no_coeffects = { oattr_name = " no_coeffects" }
218
+ let oattr_local_opt = { oattr_name = " local_opt" }
219
219
220
220
let print p osig_val_decl =
221
221
let prims =
@@ -248,15 +248,20 @@ let print p osig_val_decl =
248
248
else
249
249
attrs
250
250
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])
256
261
in
257
262
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]
260
265
in
261
266
{ osig_val_decl with
262
267
oval_prims = prims;
0 commit comments