Skip to content

Commit 5e7f5ab

Browse files
committed
remove Caml int32/int64/nativeint
1 parent f05ee48 commit 5e7f5ab

File tree

112 files changed

+227
-9398
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+227
-9398
lines changed

jscomp/core/js_exp_make.ml

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -900,22 +900,6 @@ let rec int32_bor ?comment (e1 : J.expression) (e2 : J.expression) :
900900
int32_bor e1 e2
901901
| _ -> { comment; expression_desc = Bin (Bor, e1, e2) }
902902

903-
(* Arithmatic operations
904-
TODO: distinguish between int and float
905-
TODO: Note that we have to use Int64 to avoid integer overflow, this is fine
906-
since Js only have .
907-
908-
like code below
909-
{[
910-
MAX_INT_VALUE - (MAX_INT_VALUE - 100) + 20
911-
]}
912-
913-
{[
914-
MAX_INT_VALUE - x + 30
915-
]}
916-
917-
check: Re-association: avoid integer overflow
918-
*)
919903
let to_int32 ?comment (e : J.expression) : J.expression =
920904
int32_bor ?comment e zero_int_literal
921905
(* TODO: if we already know the input is int32, [x|0] can be reduced into [x] *)
@@ -1180,15 +1164,15 @@ let int32_div ~checked ?comment (e1 : t) (e2 : t) : t =
11801164
| Number (Int { i = i0 }) -> int (Int32.div i0 i1)
11811165
| _ -> to_int32 (float_div ?comment e1 e2))
11821166
| _, _ ->
1183-
if checked then runtime_call Js_runtime_modules.int32 "div" [ e1; e2 ]
1167+
if checked then runtime_call Js_runtime_modules.int "div" [ e1; e2 ]
11841168
else to_int32 (float_div ?comment e1 e2)
11851169

11861170
let int32_mod ~checked ?comment e1 (e2 : t) : J.expression =
11871171
match e2.expression_desc with
11881172
| Number (Int { i }) when i <> 0l ->
11891173
{ comment; expression_desc = Bin (Mod, e1, e2) }
11901174
| _ ->
1191-
if checked then runtime_call Js_runtime_modules.int32 "mod_" [ e1; e2 ]
1175+
if checked then runtime_call Js_runtime_modules.int "mod_" [ e1; e2 ]
11921176
else { comment; expression_desc = Bin (Mod, e1, e2) }
11931177

11941178
let float_mul ?comment e1 e2 = bin ?comment Mul e1 e2

jscomp/core/js_long.ml

Lines changed: 0 additions & 160 deletions
This file was deleted.

jscomp/core/js_long.mli

Lines changed: 0 additions & 83 deletions
This file was deleted.

jscomp/core/lam.ml

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -461,16 +461,6 @@ module Lift = struct
461461

462462
let bool b = if b then true_ else false_
463463

464-
(* ATTENTION: [float, nativeint] constant propogaton is not done
465-
yet , due to cross platform problem
466-
*)
467-
(* let float b : t =
468-
Lconst ((Const_float b)) *)
469-
470-
(* let nativeint b : t =
471-
Lconst ((Const_nativeint b)) *)
472-
473-
let int64 b : t = Lconst (Const_int64 b)
474464
let string s : t = Lconst (Const_string { s; unicode = false })
475465
let char b : t = Lconst (Const_char b)
476466
end
@@ -492,14 +482,11 @@ let prim ~primitive:(prim : Lam_primitive.t) ~args loc : t =
492482
(* | Pnegbint Pnativeint, ( (Const_nativeint i)) *)
493483
(* -> *)
494484
(* Lift.nativeint (Nativeint.neg i) *)
495-
| Pnegint64, Const_int64 a -> Lift.int64 (Int64.neg a)
496485
| Pnot, Const_js_true -> false_
497486
| Pnot, Const_js_false -> true_
498487
| _ -> default ())
499488
| [ Lconst a; Lconst b ] -> (
500489
match (prim, a, b) with
501-
| Pint64comp cmp, Const_int64 a, Const_int64 b ->
502-
Lift.bool (Lam_compat.cmp_int64 cmp a b)
503490
| Pintcomp cmp, Const_int a, Const_int b ->
504491
Lift.bool (Lam_compat.cmp_int32 cmp a.i b.i)
505492
| Pfloatcomp cmp, Const_float a, Const_float b ->
@@ -532,28 +519,6 @@ let prim ~primitive:(prim : Lam_primitive.t) ~args loc : t =
532519
| Plsrint -> int_ (Int32.shift_right_logical aa (Int32.to_int bb))
533520
| Pasrint -> int_ (Int32.shift_right aa (Int32.to_int bb))
534521
| _ -> default ())
535-
| ( ( Paddint64 | Psubint64 | Pmulint64 | Pdivint64 | Pmodint64
536-
| Pandint64 | Porint64 | Pxorint64 ),
537-
Const_int64 aa,
538-
Const_int64 bb ) -> (
539-
match prim with
540-
| Paddint64 -> Lift.int64 (Int64.add aa bb)
541-
| Psubint64 -> Lift.int64 (Int64.sub aa bb)
542-
| Pmulint64 -> Lift.int64 (Int64.mul aa bb)
543-
| Pdivint64 -> (
544-
try Lift.int64 (Int64.div aa bb) with _ -> default ())
545-
| Pmodint64 -> (
546-
try Lift.int64 (Int64.rem aa bb) with _ -> default ())
547-
| Pandint64 -> Lift.int64 (Int64.logand aa bb)
548-
| Porint64 -> Lift.int64 (Int64.logor aa bb)
549-
| Pxorint64 -> Lift.int64 (Int64.logxor aa bb)
550-
| _ -> default ())
551-
| Plslint64, Const_int64 aa, Const_int { i = b } ->
552-
Lift.int64 (Int64.shift_left aa (Int32.to_int b))
553-
| Plsrint64, Const_int64 aa, Const_int { i = b } ->
554-
Lift.int64 (Int64.shift_right_logical aa (Int32.to_int b))
555-
| Pasrint64, Const_int64 aa, Const_int { i = b } ->
556-
Lift.int64 (Int64.shift_right aa (Int32.to_int b))
557522
| Psequand, Const_js_false, (Const_js_true | Const_js_false) -> false_
558523
| Psequand, Const_js_true, Const_js_true -> true_
559524
| Psequand, Const_js_true, Const_js_false -> false_
@@ -639,7 +604,6 @@ let rec eval_const_as_bool (v : Lam_constant.t) : bool =
639604
match v with
640605
| Const_int { i = x } -> x <> 0l
641606
| Const_char x -> x <> 0
642-
| Const_int64 x -> x <> 0L
643607
| Const_js_false | Const_js_null | Const_module_alias | Const_js_undefined _ ->
644608
false
645609
| Const_js_true | Const_string _ | Const_pointer _ | Const_float _ | Const_bigint _

0 commit comments

Comments
 (0)