Skip to content

Commit 0f05df9

Browse files
committed
better names
1 parent c94e958 commit 0f05df9

File tree

4 files changed

+36
-36
lines changed

4 files changed

+36
-36
lines changed

jscomp/core/lam_compile_external_obj.ml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,41 +46,41 @@ let assemble_obj_args (labels : External_arg_spec.obj_params) (args : J.express
4646
: (Js_op.property_name * E.t ) list * J.expression list * _ =
4747
match labels, args with
4848
| [] , [] -> [], [], []
49-
| {arg_label = Label {name = label; cst = Some cst }} :: labels , args ->
49+
| {obj_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
52-
| {arg_label = EmptyCst _ } :: rest , args -> assert false
53-
| {arg_label = Empty }::labels, arg::args
52+
| {obj_arg_label = EmptyCst _ } :: rest , args -> assert false
53+
| {obj_arg_label = Empty }::labels, arg::args
5454
-> (* unit type*)
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 {name = label; cst = None} } as arg_kind)::labels, arg::args
58+
| ({obj_arg_label = Label {name = label; cst = None} } as arg_kind)::labels, arg::args
5959
->
6060
let accs, eff, assign = aux labels args in
61-
let acc, new_eff = Lam_compile_external_call.ocaml_to_js_eff ~arg_label:Arg_label ~arg_type:arg_kind.arg_type arg in
61+
let acc, new_eff = Lam_compile_external_call.ocaml_to_js_eff ~arg_label:Arg_label ~arg_type:arg_kind.obj_arg_type arg in
6262
begin match acc with
6363
| Splice2 _
6464
| Splice0 -> assert false
6565
| Splice1 x ->
6666
(label, x) :: accs , Ext_list.append new_eff eff , assign
6767
end (* evaluation order is undefined *)
6868

