@@ -53,6 +53,12 @@ type meth_kind = Lambda.meth_kind
53
53
| Public of string option
54
54
| Cached
55
55
56
+ type pointer_info =
57
+ | Pt_constructor of string
58
+ | Pt_variant of string
59
+ | Pt_module_alias
60
+ | Pt_na
61
+
56
62
type constant =
57
63
| Const_js_null
58
64
| Const_js_undefined
@@ -66,7 +72,7 @@ type constant =
66
72
| Const_int32 of int32
67
73
| Const_int64 of int64
68
74
| Const_nativeint of nativeint
69
- | Const_pointer of int * Lambda . pointer_info
75
+ | Const_pointer of int * pointer_info
70
76
| Const_block of int * Lambda .tag_info * constant list
71
77
| Const_float_array of string list
72
78
| Const_immstring of string
@@ -1141,7 +1147,14 @@ let if_ (a : t) (b : t) c =
1141
1147
| Const_float_array _
1142
1148
| Const_immstring _ -> b
1143
1149
end
1144
- | _ -> Lifthenelse (a,b,c)
1150
+ | _ ->
1151
+ begin match a, b, c with
1152
+ | Lprim {primitive = Pintcomp _;}, Lconst (Const_js_true ), Lconst (Const_js_false )
1153
+ -> a
1154
+ | _ ->
1155
+
1156
+ Lifthenelse (a,b,c)
1157
+ end
1145
1158
1146
1159
1147
1160
let abs_int x = if x < 0 then - x else x
@@ -1195,10 +1208,10 @@ let stringswitch (lam : t) cases default : t =
1195
1208
1196
1209
1197
1210
let true_ : t =
1198
- Lconst (Const_pointer ( 1 , Pt_builtin_boolean ) )
1211
+ Lconst (Const_js_true )
1199
1212
1200
1213
let false_ : t =
1201
- Lconst (Const_pointer ( 0 , Pt_builtin_boolean ) )
1214
+ Lconst (Const_js_false )
1202
1215
1203
1216
let unit : t =
1204
1217
Lconst (Const_pointer ( 0 , Pt_constructor " ()" ))
@@ -1909,7 +1922,14 @@ let convert exports lam : _ * _ =
1909
1922
| Const_base (Const_int32 i ) -> (Const_int32 i)
1910
1923
| Const_base (Const_int64 i ) -> (Const_int64 i)
1911
1924
| Const_base (Const_nativeint i ) -> (Const_nativeint i)
1912
- | Const_pointer (i ,p ) -> Const_pointer (i,p)
1925
+ | Const_pointer (i ,p ) ->
1926
+ begin match p with
1927
+ | Pt_constructor p -> Const_pointer (i, Pt_constructor p)
1928
+ | Pt_variant p -> Const_pointer (i,Pt_variant p)
1929
+ | Pt_module_alias -> Const_pointer (i, Pt_module_alias )
1930
+ | Pt_builtin_boolean -> if i = 0 then Const_js_false else Const_js_true
1931
+ | Pt_na -> Const_pointer (i, Pt_na )
1932
+ end
1913
1933
| Const_float_array (s ) -> Const_float_array (s)
1914
1934
| Const_immstring s -> Const_immstring s
1915
1935
| Const_block (i ,t ,xs ) ->
0 commit comments