@@ -978,6 +978,7 @@ let _ =
978
978
register_un_prim " caml_obj_dup" `Mutable (fun cx loc ->
979
979
J. call (J. dot cx (Utf8_string. of_string_exn " slice" )) [] loc);
980
980
register_un_prim " caml_int_of_float" `Pure (fun cx _loc -> to_int cx);
981
+ register_un_prim " caml_float_of_int" `Pure (fun cx _loc -> cx);
981
982
register_un_math_prim " caml_abs_float" " abs" ;
982
983
register_un_math_prim " caml_acos_float" " acos" ;
983
984
register_un_math_prim " caml_asin_float" " asin" ;
@@ -1056,15 +1057,6 @@ let remove_unused_tail_args ctx exact trampolined args =
1056
1057
else args
1057
1058
else args
1058
1059
1059
- let maybe_zero_or_nan = function
1060
- | J. ENum n -> (
1061
- match J.Num. to_string n with
1062
- | "NaN" -> true
1063
- | "-0." | "0." | "0" | "-0" -> true
1064
- | _ -> false )
1065
- | J. EBin ((J. Bor | J. Lsr ), _ , _ ) -> false
1066
- | _ -> true
1067
-
1068
1060
let rec translate_expr ctx queue loc x e level : _ * J.statement_list =
1069
1061
match e with
1070
1062
| Apply { f; args; exact } ->
@@ -1359,32 +1351,32 @@ let rec translate_expr ctx queue loc x e level : _ * J.statement_list =
1359
1351
let (px, cx), queue = access_queue' ~ctx queue x in
1360
1352
let (py, cy), queue = access_queue' ~ctx queue y in
1361
1353
bool (J. EBin (J. LeInt , cx, cy)), or_p px py, queue
1362
- | Eq , [ x; y ] ->
1354
+ | Eq k , [ x; y ] ->
1363
1355
let (px, cx), queue = access_queue' ~ctx queue x in
1364
1356
let (py, cy), queue = access_queue' ~ctx queue y in
1365
1357
let e =
1366
- if not (maybe_zero_or_nan cx && maybe_zero_or_nan cy)
1367
- then bool (J. EBin (J. EqEqEq , cx, cy))
1368
- else
1369
- bool
1370
- (J. call
1371
- (J. dot (s_var " Object" ) (Utf8_string. of_string_exn " is" ))
1372
- [ cx; cy ]
1373
- loc)
1358
+ match k with
1359
+ | Not_float -> bool (J. EBin (J. EqEqEq , cx, cy))
1360
+ | Float | Unknown ->
1361
+ bool
1362
+ (J. call
1363
+ (J. dot (s_var " Object" ) (Utf8_string. of_string_exn " is" ))
1364
+ [ cx; cy ]
1365
+ loc)
1374
1366
in
1375
1367
e, or_p px py, queue
1376
- | Neq , [ x; y ] ->
1368
+ | Neq k , [ x; y ] ->
1377
1369
let (px, cx), queue = access_queue' ~ctx queue x in
1378
1370
let (py, cy), queue = access_queue' ~ctx queue y in
1379
1371
let e =
1380
- if not (maybe_zero_or_nan cx && maybe_zero_or_nan cy)
1381
- then bool (J. EBin (J. NotEqEq , cx, cy))
1382
- else
1383
- bool_not
1384
- (J. call
1385
- (J. dot (s_var " Object" ) (Utf8_string. of_string_exn " is" ))
1386
- [ cx; cy ]
1387
- loc)
1372
+ match k with
1373
+ | Not_float -> bool (J. EBin (J. NotEqEq , cx, cy))
1374
+ | Float | Unknown ->
1375
+ bool_not
1376
+ (J. call
1377
+ (J. dot (s_var " Object" ) (Utf8_string. of_string_exn " is" ))
1378
+ [ cx; cy ]
1379
+ loc)
1388
1380
in
1389
1381
e, or_p px py, queue
1390
1382
| IsInt , [ x ] ->
@@ -1394,7 +1386,7 @@ let rec translate_expr ctx queue loc x e level : _ * J.statement_list =
1394
1386
let (px, cx), queue = access_queue' ~ctx queue x in
1395
1387
let (py, cy), queue = access_queue' ~ctx queue y in
1396
1388
bool (J. EBin (J. LtInt , unsigned cx, unsigned cy)), or_p px py, queue
1397
- | (Vectlength | Array_get | Not | IsInt | Eq | Neq | Lt | Le | Ult ), _ ->
1389
+ | (Vectlength | Array_get | Not | IsInt | Eq _ | Neq _ | Lt | Le | Ult ), _ ->
1398
1390
assert false
1399
1391
in
1400
1392
res, []
@@ -2062,7 +2054,7 @@ let init () =
2062
2054
; " caml_int32_of_int" , " %identity"
2063
2055
; " caml_int32_to_int" , " %identity"
2064
2056
; " caml_int32_of_float" , " caml_int_of_float"
2065
- ; " caml_int32_to_float" , " %identity "
2057
+ ; " caml_int32_to_float" , " caml_float_of_int "
2066
2058
; " caml_int32_format" , " caml_format_int"
2067
2059
; " caml_int32_of_string" , " caml_int_of_string"
2068
2060
; " caml_int32_compare" , " caml_int_compare"
@@ -2081,7 +2073,7 @@ let init () =
2081
2073
; " caml_nativeint_of_int" , " %identity"
2082
2074
; " caml_nativeint_to_int" , " %identity"
2083
2075
; " caml_nativeint_of_float" , " caml_int_of_float"
2084
- ; " caml_nativeint_to_float" , " %identity "
2076
+ ; " caml_nativeint_to_float" , " caml_float_of_int "
2085
2077
; " caml_nativeint_of_int32" , " %identity"
2086
2078
; " caml_nativeint_to_int32" , " %identity"
2087
2079
; " caml_nativeint_format" , " caml_format_int"
@@ -2092,7 +2084,6 @@ let init () =
2092
2084
; " caml_int64_to_int" , " caml_int64_to_int32"
2093
2085
; " caml_int64_of_nativeint" , " caml_int64_of_int32"
2094
2086
; " caml_int64_to_nativeint" , " caml_int64_to_int32"
2095
- ; " caml_float_of_int" , " %identity"
2096
2087
; " caml_array_get_float" , " caml_array_get"
2097
2088
; " caml_floatarray_get" , " caml_array_get"
2098
2089
; " caml_array_get_addr" , " caml_array_get"
0 commit comments