69-
| ({arg_label = Optional {name = label}; arg_type } as arg_kind)::labels, arg::args
69+
| ({obj_arg_label = Optional {name = label}; obj_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
7373
~for_sure_none:r
7474
~for_sure_some:(fun x -> let acc, new_eff = Lam_compile_external_call.ocaml_to_js_eff
75-
~arg_label:Arg_label ~arg_type x in
75+
~arg_label:Arg_label ~arg_type:obj_arg_type x in
7676
begin match acc with
7777
| Splice2 _
7878
| Splice0 -> assert false
7979
| Splice1 x ->
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 {cst = None;_} | Optional _ } :: _ , [] -> assert false
83+
| {obj_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.obj_params) (args : J.express
103103
(Ext_list.flat_map assignment (fun
104104
((xlabel : External_arg_spec.obj_param), (arg : J.expression )) ->
105105
match xlabel with
106-
| {arg_label = Optional {name = label} } ->
106+
| {obj_arg_label = Optional {name = label} } ->
107107
(* Need make sure whether assignment is effectful or not
108108
to avoid code duplication
109109
*)
@@ -112,7 +112,7 @@ let assemble_obj_args (labels : External_arg_spec.obj_params) (args : J.express
112112
let acc,new_eff =
113113
Lam_compile_external_call.ocaml_to_js_eff
114114
~arg_label:
115-
Arg_empty ~arg_type:xlabel.arg_type
115+
Arg_empty ~arg_type:xlabel.obj_arg_type
116116
(Js_of_lam_option.val_from_option arg) in
117117
begin match acc with
118118
| Splice1 v ->
@@ -132,7 +132,7 @@ let assemble_obj_args (labels : External_arg_spec.obj_params) (args : J.express
132132
Lam_compile_external_call.ocaml_to_js_eff
133133
~arg_label:
134134
Arg_empty
135-
~arg_type:xlabel.arg_type
135+
~arg_type:xlabel.obj_arg_type
136136
(Js_of_lam_option.val_from_option arg) in
137137
begin match acc with
138138
| Splice1 v ->

jscomp/syntax/ast_external_process.ml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -416,30 +416,30 @@ let process_obj
416416
else
417417
Location.raise_errorf ~loc "expect label, optional, or unit here"
418418
| Labelled name ->
419-
let new_ty, arg_type = refine_arg_type ~nolabel:false ty in
420-
begin match arg_type with
419+
let new_ty, obj_arg_type = refine_arg_type ~nolabel:false ty in
420+
begin match obj_arg_type with
421421
| Ignore ->
422-
External_arg_spec.empty_kind arg_type,
422+
External_arg_spec.empty_kind obj_arg_type,
423423
{param_type with ty = new_ty}::arg_types, result_types
424424
| Arg_cst i ->
425425
let s = Lam_methname.translate name in
426-
{arg_label = External_arg_spec.label s (Some i);
427-
arg_type },
426+
{obj_arg_label = External_arg_spec.label s (Some i);
427+
obj_arg_type },
428428
arg_types, (* ignored in [arg_types], reserved in [result_types] *)
429429
(({Asttypes.txt = name; loc} , [], new_ty) :: result_types)
430430
| Nothing ->
431431
let s = (Lam_methname.translate name) in
432-
{arg_label = External_arg_spec.label s None ; arg_type },
432+
{obj_arg_label = External_arg_spec.label s None ; obj_arg_type },
433433
{param_type with ty = new_ty}::arg_types,
434434
(({Asttypes.txt = name; loc} , [], new_ty) :: result_types)
435435
| Int _ ->
436436
let s = Lam_methname.translate name in
437-
{arg_label = External_arg_spec.label s None; arg_type},
437+
{obj_arg_label = External_arg_spec.label s None; obj_arg_type},
438438
{param_type with ty = new_ty}::arg_types,
439439
(({Asttypes.txt = name; loc}, [], Ast_literal.type_int ~loc ()) :: result_types)
440440
| NullString _ ->
441441
let s = Lam_methname.translate name in
442-
{arg_label = External_arg_spec.label s None; arg_type},
442+
{obj_arg_label = External_arg_spec.label s None; obj_arg_type},
443443
{param_type with ty = new_ty }::arg_types,
444444
(({Asttypes.txt = name; loc}, [], Ast_literal.type_string ~loc ()) :: result_types)
445445
| Fn_uncurry_arity _ ->
@@ -455,24 +455,24 @@ let process_obj
455455
"bs.obj label %s does not support [@bs.unwrap] arguments" name
456456
end
457457
| Optional name ->
458-
let arg_type = get_opt_arg_type ~nolabel:false ty in
459-
begin match arg_type with
458+
let obj_arg_type = get_opt_arg_type ~nolabel:false ty in
459+
begin match obj_arg_type with
460460
| Ignore ->
461-
External_arg_spec.empty_kind arg_type,
461+
External_arg_spec.empty_kind obj_arg_type,
462462
param_type::arg_types, result_types
463463
| Nothing ->
464464
let s = (Lam_methname.translate name) in
465-
{arg_label = External_arg_spec.optional s; arg_type},
465+
{obj_arg_label = External_arg_spec.optional s; obj_arg_type},
466466
param_type :: arg_types,
467467
( ({Asttypes.txt = name; loc}, [], Ast_comb.to_undefined_type loc ty) :: result_types)
468468
| Int _ ->
469469
let s = Lam_methname.translate name in
470-
{arg_label = External_arg_spec.optional s ; arg_type },
470+
{obj_arg_label = External_arg_spec.optional s ; obj_arg_type },
471471
param_type :: arg_types,
472472
(({Asttypes.txt = name; loc}, [], Ast_comb.to_undefined_type loc @@ Ast_literal.type_int ~loc ()) :: result_types)
473473
| NullString _ ->
474474
let s = Lam_methname.translate name in
475-
{arg_label = External_arg_spec.optional s ; arg_type },
475+
{obj_arg_label = External_arg_spec.optional s ; obj_arg_type },
476476
param_type::arg_types,
477477
(({Asttypes.txt = name; loc}, [], Ast_comb.to_undefined_type loc @@ Ast_literal.type_string ~loc ()) :: result_types)
478478
| Arg_cst _
@@ -966,11 +966,11 @@ let pval_prim_of_labels (labels : string Asttypes.loc list) =
966966
Ext_list.fold_right labels ([] : External_arg_spec.obj_params )
967967
(fun {loc ; txt } arg_kinds
968968
->
969-
let arg_label =
969+
let obj_arg_label =
970970
External_arg_spec.label
971971
(Lam_methname.translate txt) None in
972-
{arg_type = Nothing ;
973-
arg_label } :: arg_kinds
972+
{obj_arg_type = Nothing ;
973+
obj_arg_label } :: arg_kinds
974974
) in
975975
let encoding =
976976
External_ffi_types.to_string (Ffi_obj_create arg_kinds) in
@@ -988,13 +988,13 @@ let pval_prim_of_option_labels
988988
(fun (is_option,{loc ; txt }) arg_kinds
989989
->
990990
let label_name = Lam_methname.translate txt in
991-
let arg_label =
991+
let obj_arg_label =
992992
if is_option then
993993
External_arg_spec.optional label_name
994994
else External_arg_spec.label label_name None
995995
in
996-
{arg_type = Nothing ;
997-
arg_label } :: arg_kinds) in
996+
{obj_arg_type = Nothing ;
997+
obj_arg_label } :: arg_kinds) in
998998
let encoding =
999999
External_ffi_types.to_string (Ffi_obj_create arg_kinds) in
10001000
[""; encoding]

jscomp/syntax/external_arg_spec.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ type param = {
6464

6565
type obj_param =
6666
{
67-
arg_type : attr;
68-
arg_label : label
67+
obj_arg_type : attr;
68+
obj_arg_label : label
6969
}
7070

7171

@@ -110,4 +110,4 @@ let empty_lit s = EmptyCst s
110110
let label name cst = Label {name ; cst}
111111
let optional name = Optional {name}
112112

113-
let empty_kind arg_type = { arg_label = empty_label ; arg_type }
113+
let empty_kind obj_arg_type = { obj_arg_label = empty_label ; obj_arg_type }

jscomp/syntax/external_arg_spec.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ type label_noname =
5858

5959
type obj_param =
6060
{
61-
arg_type : attr;
62-
arg_label :label
61+
obj_arg_type : attr;
62+
obj_arg_label :label
6363
}
6464

6565
type param = {

0 commit comments

Comments
 (0)