Skip to content

Commit 91e3b7f

Browse files
committedDec 2, 2018
consolidate bs_stdlib_mini now
1 parent 914276b commit 91e3b7f

23 files changed

+135
-142
lines changed
 

‎jscomp/runtime/.depend

+16-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
block.cmi : js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe bs_obj.cmj
22
caml_array.cmi : js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe
3-
caml_basic.cmi : js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe
3+
caml_basic.cmi : js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe caml_undefined_extern.cmj
44
caml_builtin_exceptions.cmi : js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe
55
caml_bytes.cmi : js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe
66
caml_exceptions.cmi : js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe caml_builtin_exceptions.cmi
@@ -23,27 +23,30 @@ caml_string.cmi : js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe
2323
caml_sys.cmi : js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe
2424
caml_utils.cmi : js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe
2525
caml_weak.cmi : js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe
26-
js_primitive.cmi : js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe bs_obj.cmj
26+
js_primitive.cmi : js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe bs_obj.cmj caml_undefined_extern.cmj
2727
block.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe bs_obj.cmj block.cmi
2828
bs_obj.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe
2929
bs_string.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe
3030
caml_array.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe caml_builtin_exceptions.cmj caml_array.cmi
31-
caml_basic.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe js_primitive.cmj caml_basic.cmi
31+
caml_basic.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe js_primitive.cmj caml_basic.cmi caml_undefined_extern.cmj
3232
caml_builtin_exceptions.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe bs_obj.cmj caml_builtin_exceptions.cmi
3333
caml_bytes.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe caml_builtin_exceptions.cmj caml_bytes.cmi bs_string.cmj
3434
caml_char.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe
3535
caml_exceptions.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe caml_nativeint.cmj caml_builtin_exceptions.cmj bs_obj.cmj caml_exceptions.cmi
36-
caml_float.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe caml_float.cmi
37-
caml_format.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe caml_int32.cmj caml_int64.cmj caml_utils.cmj caml_builtin_exceptions.cmj caml_format.cmi js_nativeint.cmj js_int64.cmj caml_nativeint.cmj caml_float.cmj caml_char.cmj bs_string.cmj
36+
caml_float.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe caml_float_extern.cmj caml_float.cmi
37+
caml_float_extern.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe
38+
caml_format.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe caml_int32.cmj caml_int64.cmj caml_utils.cmj caml_builtin_exceptions.cmj caml_format.cmi js_nativeint.cmj js_int64.cmj caml_nativeint.cmj caml_int64_extern.cmj caml_float_extern.cmj caml_float.cmj caml_char.cmj bs_string.cmj
3839
caml_gc.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe caml_gc.cmi
3940
caml_hash.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe caml_queue.cmj caml_hash_primitive.cmj caml_builtin_exceptions.cmj caml_hash.cmi caml_nativeint.cmj bs_obj.cmj
4041
caml_hash_primitive.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe caml_int32.cmj caml_hash_primitive.cmi caml_nativeint.cmj caml_char.cmj bs_string.cmj
4142
caml_int32.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe caml_builtin_exceptions.cmj caml_int32.cmi caml_nativeint.cmj
42-
caml_int64.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe caml_int32.cmj caml_utils.cmj caml_primitive.cmj caml_builtin_exceptions.cmj caml_int64.cmi caml_nativeint.cmj caml_float.cmj caml_char.cmj bs_string.cmj
43-
caml_io.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe curry.cmj caml_builtin_exceptions.cmj bs_string.cmj
43+
caml_int32_extern.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe
44+
caml_int64.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe caml_int32.cmj caml_utils.cmj caml_primitive.cmj caml_builtin_exceptions.cmj caml_int64.cmi caml_nativeint.cmj caml_float_extern.cmj caml_float.cmj caml_char.cmj bs_string.cmj
45+
caml_int64_extern.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe
46+
caml_io.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe curry.cmj caml_builtin_exceptions.cmj caml_undefined_extern.cmj bs_string.cmj
4447
caml_js_exceptions.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe js_primitive.cmj caml_exceptions.cmj bs_obj.cmj
4548
caml_lexer.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe caml_builtin_exceptions.cmj caml_lexer.cmi
46-
caml_md5.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe caml_char.cmj caml_array.cmj bs_string.cmj caml_md5.cmi
49+
caml_md5.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe caml_int32_extern.cmj caml_char.cmj caml_array.cmj bs_string.cmj caml_md5.cmi
4750
caml_missing_polyfill.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe caml_missing_polyfill.cmi
4851
caml_module.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe caml_obj.cmj caml_builtin_exceptions.cmj caml_array.cmj bs_obj.cmj
4952
caml_nativeint.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe
@@ -54,13 +57,14 @@ caml_parser.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe bs_obj.cmj
5457
caml_primitive.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe caml_bytes.cmj caml_primitive.cmi
5558
caml_queue.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe caml_queue.cmi
5659
caml_string.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe caml_builtin_exceptions.cmj caml_string.cmi caml_char.cmj bs_string.cmj
57-
caml_sys.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe caml_builtin_exceptions.cmj caml_sys.cmi caml_nativeint.cmj caml_array.cmj
60+
caml_sys.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe caml_builtin_exceptions.cmj caml_sys.cmi caml_undefined_extern.cmj caml_nativeint.cmj caml_array.cmj
61+
caml_undefined_extern.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe
5862
caml_utils.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe caml_utils.cmi
59-
caml_weak.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe caml_obj.cmj caml_array.cmj js_primitive.cmj caml_weak.cmi bs_obj.cmj
63+
caml_weak.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe caml_obj.cmj caml_array.cmj js_primitive.cmj caml_weak.cmi caml_undefined_extern.cmj bs_obj.cmj
6064
curry.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe caml_array.cmj
6165
js_int64.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe
6266
js_nativeint.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe
63-
js_primitive.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe bs_obj.cmj js_primitive.cmi
64-
all : block.cmi caml_array.cmi caml_basic.cmi caml_builtin_exceptions.cmi caml_bytes.cmi caml_exceptions.cmi caml_float.cmi caml_format.cmi caml_gc.cmi caml_hash.cmi caml_hash_primitive.cmi caml_int32.cmi caml_int64.cmi caml_lexer.cmi caml_md5.cmi caml_missing_polyfill.cmi caml_obj.cmi caml_oo.cmi caml_parser.cmi caml_primitive.cmi caml_queue.cmi caml_string.cmi caml_sys.cmi caml_utils.cmi caml_weak.cmi js_primitive.cmi block.cmj bs_obj.cmj bs_string.cmj caml_array.cmj caml_basic.cmj caml_builtin_exceptions.cmj caml_bytes.cmj caml_char.cmj caml_exceptions.cmj caml_float.cmj caml_format.cmj caml_gc.cmj caml_hash.cmj caml_hash_primitive.cmj caml_int32.cmj caml_int64.cmj caml_io.cmj caml_js_exceptions.cmj caml_lexer.cmj caml_md5.cmj caml_missing_polyfill.cmj caml_module.cmj caml_nativeint.cmj caml_obj.cmj caml_oo.cmj caml_oo_curry.cmj caml_parser.cmj caml_primitive.cmj caml_queue.cmj caml_string.cmj caml_sys.cmj caml_utils.cmj caml_weak.cmj curry.cmj js_int64.cmj js_nativeint.cmj js_primitive.cmj js.cmj js.cmi
67+
js_primitive.cmj : js.cmj js.cmi bs_stdlib_mini.cmi ../../lib/bsc.exe caml_undefined_extern.cmj bs_obj.cmj js_primitive.cmi
68+
all : block.cmi caml_array.cmi caml_basic.cmi caml_builtin_exceptions.cmi caml_bytes.cmi caml_exceptions.cmi caml_float.cmi caml_format.cmi caml_gc.cmi caml_hash.cmi caml_hash_primitive.cmi caml_int32.cmi caml_int64.cmi caml_lexer.cmi caml_md5.cmi caml_missing_polyfill.cmi caml_obj.cmi caml_oo.cmi caml_parser.cmi caml_primitive.cmi caml_queue.cmi caml_string.cmi caml_sys.cmi caml_utils.cmi caml_weak.cmi js_primitive.cmi block.cmj bs_obj.cmj bs_string.cmj caml_array.cmj caml_basic.cmj caml_builtin_exceptions.cmj caml_bytes.cmj caml_char.cmj caml_exceptions.cmj caml_float.cmj caml_float_extern.cmj caml_format.cmj caml_gc.cmj caml_hash.cmj caml_hash_primitive.cmj caml_int32.cmj caml_int32_extern.cmj caml_int64.cmj caml_int64_extern.cmj caml_io.cmj caml_js_exceptions.cmj caml_lexer.cmj caml_md5.cmj caml_missing_polyfill.cmj caml_module.cmj caml_nativeint.cmj caml_obj.cmj caml_oo.cmj caml_oo_curry.cmj caml_parser.cmj caml_primitive.cmj caml_queue.cmj caml_string.cmj caml_sys.cmj caml_undefined_extern.cmj caml_utils.cmj caml_weak.cmj curry.cmj js_int64.cmj js_nativeint.cmj js_primitive.cmj js.cmj js.cmi
6569
js.cmj : ../../lib/bsc.exe js.cmi
6670
js.cmi : ../../lib/bsc.exe bs_stdlib_mini.cmi

