Skip to content

Commit 92b47cb

Browse files
committed
compact encoding of obj_param
1 parent e97538a commit 92b47cb

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

jscomp/syntax/ast_external_process.ml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -421,25 +421,25 @@ let process_obj
421421
| Ignore ->
422422
External_arg_spec.empty_kind obj_arg_type,
423423
{param_type with ty = new_ty}::arg_types, result_types
424-
| Arg_cst i ->
424+
| Arg_cst _ ->
425425
let s = Lam_methname.translate name in
426-
{obj_arg_label = External_arg_spec.label s (Some i);
426+
{obj_arg_label = External_arg_spec.obj_label s;
427427
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-
{obj_arg_label = External_arg_spec.label s None ; obj_arg_type },
432+
{obj_arg_label = External_arg_spec.obj_label s ; 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-
{obj_arg_label = External_arg_spec.label s None; obj_arg_type},
437+
{obj_arg_label = External_arg_spec.obj_label s; 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-
{obj_arg_label = External_arg_spec.label s None; obj_arg_type},
442+
{obj_arg_label = External_arg_spec.obj_label s; 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 _ ->
@@ -967,8 +967,8 @@ let pval_prim_of_labels (labels : string Asttypes.loc list) =
967967
(fun {loc ; txt } arg_kinds
968968
->
969969
let obj_arg_label =
970-
External_arg_spec.label
971-
(Lam_methname.translate txt) None in
970+
External_arg_spec.obj_label
971+
(Lam_methname.translate txt) in
972972
{obj_arg_type = Nothing ;
973973
obj_arg_label } :: arg_kinds
974974
) in
@@ -991,7 +991,7 @@ let pval_prim_of_option_labels
991991
let obj_arg_label =
992992
if is_option then
993993
External_arg_spec.optional label_name
994-
else External_arg_spec.label label_name None
994+
else External_arg_spec.obj_label label_name
995995
in
996996
{obj_arg_type = Nothing ;
997997
obj_arg_label } :: arg_kinds) in

jscomp/syntax/external_arg_spec.ml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type label_noname =
4040

4141
type label =
4242
| Obj_label of {name : string }
43-
| Obj_labelCst of {name : string ; cst : cst}
43+
(* | Obj_labelCst of {name : string} *)
4444
| Obj_empty
4545
| Obj_optional of {name : string }
4646
(* it will be ignored , side effect will be recorded *)
@@ -107,13 +107,9 @@ let cst_int i = Arg_int_lit i
107107
let cst_string s = Arg_string_lit s
108108
let empty_label = Obj_empty
109109

110-
let label name cst =
111-
match cst with
112-
| None ->
110+
let obj_label name =
113111
Obj_label {name }
114-
| Some cst ->
115-
Obj_labelCst {name ; cst}
116-
112+
117113
let optional name = Obj_optional {name}
118114

119115
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
@@ -33,7 +33,7 @@ type cst = private
3333

3434
type label = private
3535
| Obj_label of {name : string}
36-
| Obj_labelCst of {name : string ; cst : cst}
36+
(* | Obj_labelCst of {name : string ; cst : cst} *)
3737
| Obj_empty
3838

3939
| Obj_optional of {name : string}
@@ -77,6 +77,6 @@ val cst_string : string -> cst
7777

7878
val empty_label : label
7979
(* val empty_lit : cst -> label *)
80-
val label : string -> cst option -> label
80+
val obj_label : string -> label
8181
val optional : string -> label
8282
val empty_kind : attr -> obj_param

0 commit comments

Comments
 (0)