Skip to content

Commit 05b22a0

Browse files
committed
clean up and continue
1 parent f86fe1d commit 05b22a0

7 files changed

+154
-130
lines changed

jscomp/bin/bsdep.ml

+38-32
Original file line numberDiff line numberDiff line change
@@ -28577,7 +28577,7 @@ type cst =
2857728577
| Arg_string_lit of string
2857828578

2857928579

28580-
type label =
28580+
type label = private
2858128581
| Label of string * cst option
2858228582
| Empty of cst option
2858328583
| Optional of string
@@ -28601,6 +28601,12 @@ type kind =
2860128601
arg_label :label
2860228602
}
2860328603

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+
2860428610
end = struct
2860528611
#1 "ast_arg.ml"
2860628612
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -28658,6 +28664,14 @@ type kind =
2865828664
arg_label : label
2865928665
}
2866028666

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+
2866128675
end
2866228676
module Ast_ffi_types : sig
2866328677
#1 "ast_ffi_types.mli"
@@ -30144,39 +30158,35 @@ let handle_attributes
3014430158
let arg_type, new_ty = get_arg_type ~nolabel:true false ty in
3014530159
begin match arg_type with
3014630160
| 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
3014830162
| _ ->
3014930163
Location.raise_errorf ~loc "expect label, optional, or unit here"
3015030164
end
3015130165
| Label name ->
3015230166
let arg_type, new_ty = get_arg_type ~nolabel:false false ty in
3015330167
begin match arg_type with
3015430168
| Ignore ->
30155-
{ arg_label = Empty None ; arg_type },
30169+
Ast_arg.empty_kind arg_type,
3015630170
(label,new_ty,attr,loc)::arg_types, result_types
30157-
| Arg_cst (Arg_int_lit _ as i) ->
30171+
| Arg_cst i ->
3015830172
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 },
3016030175
arg_types, (* ignored in [arg_types], reserved in [result_types] *)
3016130176
((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)
3016730177
| Nothing | Array ->
3016830178
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 },
3017030180
(label,new_ty,attr,loc)::arg_types,
3017130181
((name , [], new_ty) :: result_types)
3017230182
| Int _ ->
3017330183
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},
3017530185
(label,new_ty,attr,loc)::arg_types,
3017630186
((name, [], Ast_literal.type_int ~loc ()) :: result_types)
3017730187
| NullString _ ->
3017830188
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},
3018030190
(label,new_ty,attr,loc)::arg_types,
3018130191
((name, [], Ast_literal.type_string ~loc ()) :: result_types)
3018230192
| Fn_uncurry_arity _ ->
@@ -30193,22 +30203,22 @@ let handle_attributes
3019330203
let new_ty = Ast_core_type.lift_option_type new_ty_extract in
3019430204
begin match arg_type with
3019530205
| Ignore ->
30196-
{arg_label = Empty None ; arg_type},
30206+
Ast_arg.empty_kind arg_type,
3019730207
(label,new_ty,attr,loc)::arg_types, result_types
3019830208

3019930209
| Nothing | Array ->
3020030210
let s = (Lam_methname.translate ~loc name) in
30201-
{arg_label = Optional s; arg_type},
30211+
{arg_label = Ast_arg.optional s; arg_type},
3020230212
(label,new_ty,attr,loc)::arg_types,
3020330213
( (name, [], Ast_comb.to_undefined_type loc new_ty_extract) :: result_types)
3020430214
| Int _ ->
3020530215
let s = Lam_methname.translate ~loc name in
30206-
{arg_label = Optional s ; arg_type },
30216+
{arg_label = Ast_arg.optional s ; arg_type },
3020730217
(label,new_ty,attr,loc)::arg_types,
3020830218
((name, [], Ast_comb.to_undefined_type loc @@ Ast_literal.type_int ~loc ()) :: result_types)
3020930219
| NullString _ ->
3021030220
let s = Lam_methname.translate ~loc name in
30211-
{arg_label = Optional s ; arg_type },
30221+
{arg_label = Ast_arg.optional s ; arg_type },
3021230222
(label,new_ty,attr,loc)::arg_types,
3021330223
((name, [], Ast_comb.to_undefined_type loc @@ Ast_literal.type_string ~loc ()) :: result_types)
3021430224
| Arg_cst _
@@ -30270,25 +30280,21 @@ let handle_attributes
3027030280
~loc
3027130281
"[@@bs.string] does not work with optional when it has arities in label %s" label
3027230282
| _ ->
30273-
Ast_arg.Optional s, arg_type,
30283+
Ast_arg.optional s, arg_type,
3027430284
((label, Ast_core_type.lift_option_type new_ty , attr,loc) :: arg_types) end
3027530285
| Label s ->
3027630286
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
3028130289
| 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
3028330291
end
3028430292
| Empty ->
3028530293
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
3029030296
| 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
3029230298
end
3029330299
in
3029430300
(if i = 0 && splice then
@@ -30308,9 +30314,9 @@ let handle_attributes
3030830314
| Arg_cst _ ->
3030930315
Location.raise_errorf ~loc:obj.ptyp_loc "[@bs.as] is not supported in bs.send type "
3031030316
| _ ->
30311-
[{ arg_label = Empty None;
30312-
arg_type (* more error checking *)
30313-
}],
30317+
(* more error checking *)
30318+
[Ast_arg.empty_kind arg_type]
30319+
,
3031430320
["", new_ty, [], obj.ptyp_loc]
3031530321
,0
3031630322
end
@@ -30648,7 +30654,7 @@ let pval_prim_of_labels labels =
3064830654
List.fold_right
3064930655
(fun {Asttypes.loc ; txt } arg_kinds
3065030656
->
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
3065230658
{Ast_arg.arg_type = Nothing ;
3065330659
arg_label } :: arg_kinds
3065430660
)

jscomp/bin/bsppx.ml

+38-32
Original file line numberDiff line numberDiff line change
@@ -10592,7 +10592,7 @@ type cst =
1059210592
| Arg_string_lit of string
1059310593

1059410594

10595-
type label =
10595+
type label = private
1059610596
| Label of string * cst option
1059710597
| Empty of cst option
1059810598
| Optional of string
@@ -10616,6 +10616,12 @@ type kind =
1061610616
arg_label :label
1061710617
}
1061810618