‎jscomp/runtime/bs_stdlib_mini.mli

-47
Original file line numberDiff line numberDiff line change
@@ -69,51 +69,4 @@ module Pervasives : sig
6969
external ( = ) : 'a -> 'a -> bool = "%equal"
7070
end
7171

72-
module Int32 : sig
73-
external to_int : int32 -> int = "%int32_to_int"
74-
external add : int32 -> int32 -> int32 = "%int32_add"
75-
external shift_left : int32 -> int -> int32 = "%int32_lsl"
76-
external shift_right_logical : int32 -> int -> int32 = "%int32_lsr"
77-
external shift_right : int32 -> int -> int32 = "%int32_asr"
78-
external logand : int32 -> int32 -> int32 = "%int32_and"
79-
external logxor : int32 -> int32 -> int32 = "%int32_xor"
80-
external logor : int32 -> int32 -> int32 = "%int32_or"
81-
external of_int : int -> int32 = "%int32_of_int"
82-
external mul : int32 -> int32 -> int32 = "%int32_mul"
83-
end
84-
85-
86-
87-
module Int64 : sig
88-
external of_int : int -> int64 = "%int64_of_int"
89-
external of_nativeint : nativeint -> int64 = "%int64_of_nativeint"
90-
external add : int64 -> int64 -> int64 = "%int64_add"
91-
external sub : int64 -> int64 -> int64 = "%int64_sub"
92-
external mul : int64 -> int64 -> int64 = "%int64_mul"
93-
external div : int64 -> int64 -> int64 = "%int64_div"
94-
external logor : int64 -> int64 -> int64 = "%int64_or"
95-
external neg : int64 -> int64 = "%int64_neg"
96-
external to_int : int64 -> int = "%int64_to_int"
97-
end
98-
99-
100-
101-
102-
103-
(* We should give it a name like FloatRT to avoid occasional shadowing *)
104-
module FloatRT : sig
105-
external _NaN : float = "NaN" [@@bs.val]
106-
external isNaN : float -> bool = "" [@@bs.val]
107-
external isFinite : float -> bool = "" [@@bs.val]
108-
external toExponentialWithPrecision : float -> digits:int -> string = "toExponential" [@@bs.send]
109-
external toFixed : float -> string = "" [@@bs.send]
110-
external toFixedWithPrecision : float -> digits:int -> string = "toFixed" [@@bs.send]
111-
external fromString : string -> float = "Number" [@@bs.val]
112-
end
11372

