@@ -28577,7 +28577,7 @@ type cst =
28577
28577
| Arg_string_lit of string
28578
28578
28579
28579
28580
- type label =
28580
+ type label = private
28581
28581
| Label of string * cst option
28582
28582
| Empty of cst option
28583
28583
| Optional of string
@@ -28601,6 +28601,12 @@ type kind =
28601
28601
arg_label :label
28602
28602
}
28603
28603
28604
+ val empty_label : label
28605
+ val empty_lit : cst -> label
28606
+ val label : string -> cst option -> label
28607
+ val optional : string -> label
28608
+ val empty_kind : ty -> kind
28609
+
28604
28610
end = struct
28605
28611
#1 "ast_arg.ml"
28606
28612
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -28658,6 +28664,14 @@ type kind =
28658
28664
arg_label : label
28659
28665
}
28660
28666
28667
+
28668
+ let empty_label = Empty None
28669
+ let empty_lit s = Empty (Some s)
28670
+ let label s cst = Label(s,cst)
28671
+ let optional s = Optional s
28672
+
28673
+ let empty_kind arg_type = { arg_label = empty_label ; arg_type }
28674
+
28661
28675
end
28662
28676
module Ast_ffi_types : sig
28663
28677
#1 "ast_ffi_types.mli"
@@ -30144,39 +30158,35 @@ let handle_attributes
30144
30158
let arg_type, new_ty = get_arg_type ~nolabel:true false ty in
30145
30159
begin match arg_type with
30146
30160
| Extern_unit ->
30147
- { Ast_arg.arg_label = Empty None; arg_type } , (label,new_ty,attr,loc)::arg_types, result_types
30161
+ Ast_arg.empty_kind arg_type, (label,new_ty,attr,loc)::arg_types, result_types
30148
30162
| _ ->
30149
30163
Location.raise_errorf ~loc "expect label, optional, or unit here"
30150
30164
end
30151
30165
| Label name ->
30152
30166
let arg_type, new_ty = get_arg_type ~nolabel:false false ty in
30153
30167
begin match arg_type with
30154
30168
| Ignore ->
30155
- { arg_label = Empty None ; arg_type } ,
30169
+ Ast_arg.empty_kind arg_type,
30156
30170
(label,new_ty,attr,loc)::arg_types, result_types
30157
- | Arg_cst (Arg_int_lit _ as i) ->
30171
+ | Arg_cst i ->
30158
30172
let s = (Lam_methname.translate ~loc name) in
30159
- {arg_label = Label (s, Some i) ; arg_type },
30173
+ {arg_label = Ast_arg.label s (Some i);
30174
+ arg_type },
30160
30175
arg_types, (* ignored in [arg_types], reserved in [result_types] *)
30161
30176
((name , [], new_ty) :: result_types)
30162
- | Arg_cst (Arg_string_lit _ as i) ->
30163
- let s = (Lam_methname.translate ~loc name) in
30164
- {arg_label = Label (s, Some i) ; arg_type },
30165
- arg_types,
30166
- ((name , [], new_ty) :: result_types)
30167
30177
| Nothing | Array ->
30168
30178
let s = (Lam_methname.translate ~loc name) in
30169
- {arg_label = Label (s, None) ; arg_type },
30179
+ {arg_label = Ast_arg.label s None ; arg_type },
30170
30180
(label,new_ty,attr,loc)::arg_types,
30171
30181
((name , [], new_ty) :: result_types)
30172
30182
| Int _ ->
30173
30183
let s = Lam_methname.translate ~loc name in
30174
- {arg_label = Label (s, None) ; arg_type},
30184
+ {arg_label = Ast_arg.label s None; arg_type},
30175
30185
(label,new_ty,attr,loc)::arg_types,
30176
30186
((name, [], Ast_literal.type_int ~loc ()) :: result_types)
30177
30187
| NullString _ ->
30178
30188
let s = Lam_methname.translate ~loc name in
30179
- {arg_label = Label (s, None) ; arg_type},
30189
+ {arg_label = Ast_arg.label s None; arg_type},
30180
30190
(label,new_ty,attr,loc)::arg_types,
30181
30191
((name, [], Ast_literal.type_string ~loc ()) :: result_types)
30182
30192
| Fn_uncurry_arity _ ->
@@ -30193,22 +30203,22 @@ let handle_attributes
30193
30203
let new_ty = Ast_core_type.lift_option_type new_ty_extract in
30194
30204
begin match arg_type with
30195
30205
| Ignore ->
30196
- {arg_label = Empty None ; arg_type} ,
30206
+ Ast_arg.empty_kind arg_type,
30197
30207
(label,new_ty,attr,loc)::arg_types, result_types
30198
30208
30199
30209
| Nothing | Array ->
30200
30210
let s = (Lam_methname.translate ~loc name) in
30201
- {arg_label = Optional s; arg_type},
30211
+ {arg_label = Ast_arg.optional s; arg_type},
30202
30212
(label,new_ty,attr,loc)::arg_types,
30203
30213
( (name, [], Ast_comb.to_undefined_type loc new_ty_extract) :: result_types)
30204
30214
| Int _ ->
30205
30215
let s = Lam_methname.translate ~loc name in
30206
- {arg_label = Optional s ; arg_type },
30216
+ {arg_label = Ast_arg.optional s ; arg_type },
30207
30217
(label,new_ty,attr,loc)::arg_types,
30208
30218
((name, [], Ast_comb.to_undefined_type loc @@ Ast_literal.type_int ~loc ()) :: result_types)
30209
30219
| NullString _ ->
30210
30220
let s = Lam_methname.translate ~loc name in
30211
- {arg_label = Optional s ; arg_type },
30221
+ {arg_label = Ast_arg.optional s ; arg_type },
30212
30222
(label,new_ty,attr,loc)::arg_types,
30213
30223
((name, [], Ast_comb.to_undefined_type loc @@ Ast_literal.type_string ~loc ()) :: result_types)
30214
30224
| Arg_cst _
@@ -30270,25 +30280,21 @@ let handle_attributes
30270
30280
~loc
30271
30281
"[@@bs.string] does not work with optional when it has arities in label %s" label
30272
30282
| _ ->
30273
- Ast_arg.Optional s, arg_type,
30283
+ Ast_arg.optional s, arg_type,
30274
30284
((label, Ast_core_type.lift_option_type new_ty , attr,loc) :: arg_types) end
30275
30285
| Label s ->
30276
30286
begin match get_arg_type ~nolabel:false false ty with
30277
- | (Arg_cst (Arg_int_lit _ as i) as arg_type), new_ty ->
30278
- Label(s, Some i), arg_type, arg_types
30279
- | (Arg_cst (Arg_string_lit _ as i) as arg_type), new_ty ->
30280
- Label(s, Some i), arg_type, arg_types
30287
+ | (Arg_cst ( i) as arg_type), new_ty ->
30288
+ Ast_arg.label s (Some i), arg_type, arg_types
30281
30289
| arg_type, new_ty ->
30282
- Label (s, None) , arg_type, (label, new_ty,attr,loc) :: arg_types
30290
+ Ast_arg.label s None, arg_type, (label, new_ty,attr,loc) :: arg_types
30283
30291
end
30284
30292
| Empty ->
30285
30293
begin match get_arg_type ~nolabel:true false ty with
30286
- | (Arg_cst (Arg_int_lit _ as i) as arg_type), new_ty ->
30287
- Empty (Some i) , arg_type, arg_types
30288
- | (Arg_cst (Arg_string_lit _ as i) as arg_type), new_ty ->
30289
- Empty(Some i), arg_type, arg_types
30294
+ | (Arg_cst ( i) as arg_type), new_ty ->
30295
+ Ast_arg.empty_lit i , arg_type, arg_types
30290
30296
| arg_type, new_ty ->
30291
- Empty None , arg_type, (label, new_ty,attr,loc) :: arg_types
30297
+ Ast_arg.empty_label , arg_type, (label, new_ty,attr,loc) :: arg_types
30292
30298
end
30293
30299
in
30294
30300
(if i = 0 && splice then
@@ -30308,9 +30314,9 @@ let handle_attributes
30308
30314
| Arg_cst _ ->
30309
30315
Location.raise_errorf ~loc:obj.ptyp_loc "[@bs.as] is not supported in bs.send type "
30310
30316
| _ ->
30311
- [{ arg_label = Empty None;
30312
- arg_type (* more error checking *)
30313
- }] ,
30317
+ (* more error checking *)
30318
+ [Ast_arg.empty_kind arg_type]
30319
+ ,
30314
30320
["", new_ty, [], obj.ptyp_loc]
30315
30321
,0
30316
30322
end
@@ -30648,7 +30654,7 @@ let pval_prim_of_labels labels =
30648
30654
List.fold_right
30649
30655
(fun {Asttypes.loc ; txt } arg_kinds
30650
30656
->
30651
- let arg_label = Ast_arg.Label (Lam_methname.translate ~loc txt, None) in
30657
+ let arg_label = Ast_arg.label (Lam_methname.translate ~loc txt) None in
30652
30658
{Ast_arg.arg_type = Nothing ;
30653
30659
arg_label } :: arg_kinds
30654
30660
)
0 commit comments