10619+
val empty_label : label
10620+
val empty_lit : cst -> label
10621+
val label : string -> cst option -> label
10622+
val optional : string -> label
10623+
val empty_kind : ty -> kind
10624+
1061910625
end = struct
1062010626
#1 "ast_arg.ml"
1062110627
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -10673,6 +10679,14 @@ type kind =
1067310679
arg_label : label
1067410680
}
1067510681

10682+
10683+
let empty_label = Empty None
10684+
let empty_lit s = Empty (Some s)
10685+
let label s cst = Label(s,cst)
10686+
let optional s = Optional s
10687+
10688+
let empty_kind arg_type = { arg_label = empty_label ; arg_type }
10689+
1067610690
end
1067710691
module Bs_version : sig
1067810692
#1 "bs_version.mli"
@@ -12222,39 +12236,35 @@ let handle_attributes
1222212236
let arg_type, new_ty = get_arg_type ~nolabel:true false ty in
1222312237
begin match arg_type with
1222412238
| Extern_unit ->
12225-
{ Ast_arg.arg_label = Empty None; arg_type }, (label,new_ty,attr,loc)::arg_types, result_types
12239+
Ast_arg.empty_kind arg_type, (label,new_ty,attr,loc)::arg_types, result_types
1222612240
| _ ->
1222712241
Location.raise_errorf ~loc "expect label, optional, or unit here"
1222812242
end
1222912243
| Label name ->
1223012244
let arg_type, new_ty = get_arg_type ~nolabel:false false ty in
1223112245
begin match arg_type with
1223212246
| Ignore ->
12233-
{ arg_label = Empty None ; arg_type },
12247+
Ast_arg.empty_kind arg_type,
1223412248
(label,new_ty,attr,loc)::arg_types, result_types
12235-
| Arg_cst (Arg_int_lit _ as i) ->
12249+
| Arg_cst i ->
1223612250
let s = (Lam_methname.translate ~loc name) in
12237-
{arg_label = Label (s, Some i) ; arg_type },
12251+
{arg_label = Ast_arg.label s (Some i);
12252+
arg_type },
1223812253
arg_types, (* ignored in [arg_types], reserved in [result_types] *)
1223912254
((name , [], new_ty) :: result_types)
12240-
| Arg_cst (Arg_string_lit _ as i) ->
12241-
let s = (Lam_methname.translate ~loc name) in
12242-
{arg_label = Label (s, Some i) ; arg_type },
12243-
arg_types,
12244-
((name , [], new_ty) :: result_types)
1224512255
| Nothing | Array ->
1224612256
let s = (Lam_methname.translate ~loc name) in
12247-
{arg_label = Label (s,None) ; arg_type },
12257+
{arg_label = Ast_arg.label s None ; arg_type },
1224812258
(label,new_ty,attr,loc)::arg_types,
1224912259
((name , [], new_ty) :: result_types)
1225012260
| Int _ ->
1225112261
let s = Lam_methname.translate ~loc name in
12252-
{arg_label = Label (s,None); arg_type},
12262+
{arg_label = Ast_arg.label s None; arg_type},
1225312263
(label,new_ty,attr,loc)::arg_types,
1225412264
((name, [], Ast_literal.type_int ~loc ()) :: result_types)
1225512265
| NullString _ ->
1225612266
let s = Lam_methname.translate ~loc name in
12257-
{arg_label = Label (s,None); arg_type},
12267+
{arg_label = Ast_arg.label s None; arg_type},
1225812268
(label,new_ty,attr,loc)::arg_types,
1225912269
((name, [], Ast_literal.type_string ~loc ()) :: result_types)
1226012270
| Fn_uncurry_arity _ ->
@@ -12271,22 +12281,22 @@ let handle_attributes
1227112281
let new_ty = Ast_core_type.lift_option_type new_ty_extract in
1227212282
begin match arg_type with
1227312283
| Ignore ->
12274-
{arg_label = Empty None ; arg_type},
12284+
Ast_arg.empty_kind arg_type,
1227512285
(label,new_ty,attr,loc)::arg_types, result_types
1227612286

