Skip to content

Commit be289e2

Browse files
committed
using inline records
1 parent 21a298d commit be289e2

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

jscomp/core/lam_compile_external_call.ml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ let ocaml_to_js_eff
9898
match arg_label with
9999
| Optional label ->
100100
Js_of_lam_option.get_default_undefined_from_optional raw_arg
101-
| Label (_, None) | Empty -> raw_arg
102-
| Label (_, Some _)
101+
| Label {cst = None;_} | Empty -> raw_arg
102+
| Label {cst = Some _;_}
103103
| EmptyCst _
104104
-> assert false in
105105
match arg_type with
@@ -176,16 +176,16 @@ let assemble_args_no_splice call_loc ffi
176176
| [], _
177177
-> assert (args = []) ; empty_pair
178178
| { arg_label = EmptyCst cst ; _} :: labels, args
179-
| { arg_label = Label (_, Some cst); _} :: labels, args ->
179+
| { arg_label = Label {cst = Some cst;_}; _} :: labels, args ->
180180
let accs, eff = aux labels args in
181181
Lam_compile_const.translate_arg_cst cst :: accs, eff
182-
| ({arg_label = Empty | Label (_,None) | Optional _ ;_ } as arg_kind) ::labels,
182+
| ({arg_label = Empty | Label {cst = None;_} | Optional _ ;_ } as arg_kind) ::labels,
183183
arg :: args
184184
->
185185
let accs, eff = aux labels args in
186186
let acc, new_eff = ocaml_to_js_eff arg_kind arg in
187187
append_list acc accs, Ext_list.append new_eff eff
188-
| { arg_label = Empty | Label (_,None) | Optional _ ; _ } :: _ , []
188+
| { arg_label = Empty | Label {cst = None;_} | Optional _ ; _ } :: _ , []
189189
-> assert false
190190
in
191191
let args, eff = aux arg_types args in
@@ -202,10 +202,10 @@ let assemble_args_has_splice call_loc ffi (arg_types : specs) (args : exprs)
202202
match labels, args with
203203
| [] , _ -> assert (args = []); empty_pair
204204
| { arg_label = EmptyCst cst ; _} :: labels , args
205-
| { arg_label = Label (_, Some cst); _} :: labels , args ->
205+
| { arg_label = Label {cst = Some cst;_}; _} :: labels , args ->
206206
let accs, eff = aux labels args in
207207
Lam_compile_const.translate_arg_cst cst :: accs, eff
208-
| ({arg_label = Empty | Label (_,None) | Optional _ ;_ } as arg_kind) ::labels,
208+
| ({arg_label = Empty | Label {cst = None;_} | Optional _ ;_ } as arg_kind) ::labels,
209209
arg :: args
210210
->
211211
let accs, eff = aux labels args in
@@ -217,7 +217,7 @@ let assemble_args_has_splice call_loc ffi (arg_types : specs) (args : exprs)
217217
let acc, new_eff = ocaml_to_js_eff arg_kind arg in
218218
append_list acc accs, Ext_list.append new_eff eff
219219
end
220-
| { arg_label = Empty | Label (_,None) | Optional _ ; _ } :: _ , []
220+
| { arg_label = Empty | Label {cst = None;_} | Optional _ ; _ } :: _ , []
221221
-> assert false
222222
in
223223
let args, eff = aux arg_types args in

jscomp/core/lam_compile_external_obj.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ let assemble_obj_args (labels : External_arg_spec.t list) (args : J.expression
4646
: (Js_op.property_name * E.t ) list * J.expression list * _ =
4747
match labels, args with
4848
| [] , [] -> [], [], []
49-
| {arg_label = Label (label, Some cst )} :: labels , args ->
49+
| {arg_label = Label {name = label; cst = Some cst }} :: labels , args ->
5050
let accs, eff, assign = aux labels args in
5151
(label, Lam_compile_const.translate_arg_cst cst )::accs, eff, assign
5252
| {arg_label = EmptyCst _ } :: rest , args -> assert false
@@ -55,7 +55,7 @@ let assemble_obj_args (labels : External_arg_spec.t list) (args : J.expression
5555
let (accs, eff, assign) as r = aux labels args in
5656
if Js_analyzer.no_side_effect_expression arg then r
5757
else (accs, arg::eff, assign)
58-
| ({arg_label = Label (label,None) } as arg_kind)::labels, arg::args
58+
| ({arg_label = Label {name = label; cst = None} } as arg_kind)::labels, arg::args
5959
->
6060
let accs, eff, assign = aux labels args in
6161
let acc, new_eff = Lam_compile_external_call.ocaml_to_js_eff arg_kind arg in
@@ -66,7 +66,7 @@ let assemble_obj_args (labels : External_arg_spec.t list) (args : J.expression
6666
(label, x) :: accs , Ext_list.append new_eff eff , assign
6767
end (* evaluation order is undefined *)
6868

69-
| ({arg_label = Optional label; arg_type } as arg_kind)::labels, arg::args
69+
| ({arg_label = Optional {name = label}; arg_type } as arg_kind)::labels, arg::args
7070
->
7171
let (accs, eff, assign) as r = aux labels args in
7272
Js_of_lam_option.destruct_optional arg
@@ -80,7 +80,7 @@ let assemble_obj_args (labels : External_arg_spec.t list) (args : J.expression
8080
(label, x) :: accs , Ext_list.append new_eff eff , assign
8181
end )
8282
~not_sure:(fun _ -> accs, eff , (arg_kind,arg)::assign )
83-
| {arg_label = Empty | Label (_,None) | Optional _ } :: _ , [] -> assert false
83+
| {arg_label = Empty | Label {cst = None;_} | Optional _ } :: _ , [] -> assert false
8484
| [], _ :: _ -> assert false
8585
in
8686
let map, eff, assignment = aux labels args in
@@ -103,7 +103,7 @@ let assemble_obj_args (labels : External_arg_spec.t list) (args : J.expression
103103
(Ext_list.flat_map assignment (fun
104104
((xlabel : External_arg_spec.t), (arg : J.expression )) ->
105105
match xlabel with
106-
| {arg_label = Optional label } ->
106+
| {arg_label = Optional {name = label} } ->
107107
(* Need make sure whether assignment is effectful or not
108108
to avoid code duplication
109109
*)

jscomp/syntax/external_arg_spec.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ type cst =
3333
| Arg_js_false
3434
| Arg_js_json of string
3535
type label =
36-
| Label of string * cst option
36+
| Label of {name : string ; cst : cst option }
3737
| Empty
3838
| EmptyCst of cst
39-
| Optional of string
39+
| Optional of {name : string }
4040
(* it will be ignored , side effect will be recorded *)
4141

4242
type attr =
@@ -93,7 +93,7 @@ let cst_int i = Arg_int_lit i
9393
let cst_string s = Arg_string_lit s
9494
let empty_label = Empty
9595
let empty_lit s = EmptyCst s
96-
let label s cst = Label(s,cst)
97-
let optional s = Optional s
96+
let label name cst = Label {name ; cst}
97+
let optional name = Optional {name}
9898

9999
let empty_kind arg_type = { arg_label = empty_label ; arg_type }

jscomp/syntax/external_arg_spec.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ type cst = private
3232

3333

3434
type label = private
35-
| Label of string * cst option
35+
| Label of {name : string ; cst : cst option }
3636
| Empty
3737
| EmptyCst of cst
38-
| Optional of string
38+
| Optional of {name : string}
3939
(* it will be ignored , side effect will be recorded *)
4040

4141
type attr =

0 commit comments

Comments
 (0)