Skip to content

Commit 7045190

Browse files
committed
adding Const_module_alias
- we keep it different from Const_js_undefined mostly because we don't want to serialize module alias in cmj format
1 parent 531822a commit 7045190

11 files changed

+14
-7
lines changed

jscomp/core/lam.ml

+1
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,7 @@ let if_ (a : t) (b : t) (c : t) : t =
721721
if x <> 0n then b else c
722722
| Const_js_false
723723
| Const_js_null
724+
| Const_module_alias
724725
| Const_js_undefined -> c
725726
| Const_js_true
726727
| Const_string _

jscomp/core/lam_analysis.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ and size_constant x =
324324
| Const_nativeint _
325325
| Const_immstring _
326326
| Const_pointer _
327-
| Const_js_null | Const_js_undefined
327+
| Const_js_null | Const_js_undefined | Const_module_alias
328328
| Const_js_true | Const_js_false
329329
-> 1
330330
| Const_unicode _ (* TODO: this seems to be not good heurisitives*)

jscomp/core/lam_compile_const.ml

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ module E = Js_exp_make
3535
let rec is_some_none_aux (x : Lam_constant.t) acc =
3636
match x with
3737
| Const_some v -> is_some_none_aux v (acc + 1)
38+
| Const_module_alias
3839
| Const_js_undefined -> acc
3940
| _ -> -1
4041

@@ -50,6 +51,7 @@ translate_some (x : Lam_constant.t) : J.expression =
5051
else nested_some_none depth (E.optional_block (translate Const_js_undefined))
5152
and translate (x : Lam_constant.t ) : J.expression =
5253
match x with
54+
| Const_module_alias -> E.undefined (* TODO *)
5355
| Const_some s -> translate_some s
5456
| Const_js_true -> E.bool true
5557
| Const_js_false -> E.bool false

jscomp/core/lam_compile_util.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ let comment_of_tag_info (x : Lam_tag_info.t) =
6262
| Blk_extension_slot -> None
6363
| Blk_na s -> if s = "" then None else Some s
6464

65-
let module_alias = Some "alias"
65+
(* let module_alias = Some "alias" *)
6666
let comment_of_pointer_info (x : Lam_pointer_info.t)=
6767
match x with
6868
| Pt_constructor {name;_}
6969
| Pt_variant {name} -> Some name
70-
| Pt_module_alias -> module_alias
70+
(* | Pt_module_alias -> module_alias *)
7171
| Pt_na -> None

jscomp/core/lam_constant.ml

+2
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@
4040
| Const_float_array of string list
4141
| Const_immstring of string
4242
| Const_some of t
43+
| Const_module_alias
4344
(* eventually we can remove it, since we know
4445
[constant] is [undefined] or not
4546
*)
4647

4748

4849
let rec eq_approx (x : t) (y : t) =
4950
match x with
51+
| Const_module_alias -> y = Const_module_alias
5052
| Const_js_null -> y = Const_js_null
5153
| Const_js_undefined -> y = Const_js_undefined
5254
| Const_js_true -> y = Const_js_true

jscomp/core/lam_constant.mli

+1
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,6 @@ type t =
4343
(* eventually we can remove it, since we know
4444
[constant] is [undefined] or not
4545
*)
46+
| Const_module_alias
4647
val eq_approx : t -> t -> bool
4748
val lam_none : t

jscomp/core/lam_constant_convert.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ let rec convert_constant ( const : Lambda.structured_constant) : Lam_constant.t
4444
begin match p with
4545
| Pt_constructor {name;cstrs} -> Const_pointer(i, Pt_constructor {name; cstrs})
4646
| Pt_variant {name} -> Const_pointer(i,Pt_variant {name})
47-
| Pt_module_alias -> Const_pointer(i, Pt_module_alias)
47+
| Pt_module_alias -> Const_module_alias
4848
| Pt_builtin_boolean -> if i = 0 then Const_js_false else Const_js_true
4949
| Pt_shape_none ->
5050
Lam_constant.lam_none

jscomp/core/lam_pointer_info.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@
2626
type t =
2727
| Pt_constructor of {name : string ; cstrs : int * int}
2828
| Pt_variant of {name : string }
29-
| Pt_module_alias
29+
(* | Pt_module_alias *)
3030
| Pt_na

jscomp/core/lam_pointer_info.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@
2626
type t =
2727
| Pt_constructor of {name : string ; cstrs : int * int}
2828
| Pt_variant of { name : string}
29-
| Pt_module_alias
29+
(* | Pt_module_alias *)
3030
| Pt_na

jscomp/core/lam_print.ml

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ let rec struct_const ppf (cst : Lam_constant.t) =
2222
| Const_js_true -> fprintf ppf "#true"
2323
| Const_js_false -> fprintf ppf "#false"
2424
| Const_js_null -> fprintf ppf "#null"
25+
| Const_module_alias -> fprintf ppf "#alias"
2526
| Const_js_undefined -> fprintf ppf "#undefined"
2627
| (Const_int n) -> fprintf ppf "%i" n
2728
| (Const_char c) -> fprintf ppf "%C" c

jscomp/core/lam_stats_export.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ let values_of_export
100100
in
101101
match arity, persistent_closed_lambda with
102102
| Single Arity_na,
103-
(None | Some (Lconst (Const_pointer (_, Pt_module_alias)))) -> acc
103+
(None | Some (Lconst Const_module_alias)) -> acc
104104
| Submodule [||], None -> acc
105105
| _ ->
106106
let cmj_value : Js_cmj_format.cmj_value =

0 commit comments

Comments
 (0)