1227712287
| Nothing | Array ->
1227812288
let s = (Lam_methname.translate ~loc name) in
12279-
{arg_label = Optional s; arg_type},
12289+
{arg_label = Ast_arg.optional s; arg_type},
1228012290
(label,new_ty,attr,loc)::arg_types,
1228112291
( (name, [], Ast_comb.to_undefined_type loc new_ty_extract) :: result_types)
1228212292
| Int _ ->
1228312293
let s = Lam_methname.translate ~loc name in
12284-
{arg_label = Optional s ; arg_type },
12294+
{arg_label = Ast_arg.optional s ; arg_type },
1228512295
(label,new_ty,attr,loc)::arg_types,
1228612296
((name, [], Ast_comb.to_undefined_type loc @@ Ast_literal.type_int ~loc ()) :: result_types)
1228712297
| NullString _ ->
1228812298
let s = Lam_methname.translate ~loc name in
12289-
{arg_label = Optional s ; arg_type },
12299+
{arg_label = Ast_arg.optional s ; arg_type },
1229012300
(label,new_ty,attr,loc)::arg_types,
1229112301
((name, [], Ast_comb.to_undefined_type loc @@ Ast_literal.type_string ~loc ()) :: result_types)
1229212302
| Arg_cst _
@@ -12348,25 +12358,21 @@ let handle_attributes
1234812358
~loc
1234912359
"[@@bs.string] does not work with optional when it has arities in label %s" label
1235012360
| _ ->
12351-
Ast_arg.Optional s, arg_type,
12361+
Ast_arg.optional s, arg_type,
1235212362
((label, Ast_core_type.lift_option_type new_ty , attr,loc) :: arg_types) end
1235312363
| Label s ->
1235412364
begin match get_arg_type ~nolabel:false false ty with
12355-
| (Arg_cst (Arg_int_lit _ as i) as arg_type), new_ty ->
12356-
Label(s, Some i), arg_type, arg_types
12357-
| (Arg_cst (Arg_string_lit _ as i) as arg_type), new_ty ->
12358-
Label(s, Some i), arg_type, arg_types
12365+
| (Arg_cst ( i) as arg_type), new_ty ->
12366+
Ast_arg.label s (Some i), arg_type, arg_types
1235912367
| arg_type, new_ty ->
12360-
Label (s,None), arg_type, (label, new_ty,attr,loc) :: arg_types
12368+
Ast_arg.label s None, arg_type, (label, new_ty,attr,loc) :: arg_types
1236112369
end
1236212370
| Empty ->
1236312371
begin match get_arg_type ~nolabel:true false ty with
12364-
| (Arg_cst (Arg_int_lit _ as i) as arg_type), new_ty ->
12365-
Empty (Some i) , arg_type, arg_types
12366-
| (Arg_cst (Arg_string_lit _ as i) as arg_type), new_ty ->
12367-
Empty(Some i), arg_type, arg_types
12372+
| (Arg_cst ( i) as arg_type), new_ty ->
12373+
Ast_arg.empty_lit i , arg_type, arg_types
1236812374
| arg_type, new_ty ->
12369-
Empty None, arg_type, (label, new_ty,attr,loc) :: arg_types
12375+
Ast_arg.empty_label, arg_type, (label, new_ty,attr,loc) :: arg_types
1237012376
end
1237112377
in
1237212378
(if i = 0 && splice then
@@ -12386,9 +12392,9 @@ let handle_attributes
1238612392
| Arg_cst _ ->
1238712393
Location.raise_errorf ~loc:obj.ptyp_loc "[@bs.as] is not supported in bs.send type "
1238812394
| _ ->
12389-
[{ arg_label = Empty None;
12390-
arg_type (* more error checking *)
12391-
}],
12395+
(* more error checking *)
12396+
[Ast_arg.empty_kind arg_type]
12397+
,
1239212398
["", new_ty, [], obj.ptyp_loc]
1239312399
,0
1239412400
end
@@ -12726,7 +12732,7 @@ let pval_prim_of_labels labels =
1272612732
List.fold_right
1272712733
(fun {Asttypes.loc ; txt } arg_kinds
1272812734
->
12729-
let arg_label = Ast_arg.Label (Lam_methname.translate ~loc txt, None) in
12735+
let arg_label = Ast_arg.label (Lam_methname.translate ~loc txt) None in
1273012736
{Ast_arg.arg_type = Nothing ;
1273112737
arg_label } :: arg_kinds
1273212738
)

0 commit comments

Comments
 (0)