Skip to content

Commit e86f3d0

Browse files
Nicer API
1 parent 3948d7b commit e86f3d0

4 files changed

Lines changed: 6 additions & 14 deletions

File tree

src/loader/cmi.ml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -757,11 +757,7 @@ let read_value_description ({ident_env ; warnings_tag} as env) parent id vd =
757757
External primitives
758758
| _ -> assert false
759759
in
760-
let zero_alloc = Doc_attr.known_attribute vd in
761-
let ext_attr = match zero_alloc with
762-
| Some za -> [za]
763-
| None -> []
764-
in
760+
let ext_attr = Doc_attr.attrs_of_value_description vd in
765761
Value { Value.id; source_loc; doc; type_; value; ext_attr }
766762

767763
#if defined OXCAML

src/loader/cmti.ml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,7 @@ let read_value_description env parent vd =
233233
| [] -> Value.Abstract
234234
| primitives -> External primitives
235235
in
236-
let zero_alloc = Doc_attr.known_attribute vd.val_val in
237-
let ext_attr = match zero_alloc with
238-
| Some za -> [za]
239-
| None -> []
240-
in
236+
let ext_attr = Doc_attr.attrs_of_value_description vd.val_val in
241237
Value { Value.id; source_loc; doc; type_; value; ext_attr }
242238

243239
let read_type_parameter (ctyp, var_and_injectivity) =

src/loader/doc_attr.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ let attribute_unpack = function
7474
| { Location.txt = name; loc }, attr_payload -> (name, attr_payload, loc)
7575
#endif
7676

77-
let known_attribute (vd : Types.value_description) =
77+
let attrs_of_value_description (vd : Types.value_description) =
7878
let zero_alloc = match vd.val_zero_alloc |> Zero_alloc.get with
7979
| Default_zero_alloc -> None
8080
| Ignore_assert_all -> None
@@ -84,8 +84,8 @@ let known_attribute (vd : Types.value_description) =
8484
Some ( Lang.Value.Zero_alloc.{ opt; strict; arity; custom_error_msg })
8585
in
8686
match zero_alloc with
87-
| Some za -> Some (Lang.Value.Zero_alloc za)
88-
| None -> None
87+
| Some za -> [Lang.Value.Zero_alloc za]
88+
| None -> []
8989

9090
type payload = string * Location.t
9191

src/loader/doc_attr.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,4 @@ type parsed_attribute =
9393
]
9494

9595
val parse_attribute : Parsetree.attribute -> parsed_attribute option
96-
val known_attribute : Types.value_description -> Lang.Value.attr option
96+
val attrs_of_value_description : Types.value_description -> Lang.Value.attr list

0 commit comments

Comments
 (0)