114-
module UndefinedRT : sig
115-
type + 'a t
116-
external empty : 'a t = "#undefined"
117-
external return : 'a -> 'a t = "%identity"
118-
external toOption : 'a t -> 'a option = "#undefined_to_opt"
119-
end

‎jscomp/runtime/caml_basic.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ let some x = Some x
3333
let is_none x : bool =
3434
x = None
3535

36-
let to_def x : _ UndefinedRT.t =
36+
let to_def x : _ Caml_undefined_extern.t =
3737
match x with
38-
| None -> UndefinedRT.empty
39-
| Some x -> UndefinedRT.return x
38+
| None -> Caml_undefined_extern.empty
39+
| Some x -> Caml_undefined_extern.return x
4040

4141
(* In the next version of std, we already provide
4242
[List.cons]

‎jscomp/runtime/caml_basic.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828
val none : 'a option
2929
val some : 'a -> 'a option
3030
val is_none : 'a option -> bool
31-
val to_def : 'a option -> 'a UndefinedRT.t
31+
val to_def : 'a option -> 'a Caml_undefined_extern.t
3232
val cons : 'a -> 'a list -> 'a list
3333
val is_list_empty : 'a list -> bool

‎jscomp/runtime/caml_float.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ let caml_int32_bits_of_float : float -> int32 = fun%raw x -> {|
5454

5555

5656
let caml_modf_float (x : float) : float * float =
57-
if FloatRT.isFinite x then
57+
if Caml_float_extern.isFinite x then
5858
let neg = 1. /. x < 0. in
5959
let x = abs_float x in
6060
let i = floor x in
6161
let f = x -. i in
6262
if neg then
6363
-. f, -. i
6464
else f, i
65-
else if FloatRT.isNaN x then FloatRT._NaN, FloatRT._NaN
65+
else if Caml_float_extern.isNaN x then Caml_float_extern._NaN, Caml_float_extern._NaN
6666
else (1. /. x , x)
6767

6868
let caml_ldexp_float (x: float) (exp: int) : float =
@@ -83,7 +83,7 @@ let caml_ldexp_float (x: float) (exp: int) : float =
8383

8484

8585
let caml_frexp_float (x: float): float * int =
86-
if x = 0. || not (FloatRT.isFinite x) then
86+
if x = 0. || not (Caml_float_extern.isFinite x) then
8787
(x, 0)
8888
else begin
8989
let neg = x < 0. in

‎jscomp/runtime/caml_float_extern.ml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
external _NaN : float = "NaN" [@@bs.val]
2+
external isNaN : float -> bool = "" [@@bs.val]
3+
external isFinite : float -> bool = "" [@@bs.val]
4+
external toExponentialWithPrecision : float -> digits:int -> string = "toExponential" [@@bs.send]
5+
external toFixed : float -> string = "" [@@bs.send]
6+
external toFixedWithPrecision : float -> digits:int -> string = "toFixed" [@@bs.send]
7+
external fromString : string -> float = "Number" [@@bs.val]

‎jscomp/runtime/caml_format.ml

+28-28
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ let caml_int_of_string s =
126126
let caml_int64_of_string s =
127127
let module String = Bs_string in
128128
let i, sign, hbase = parse_sign_and_base s in
129-
let base = Int64.of_int (int_of_string_base hbase) in
130-
let sign = Int64.of_nativeint sign in
129+
let base = Caml_int64_extern.of_int (int_of_string_base hbase) in
130+
let sign = Caml_int64_extern.of_nativeint sign in
131131
let threshold =
132132
match hbase with
133133
| Hex -> (* 2 ^ 64 - 1 / 16*)
@@ -141,28 +141,28 @@ let caml_int64_of_string s =
141141
in
142142
let len =Bs_string.length s in
143143
let c = if i < len then s.[i] else '\000' in
144-
let d = Int64.of_int (parse_digit c) in
144+
let d = Caml_int64_extern.of_int (parse_digit c) in
145145
let () =
146146
if d < 0L || d >= base then
147147
caml_failwith "int64_of_string" in
148-
let (+~) = Int64.add in
149-
let ( *~ ) = Int64.mul in
148+
let (+~) = Caml_int64_extern.add in
149+
let ( *~ ) = Caml_int64_extern.mul in
150150

151151
let rec aux acc k =
152152
if k = len then acc
153153
else
154154
let a = s.[k] in
155155
if a = '_' then aux acc ( k + 1)
156156
else
157-
let v = Int64.of_int (parse_digit a) in
157+
let v = Caml_int64_extern.of_int (parse_digit a) in
158158
if v < 0L || v >= base || acc > threshold then
159159
caml_failwith "int64_of_string"
160160
else
161161
let acc = base *~ acc +~ v in
162162
aux acc ( k + 1)
163163
in
164164
let res = sign *~ aux d (i + 1) in
165-
let or_res = Int64.logor res 0L in
165+
let or_res = Caml_int64_extern.logor res 0L in
166166
(if base = 10L && res <> or_res then
167167
caml_failwith "int64_of_string");
168168
or_res
@@ -384,7 +384,7 @@ let caml_int64_format fmt x =
384384
if f.signedconv && x < 0L then
385385
begin
386386
f.sign <- -1;
387-
Int64.neg x
387+
Caml_int64_extern.neg x
388388
end
389389
else x in
390390
let s = ref "" in
@@ -410,17 +410,17 @@ let caml_int64_format fmt x =
410410
let c, d = Js_int64.div_mod y wbase in
411411

412412
let quotient =
413-
ref (Int64.add quotient_l c ) in
413+
ref (Caml_int64_extern.add quotient_l c ) in
414414
let modulus = ref d in
415415
s :=
416416
Bs_string.of_char
417-
cvtbl.[ Int64.to_int !modulus] ^ !s ;
417+
cvtbl.[ Caml_int64_extern.to_int !modulus] ^ !s ;
418418

419419
while !quotient <> 0L do
420420
let a, b = Js_int64.div_mod (!quotient) wbase in
421421
quotient := a;
422422
modulus := b;
423-
s := Bs_string.of_char cvtbl.[Int64.to_int !modulus] ^ !s ;
423+
s := Bs_string.of_char cvtbl.[Caml_int64_extern.to_int !modulus] ^ !s ;
424424
done;
425425
end
426426
else
@@ -429,13 +429,13 @@ let caml_int64_format fmt x =
429429
let modulus = ref b in
430430
s :=
431431
Bs_string.of_char
432-
cvtbl.[ Int64.to_int !modulus] ^ !s ;
432+
cvtbl.[ Caml_int64_extern.to_int !modulus] ^ !s ;
433433

434434
while !quotient <> 0L do
435435
let a, b = Js_int64.div_mod (!quotient) wbase in
436436
quotient := a;
437437
modulus := b;
438-
s := Bs_string.of_char cvtbl.[Int64.to_int !modulus] ^ !s ;
438+
s := Bs_string.of_char cvtbl.[Caml_int64_extern.to_int !modulus] ^ !s ;
439439
done
440440

441441
| Dec ->
@@ -455,20 +455,20 @@ let caml_int64_format fmt x =
455455
we can not do the code above, it can overflow when y is really large
456456
*)
457457
let c, d = Js_int64.div_mod y wbase in
458-
let e ,f = Js_int64.div_mod (Int64.add modulus_l d) wbase in
458+
let e ,f = Js_int64.div_mod (Caml_int64_extern.add modulus_l d) wbase in
459459
let quotient =
460-
ref (Int64.add (Int64.add quotient_l c )
460+
ref (Caml_int64_extern.add (Caml_int64_extern.add quotient_l c )
461461
e) in
462462
let modulus = ref f in
463463
s :=
464464
Bs_string.of_char
465-
cvtbl.[Int64.to_int !modulus] ^ !s ;
465+
cvtbl.[Caml_int64_extern.to_int !modulus] ^ !s ;
466466

467467
while !quotient <> 0L do
468468
let a, b = Js_int64.div_mod (!quotient) wbase in
469469
quotient := a;
470470
modulus := b;
471-
s := Bs_string.of_char cvtbl.[Int64.to_int !modulus] ^ !s ;
471+
s := Bs_string.of_char cvtbl.[Caml_int64_extern.to_int !modulus] ^ !s ;
472472
done;
473473

474474
else
@@ -477,13 +477,13 @@ let caml_int64_format fmt x =
477477
let modulus = ref b in
478478
s :=
479479
Bs_string.of_char
480-
cvtbl.[ Int64.to_int !modulus] ^ !s ;
480+
cvtbl.[ Caml_int64_extern.to_int !modulus] ^ !s ;
481481

482482
while !quotient <> 0L do
483483
let a, b = Js_int64.div_mod (!quotient) wbase in
484484
quotient := a;
485485
modulus := b;
486-
s := Bs_string.of_char cvtbl.[Int64.to_int !modulus] ^ !s ;
486+
s := Bs_string.of_char cvtbl.[Caml_int64_extern.to_int !modulus] ^ !s ;
487487
done;
488488
end;
489489
if f.prec >= 0 then
@@ -502,12 +502,12 @@ let caml_format_float fmt x =
502502
let prec = if f.prec < 0 then 6 else f.prec in
503503
let x = if x < 0. then (f.sign <- (-1); -. x) else x in
504504
let s = ref "" in
505-
if FloatRT.isNaN x then
505+
if Caml_float_extern.isNaN x then
506506
begin
507507
s := "nan";
508508
f.filter <- " "
509509
end
510-
else if not (FloatRT.isFinite x) then
510+
else if not (Caml_float_extern.isFinite x) then
511511
begin
512512
s := "inf";
513513
f.filter <- " "
@@ -517,7 +517,7 @@ let caml_format_float fmt x =
517517
match f.conv with
518518
| "e"
519519
->
520-
s := FloatRT.toExponentialWithPrecision x ~digits:prec;
520+
s := Caml_float_extern.toExponentialWithPrecision x ~digits:prec;
521521
(* exponent should be at least two digits
522522
{[
523523
(3.3).toExponential()
@@ -534,13 +534,13 @@ let caml_format_float fmt x =
534534
->
535535
(* this will not work large numbers *)
536536
(* ("%3.10f", 3e+56, "300000000000000005792779041490073052596128503513888063488.0000000000") *)
537-
s := FloatRT.toFixedWithPrecision x ~digits:prec
537+
s := Caml_float_extern.toFixedWithPrecision x ~digits:prec
538538
| "g" ->
539539
let prec = if prec <> 0 then prec else 1 in
540-
s := FloatRT.toExponentialWithPrecision x ~digits:(prec - 1);
540+
s := Caml_float_extern.toExponentialWithPrecision x ~digits:(prec - 1);
541541
let j = Bs_string.index_of !s "e" in
542-
let exp = Caml_float.int_of_float (FloatRT.fromString (Bs_string.slice_rest !s (j + 1))) in
543-
if exp < -4 || x >= 1e21 ||Bs_string.length (FloatRT.toFixed x) > prec then
542+
let exp = Caml_float.int_of_float (Caml_float_extern.fromString (Bs_string.slice_rest !s (j + 1))) in
543+
if exp < -4 || x >= 1e21 ||Bs_string.length (Caml_float_extern.toFixed x) > prec then
544544
let i = ref (j - 1) in
545545
while !s.[!i] = '0' do
546546
decr i
@@ -557,10 +557,10 @@ let caml_format_float fmt x =
557557
if exp < 0 then
558558
begin
559559
p := !p - (exp + 1);
560-
s := FloatRT.toFixedWithPrecision x ~digits:!p
560+
s := Caml_float_extern.toFixedWithPrecision x ~digits:!p
561561
end
562562
else
563-
while (s := FloatRT.toFixedWithPrecision x ~digits:!p;Bs_string.length !s > prec + 1) do
563+
while (s := Caml_float_extern.toFixedWithPrecision x ~digits:!p;Bs_string.length !s > prec + 1) do
564564
decr p
565565
done ;
566566
if !p <> 0 then

‎jscomp/runtime/caml_int32_extern.ml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
3+
external to_int : int32 -> int = "%int32_to_int"
4+
external add : int32 -> int32 -> int32 = "%int32_add"
5+
external shift_left : int32 -> int -> int32 = "%int32_lsl"
6+
external shift_right_logical : int32 -> int -> int32 = "%int32_lsr"
7+
external shift_right : int32 -> int -> int32 = "%int32_asr"
8+
external logand : int32 -> int32 -> int32 = "%int32_and"
9+
external logxor : int32 -> int32 -> int32 = "%int32_xor"
10+
external logor : int32 -> int32 -> int32 = "%int32_or"
11+
external of_int : int -> int32 = "%int32_of_int"
12+
external mul : int32 -> int32 -> int32 = "%int32_mul"

‎jscomp/runtime/caml_int64.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,8 @@ external mod_float : float -> float -> float = "caml_fmod_float"
291291

292292

293293
let rec of_float (x : float) : t =
294-
if FloatRT.isNaN x
295-
|| Pervasives.not (FloatRT.isFinite x ) then zero
294+
if Caml_float_extern.isNaN x
295+
|| Pervasives.not (Caml_float_extern.isFinite x ) then zero
296296
else if x <= neg_two_ptr_63 then
297297
min_int
298298
else if x +. 1. >= two_ptr_63_dbl then
@@ -436,7 +436,7 @@ let float_of_bits : t -> float = fun%raw x -> {|
436436
let bits_of_float : float -> t = fun x ->
437437
let buf = [%raw{|new Int32Array(new Float64Array([x]).buffer)|}] in
438438
mk ~lo:(fst buf) ~hi:(snd buf)
439-
(* let to_nat (x : int32) = x |> Int32.to_int |> Caml_nativeint.of_int in
439+
(* let to_nat (x : int32) = x |> Caml_int32_extern.to_int |> Caml_nativeint.of_int in
440440
441441
let u = Float64_array.make [| x |] in
442442
let int32 = Int32_array.fromBuffer (Float64_array.buffer u) in

‎jscomp/runtime/caml_int64_extern.ml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
external of_int : int -> int64 = "%int64_of_int"
2+
external of_nativeint : nativeint -> int64 = "%int64_of_nativeint"
3+
external add : int64 -> int64 -> int64 = "%int64_add"
4+
external sub : int64 -> int64 -> int64 = "%int64_sub"
5+
external mul : int64 -> int64 -> int64 = "%int64_mul"
6+
external div : int64 -> int64 -> int64 = "%int64_div"
7+
external logor : int64 -> int64 -> int64 = "%int64_or"
8+
external neg : int64 -> int64 = "%int64_neg"
9+
external to_int : int64 -> int = "%int64_to_int"

‎jscomp/runtime/caml_io.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
type in_channel
2828

2929

30-
let stderr = UndefinedRT.empty
30+
let stderr = Caml_undefined_extern.empty
3131

3232
type out_channel = {
3333
mutable buffer : string;

‎jscomp/runtime/caml_md5.ml

+19-19
Original file line numberDiff line numberDiff line change
@@ -28,33 +28,33 @@
2828

2929
(** *)
3030

31-
let (+~) = Int32.add
32-
let add32 = Int32.add
33-
let (<<) = Int32.shift_left
34-
let (>>>) = Int32.shift_right_logical
35-
let (>>) = Int32.shift_right
36-
let (&) = Int32.logand
37-
let (^) = Int32.logxor
38-
let lognot n = Int32.logxor n (-1l)
31+
let (+~) = Caml_int32_extern.add
32+
let add32 = Caml_int32_extern.add
33+
let (<<) = Caml_int32_extern.shift_left
34+
let (>>>) = Caml_int32_extern.shift_right_logical
35+
let (>>) = Caml_int32_extern.shift_right
36+
let (&) = Caml_int32_extern.logand
37+
let (^) = Caml_int32_extern.logxor
38+
let lognot n = Caml_int32_extern.logxor n (-1l)
3939
let cmn q a b x s t =
4040
let a = a +~ q +~ x +~ t in
41-
Int32.logor (a << s) (a >>> (32 - s)) +~ b
41+
Caml_int32_extern.logor (a << s) (a >>> (32 - s)) +~ b
4242

4343

4444
let f a b c d x s t =
45-
cmn (Int32.logor (b & c) (lognot b & d)) a b x s t
45+
cmn (Caml_int32_extern.logor (b & c) (lognot b & d)) a b x s t
4646

4747

4848
let g a b c d x s t =
49-
cmn (Int32.logor (b & d) (c & (lognot d))) a b x s t
49+
cmn (Caml_int32_extern.logor (b & d) (c & (lognot d))) a b x s t
5050

5151
;;
5252
let h a b c d x s t =
5353
cmn (b ^ c ^ d) a b x s t
5454
;;
5555

5656
let i a b c d x s t =
57-
cmn (c ^ (Int32.logor b (lognot d))) a b x s t
57+
cmn (c ^ (Caml_int32_extern.logor b (lognot d))) a b x s t
5858

5959

6060
let cycle (x : int32 array) (k : int32 array) =
@@ -177,10 +177,10 @@ let caml_md5_string s start len =
177177
for i = 1 to i_end do
178178
for j = 0 to 16 - 1 do
179179
let k = i * 64 - 64 + j * 4 in
180-
md5blk.(j) <- (Int32.of_int (Caml_char.code s.[k])) +~
181-
(Int32.of_int (Caml_char.code s.[k+1]) << 8 ) +~
182-
(Int32.of_int (Caml_char.code s.[k+2]) << 16 ) +~
183-
(Int32.of_int (Caml_char.code s.[k+3]) << 24 )
180+
md5blk.(j) <- (Caml_int32_extern.of_int (Caml_char.code s.[k])) +~
181+
(Caml_int32_extern.of_int (Caml_char.code s.[k+1]) << 8 ) +~
182+
(Caml_int32_extern.of_int (Caml_char.code s.[k+2]) << 16 ) +~
183+
(Caml_int32_extern.of_int (Caml_char.code s.[k+3]) << 24 )
184184
done ;
185185
cycle state md5blk
186186
done ;
@@ -192,18 +192,18 @@ let caml_md5_string s start len =
192192
let i_end =Bs_string.length s_tail - 1 in
193193
for i = 0 to i_end do
194194
md5blk.(i / 4 ) <-
195-
Int32.logor md5blk.(i / 4) (Int32.of_int (Caml_char.code s_tail.[i]) << ((i mod 4) lsl 3))
195+
Caml_int32_extern.logor md5blk.(i / 4) (Caml_int32_extern.of_int (Caml_char.code s_tail.[i]) << ((i mod 4) lsl 3))
196196
done ;
197197
let i = i_end + 1 in
198-
md5blk.(i / 4 ) <- Int32.logor md5blk.(i / 4 ) (0x80l << ((i mod 4) lsl 3)) ;
198+
md5blk.(i / 4 ) <- Caml_int32_extern.logor md5blk.(i / 4 ) (0x80l << ((i mod 4) lsl 3)) ;
199199
if i > 55 then
200200
begin
201201
cycle state md5blk;
202202
for i = 0 to 15 do
203203
md5blk.(i) <- 0l
204204
done
205205
end;
206-
md5blk.(14) <- Int32.mul (Int32.of_int n) 8l;
206+
md5blk.(14) <- Caml_int32_extern.mul (Caml_int32_extern.of_int n) 8l;
207207
cycle state md5blk;
208208
Bs_string.of_small_int32_array [|
209209
state.(0) & 0xffl;

‎jscomp/runtime/caml_sys.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
external getEnv : 'a -> string -> string option = "" [@@bs.get_index]
3030
let caml_sys_getenv s =
3131
if Js.typeof [%raw{|process|}] = "undefined"
32-
|| [%raw{|process.env|}] = UndefinedRT.empty
32+
|| [%raw{|process.env|}] = Caml_undefined_extern.empty
3333
then raise Not_found
3434
else
3535
match getEnv [%raw{|process.env|}] s with
@@ -51,7 +51,7 @@ external exit : process -> int -> 'a = "" [@@bs.send]
5151

5252
let caml_sys_time () =
5353
if Js.typeof [%raw{|process|}] = "undefined"
54-
|| [%raw{|process.uptime|}] = UndefinedRT.empty
54+
|| [%raw{|process.uptime|}] = Caml_undefined_extern.empty
5555
then -1.
5656
else uptime [%raw{|process|}] ()
5757

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
type + 'a t
2+
external empty : 'a t = "#undefined"
3+
external return : 'a -> 'a t = "%identity"
4+
external toOption : 'a t -> 'a option = "#undefined_to_opt"

‎jscomp/runtime/caml_weak.ml

+5-5
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,27 @@
2828

2929
(** *)
3030

31-
type 'a t = 'a UndefinedRT.t array
31+
type 'a t = 'a Caml_undefined_extern.t array
3232

3333
let caml_weak_create n =
3434
Caml_array.new_uninitialized n
3535

3636
let caml_weak_set xs i v =
3737
match v with
3838
| Some x ->
39-
Caml_array.unsafe_set xs i (UndefinedRT.return x)
39+
Caml_array.unsafe_set xs i (Caml_undefined_extern.return x)
4040
| None -> ()
4141

4242
let caml_weak_get xs i =
43-
UndefinedRT.toOption
43+
Caml_undefined_extern.toOption
4444
(Caml_array.unsafe_get xs i)
4545

4646
let caml_weak_get_copy xs i =
47-
match UndefinedRT.toOption (Caml_array.unsafe_get xs i) with
47+
match Caml_undefined_extern.toOption (Caml_array.unsafe_get xs i) with
4848
| None -> None
4949
| Some x -> Some (Obj.magic (Caml_obj.caml_obj_dup (Bs_obj.repr x) ))
5050

5151
let caml_weak_check xs i =
52-
Caml_array.unsafe_get xs i <> UndefinedRT.empty
52+
Caml_array.unsafe_get xs i <> Caml_undefined_extern.empty
5353

5454
let caml_weak_blit = Caml_array.caml_array_blit

‎jscomp/runtime/js_primitive.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ let valFromOption (x : Bs_obj.t) : Bs_obj.t =
6969

7070

7171
let option_get (x : 'a option) =
72-
if x = None then UndefinedRT.empty
72+
if x = None then Caml_undefined_extern.empty
7373
else Obj.magic (valFromOption (Bs_obj.repr x))
7474

7575

7676
(** [input] is optional polymorphic variant *)
7777
let option_get_unwrap (x : 'a option) =
78-
if x = None then UndefinedRT.empty
78+
if x = None then Caml_undefined_extern.empty
7979
else Obj.magic (Bs_obj.field (Bs_obj.repr (valFromOption (Bs_obj.repr x))) 1 )
8080

‎jscomp/runtime/js_primitive.mli

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ val valFromOption : Bs_obj.t -> Bs_obj.t
3333

3434
val some : Bs_obj.t -> Bs_obj.t
3535

36-
val option_get : Bs_obj.t option -> Bs_obj.t UndefinedRT.t
36+
val option_get : Bs_obj.t option -> Bs_obj.t Caml_undefined_extern.t
3737

38-
val option_get_unwrap : 'a option -> Bs_obj.t UndefinedRT.t
38+
val option_get_unwrap : 'a option -> Bs_obj.t Caml_undefined_extern.t

‎lib/js/belt_internalSetBuckets.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,6 @@
33
var Curry = require("./curry.js");
44
var Belt_Array = require("./belt_Array.js");
55

6-
function copyBucket(c) {
7-
if (c !== undefined) {
8-
var head = {
9-
key: c.key,
10-
next: undefined
11-
};
12-
copyAuxCont(c.next, head);
13-
return head;
14-
} else {
15-
return c;
16-
}
17-
}
18-
196
function copyAuxCont(_c, _prec) {
207
while(true) {
218
var prec = _prec;
@@ -35,6 +22,19 @@ function copyAuxCont(_c, _prec) {
3522
};
3623
}
3724

25+
function copyBucket(c) {
26+
if (c !== undefined) {
27+
var head = {
28+
key: c.key,
29+
next: undefined
30+
};
31+
copyAuxCont(c.next, head);
32+
return head;
33+
} else {
34+
return c;
35+
}
36+
}
37+
3838
function copyBuckets(buckets) {
3939
var len = buckets.length;
4040
var newBuckets = new Array(len);

‎lib/js/caml_float_extern.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */

‎lib/js/caml_int32_extern.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */

‎lib/js/caml_int64_extern.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */

‎lib/js/caml_parser.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function caml_parse_engine (tables,env,cmd,arg){
8989
var env_stacksize = 4;
9090
var env_stackbase = 5;
9191
var env_curr_char = 6;
92-
var env_lval = 7; // Obj.t
92+
var env_lval = 7; // Bs_obj.t
9393
var env_symb_start = 8; // position
9494
var env_symb_end = 9; // position
9595
var env_asp = 10;

‎lib/js/caml_undefined_extern.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */

0 commit comments

Comments
 (0)
Please sign in to comment.