Skip to content

Commit 62a6d24

Browse files
committedMay 20, 2020
clean up - keep runtime exposure minimal
1 parent f72f00d commit 62a6d24

25 files changed

+114
-130
lines changed
 

Diff for: ‎jscomp/main/builtin_cmi_datasets.ml

+7-9
Large diffs are not rendered by default.

Diff for: ‎jscomp/main/builtin_cmj_datasets.ml

+5-7
Large diffs are not rendered by default.

Diff for: ‎jscomp/runtime/block.ml

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

2828

2929

30-
type obj = Caml_obj_extern.t
30+
type obj = Obj.t
3131

3232
(* Note that when we introduce it in {!Js_dump}
3333
we need introduce dependency properly *)

Diff for: ‎jscomp/runtime/block.mli

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

2828

2929
(** *)
30-
type obj = Caml_obj_extern.t
30+
type obj = Obj.t
3131

3232
val __ : int -> obj -> obj
3333

Diff for: ‎jscomp/runtime/caml_chrome_debugger.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

2525

26-
type obj = Caml_obj_extern.t
26+
type obj = Obj.t
2727

2828
let setupChromeDebugger : unit -> unit [@bs]= [%raw{|
2929
function () {

Diff for: ‎jscomp/runtime/caml_chrome_debugger.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* along with this program; if not, write to the Free Software
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

25-
type obj = Caml_obj_extern.t
25+
type obj = Obj.t
2626

2727
val __ : int -> obj -> obj
2828

Diff for: ‎jscomp/runtime/caml_hash.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ external ( +~ ) : nativeint -> nativeint -> nativeint =
8080
"caml_int32_add"
8181

8282
(*ATTENTION: refer {!Oo.id} *)
83-
external oo_id : Caml_obj_extern.t -> int = "%field1"
83+
external oo_id : Obj.t -> int = "%field1"
8484

8585
open Caml_hash_primitive
8686

8787
let caml_hash (count : int) _limit (seed : nativeint)
88-
(obj : Caml_obj_extern.t) : nativeint =
88+
(obj : Obj.t) : nativeint =
8989
let hash = ref seed in
9090
if Js.typeof obj = "number" then
9191
begin

Diff for: ‎jscomp/runtime/caml_hash.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@
2626

2727

2828
(** *)
29-
val caml_hash : int -> 'a -> nativeint -> Caml_obj_extern.t -> nativeint
29+
val caml_hash : int -> 'a -> nativeint -> Obj.t -> nativeint

Diff for: ‎jscomp/runtime/caml_js_exceptions.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ exception Error of t
1616
This function has to be in this module Since
1717
[Error] is defined here
1818
*)
19-
let internalToOCamlException (e : Caml_obj_extern.t) =
19+
let internalToOCamlException (e : Obj.t) =
2020
if Caml_exceptions.caml_is_extension e then
2121
(Obj.magic e : exn)
2222
else Error (Any e)

Diff for: ‎jscomp/runtime/caml_module.ml

+5-5
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ type shape =
3333
| Lazy
3434
| Class
3535
| Module of (shape * string) array
36-
| Value of Caml_obj_extern.t
36+
| Value of Obj.t
3737
(* ATTENTION: check across versions *)
3838
module Array = Caml_array_extern
3939

40-
external set_field : Caml_obj_extern.t -> string -> Caml_obj_extern.t -> unit = ""
40+
external set_field : Obj.t -> string -> Obj.t -> unit = ""
4141
[@@bs.set_index]
4242

43-
external get_field : Caml_obj_extern.t -> string -> Caml_obj_extern.t = ""
43+
external get_field : Obj.t -> string -> Obj.t = ""
4444
[@@bs.get_index]
4545

4646
module type Empty = sig end
@@ -51,7 +51,7 @@ module type Empty = sig end
5151
*)
5252
let init_mod (loc : string * int * int) (shape : shape) =
5353
let undef_module _ = raise (Undefined_recursive_module loc) in
54-
let rec loop (shape : shape) (struct_ : Caml_obj_extern.t) idx =
54+
let rec loop (shape : shape) (struct_ : Obj.t) idx =
5555
match shape with
5656
| Function ->
5757
set_field struct_ idx (Obj.magic undef_module)
@@ -82,7 +82,7 @@ let init_mod (loc : string * int * int) (shape : shape) =
8282
(* Note the [shape] passed between [init_mod] and [update_mod] is always the same
8383
and we assume [module] is encoded as an array
8484
*)
85-
let update_mod (shape : shape) (o : Caml_obj_extern.t) (n : Caml_obj_extern.t) : unit =
85+
let update_mod (shape : shape) (o : Obj.t) (n : Obj.t) : unit =
8686
let rec aux (shape : shape) o n parent i =
8787
match shape with
8888
| Function

Diff for: ‎jscomp/runtime/caml_module.mli

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ type shape
55
val init_mod :
66
(string * int * int) ->
77
shape ->
8-
Caml_obj_extern.t
8+
Obj.t
99

1010
val update_mod:
1111
shape ->
12-
Caml_obj_extern.t ->
13-
Caml_obj_extern.t ->
12+
Obj.t ->
13+
Obj.t ->
1414
unit

Diff for: ‎jscomp/runtime/caml_obj.ml

+18-18
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@
2828

2929

3030

31-
type t = Caml_obj_extern.t
31+
type t = Obj.t
3232

3333
module O = struct
3434
external isArray : 'a -> bool = "Array.isArray" [@@bs.val]
3535
type key = string
36-
let for_in : (Caml_obj_extern.t -> (key -> unit) -> unit) =
36+
let for_in : (Obj.t -> (key -> unit) -> unit) =
3737
[%raw{|function(o,foo){
3838
for (var x in o) { foo(x) }}
3939
|}]
4040
external hasOwnProperty :
4141
t -> key -> bool = "hasOwnProperty" [@@bs.send]
42-
external get_value : Caml_obj_extern.t -> key -> Caml_obj_extern.t = ""[@@bs.get_index]
42+
external get_value : Obj.t -> key -> Obj.t = ""[@@bs.get_index]
4343

4444
end
4545

@@ -90,7 +90,7 @@ let caml_obj_block tag size =
9090
`caml_obj_dup` is a superset of `caml_array_dup`
9191
*)
9292

93-
let caml_obj_dup : Caml_obj_extern.t -> Caml_obj_extern.t = [%raw{|function(x){
93+
let caml_obj_dup : Obj.t -> Obj.t = [%raw{|function(x){
9494
if(Array.isArray(x)){
9595
var len = x.length
9696
var v = new Array(len)
@@ -155,7 +155,7 @@ let update_dummy : _ -> _ -> unit= [%raw{|function(x,y){
155155
The compare function can be used as the comparison function required by the [Set.Make] and [Map.Make] functors,
156156
as well as the [List.sort] and [Array.sort] functions.
157157
*)
158-
let rec caml_compare (a : Caml_obj_extern.t) (b : Caml_obj_extern.t) : int =
158+
let rec caml_compare (a : Obj.t) (b : Obj.t) : int =
159159
if a == b then 0 else
160160
(*front and formoest, we do not compare function values*)
161161
let a_type = Js.typeof a in
@@ -227,26 +227,26 @@ let rec caml_compare (a : Caml_obj_extern.t) (b : Caml_obj_extern.t) : int =
227227
aux_length_a_short a b 0 len_a
228228
else
229229
aux_length_b_short a b 0 len_b
230-
and aux_same_length (a : Caml_obj_extern.t) (b : Caml_obj_extern.t) i same_length =
230+
and aux_same_length (a : Obj.t) (b : Obj.t) i same_length =
231231
if i = same_length then
232232
0
233233
else
234234
let res = caml_compare (Obj.field a i) (Obj.field b i) in
235235
if res <> 0 then res
236236
else aux_same_length a b (i + 1) same_length
237-
and aux_length_a_short (a : Caml_obj_extern.t) (b : Caml_obj_extern.t) i short_length =
237+
and aux_length_a_short (a : Obj.t) (b : Obj.t) i short_length =
238238
if i = short_length then -1
239239
else
240240
let res = caml_compare (Obj.field a i) (Obj.field b i) in
241241
if res <> 0 then res
242242
else aux_length_a_short a b (i+1) short_length
243-
and aux_length_b_short (a : Caml_obj_extern.t) (b : Caml_obj_extern.t) i short_length =
243+
and aux_length_b_short (a : Obj.t) (b : Obj.t) i short_length =
244244
if i = short_length then 1
245245
else
246246
let res = caml_compare (Obj.field a i) (Obj.field b i) in
247247
if res <> 0 then res
248248
else aux_length_b_short a b (i+1) short_length
249-
and aux_obj_compare (a: Caml_obj_extern.t) (b: Caml_obj_extern.t) =
249+
and aux_obj_compare (a: Obj.t) (b: Obj.t) =
250250
let min_key_lhs = ref None in
251251
let min_key_rhs = ref None in
252252
let do_key (a, b, min_key) key =
@@ -268,13 +268,13 @@ and aux_obj_compare (a: Caml_obj_extern.t) (b: Caml_obj_extern.t) =
268268
| (Some x), (Some y) -> Pervasives.compare x y in
269269
res
270270

271-
type eq = Caml_obj_extern.t -> Caml_obj_extern.t -> bool
271+
type eq = Obj.t -> Obj.t -> bool
272272

273273

274274
(** It is easier to do equality check than comparision, since as long as its
275275
basic type is not the same, it will not equal
276276
*)
277-
let rec caml_equal (a : Caml_obj_extern.t) (b : Caml_obj_extern.t) : bool =
277+
let rec caml_equal (a : Obj.t) (b : Obj.t) : bool =
278278
(*front and formoest, we do not compare function values*)
279279
if a == b then true
280280
else
@@ -321,13 +321,13 @@ let rec caml_equal (a : Caml_obj_extern.t) (b : Caml_obj_extern.t) : bool =
321321
not (Js.unsafe_gt a b || Js.unsafe_lt a b)
322322
else aux_obj_equal a b
323323
else false
324-
and aux_equal_length (a : Caml_obj_extern.t) (b : Caml_obj_extern.t) i same_length =
324+
and aux_equal_length (a : Obj.t) (b : Obj.t) i same_length =
325325
if i = same_length then
326326
true
327327
else
328328
caml_equal (Obj.field a i) (Obj.field b i)
329329
&& aux_equal_length a b (i + 1) same_length
330-
and aux_obj_equal (a: Caml_obj_extern.t) (b: Caml_obj_extern.t) =
330+
and aux_obj_equal (a: Obj.t) (b: Obj.t) =
331331
let result = ref true in
332332
let do_key_a key =
333333
if not (O.hasOwnProperty b key)
@@ -340,17 +340,17 @@ and aux_obj_equal (a: Caml_obj_extern.t) (b: Caml_obj_extern.t) =
340340
if result.contents then O.for_in b do_key_b;
341341
result.contents
342342

343-
let caml_equal_null (x : Caml_obj_extern.t) (y : Caml_obj_extern.t Js.null) =
343+
let caml_equal_null (x : Obj.t) (y : Obj.t Js.null) =
344344
match Js.nullToOption y with
345345
| None -> x == (Obj.magic y)
346346
| Some y -> caml_equal x y
347347

348-
let caml_equal_undefined (x : Caml_obj_extern.t) (y : Caml_obj_extern.t Js.undefined) =
348+
let caml_equal_undefined (x : Obj.t) (y : Obj.t Js.undefined) =
349349
match Js.undefinedToOption y with
350350
| None -> x == (Obj.magic y)
351351
| Some y -> caml_equal x y
352352

353-
let caml_equal_nullable ( x: Caml_obj_extern.t) (y : Caml_obj_extern.t Js.nullable) =
353+
let caml_equal_nullable ( x: Obj.t) (y : Obj.t Js.nullable) =
354354
match Js.toOption y with
355355
| None -> x == (Obj.magic y)
356356
| Some y -> caml_equal x y
@@ -365,10 +365,10 @@ let caml_lessequal a b = caml_compare a b <= 0
365365

366366
let caml_lessthan a b = caml_compare a b < 0
367367

368-
let caml_min (x : Caml_obj_extern.t) y =
368+
let caml_min (x : Obj.t) y =
369369
if caml_compare x y <= 0 then x else y
370370

371-
let caml_max (x : Caml_obj_extern.t) y =
371+
let caml_max (x : Obj.t) y =
372372
if caml_compare x y >= 0 then x else y
373373

374374
let caml_obj_set_tag = Obj.set_tag

Diff for: ‎jscomp/runtime/caml_obj.mli

+10-10
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,25 @@
2626

2727

2828

29-
type t = Caml_obj_extern.t
29+
type t = Obj.t
3030

3131

32-
val caml_obj_block : int -> int -> Caml_obj_extern.t
33-
val caml_obj_dup : Caml_obj_extern.t -> Caml_obj_extern.t
32+
val caml_obj_block : int -> int -> Obj.t
33+
val caml_obj_dup : Obj.t -> Obj.t
3434

3535

36-
val update_dummy : Caml_obj_extern.t -> Caml_obj_extern.t -> unit
36+
val update_dummy : Obj.t -> Obj.t -> unit
3737

3838

39-
val caml_compare : Caml_obj_extern.t -> Caml_obj_extern.t -> int
39+
val caml_compare : Obj.t -> Obj.t -> int
4040

41-
type eq = Caml_obj_extern.t -> Caml_obj_extern.t -> bool
41+
type eq = Obj.t -> Obj.t -> bool
4242

4343
val caml_equal : eq
4444

45-
val caml_equal_null : Caml_obj_extern.t -> Caml_obj_extern.t Js.null -> bool
46-
val caml_equal_undefined : Caml_obj_extern.t -> Caml_obj_extern.t Js.undefined -> bool
47-
val caml_equal_nullable : Caml_obj_extern.t -> Caml_obj_extern.t Js.nullable -> bool
45+
val caml_equal_null : Obj.t -> Obj.t Js.null -> bool
46+
val caml_equal_undefined : Obj.t -> Obj.t Js.undefined -> bool
47+
val caml_equal_nullable : Obj.t -> Obj.t Js.nullable -> bool
4848

4949
val caml_notequal : eq
5050
val caml_greaterequal : eq
@@ -60,4 +60,4 @@ val caml_min :
6060
val caml_max :
6161
t -> t -> t
6262

63-
val caml_obj_set_tag : Caml_obj_extern.t -> int -> unit
63+
val caml_obj_set_tag : Obj.t -> int -> unit

Diff for: ‎jscomp/runtime/caml_option.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
let undefinedHeader = [| |]
2626

27-
let some ( x : Caml_obj_extern.t) : Caml_obj_extern.t =
27+
let some ( x : Obj.t) : Obj.t =
2828
if Obj.magic x = None then
2929
(let block = Obj.repr (undefinedHeader, 0) in
3030
Obj.set_tag block 256;
@@ -59,7 +59,7 @@ let null_to_opt (type t ) ( x : t Js.null) : t option =
5959

6060
(** The input is already of [Some] form, [x] is not None,
6161
make sure [x[0]] will not throw *)
62-
let valFromOption (x : Caml_obj_extern.t) : Caml_obj_extern.t =
62+
let valFromOption (x : Obj.t) : Obj.t =
6363
if x != Obj.repr Js.null && fst (Obj.magic x) == Obj.repr undefinedHeader
6464
then
6565
let depth : int = snd (Obj.magic x) in

Diff for: ‎jscomp/runtime/caml_option.mli

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ val undefined_to_opt : 'a Js.undefined -> 'a option
2929

3030
val null_to_opt : 'a Js.null -> 'a option
3131

32-
val valFromOption : Caml_obj_extern.t -> Caml_obj_extern.t
32+
val valFromOption : Obj.t -> Obj.t
3333

34-
val some : Caml_obj_extern.t -> Caml_obj_extern.t
34+
val some : Obj.t -> Obj.t
3535

36-
val option_get : Caml_obj_extern.t option -> Caml_obj_extern.t Caml_undefined_extern.t
36+
val option_get : Obj.t option -> Obj.t Caml_undefined_extern.t
3737

38-
val option_get_unwrap : 'a option -> Caml_obj_extern.t Caml_undefined_extern.t
38+
val option_get_unwrap : 'a option -> Obj.t Caml_undefined_extern.t

Diff for: ‎jscomp/runtime/caml_parser.ml

+7-7
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ var PARSER_TRACE = false;
9393
|}]
9494

9595
(**
96-
* external parse_engine : parse_tables -> parser_env -> parser_input -> Caml_obj_extern.t -> parser_output
96+
* external parse_engine : parse_tables -> parser_env -> parser_input -> Obj.t -> parser_output
9797
* parsing.ml
9898
*
9999
* type parse_tables = {
100-
* actions : (parser_env -> Caml_obj_extern.t) array
100+
* actions : (parser_env -> Obj.t) array
101101
* transl_const : int array;
102102
* transl_block : int array;
103103
* lhs : string;
@@ -117,13 +117,13 @@ var PARSER_TRACE = false;
117117
*
118118
* type parser_env =
119119
* { mutable s_stack : int array; (* States *)
120-
* mutable v_stack : Caml_obj_extern.t array; (* Semantic attributes *)
120+
* mutable v_stack : Obj.t array; (* Semantic attributes *)
121121
* mutable symb_start_stack : position array; (* Start positions *)
122122
* mutable symb_end_stack : position array; (* End positions *)
123123
* mutable stacksize : int; (* Size of the stacks *)
124124
* mutable stackbase : int; (* Base sp for current parse *)
125125
* mutable curr_char : int; (* Last token read *)
126-
* mutable lval : Caml_obj_extern.t; (* Its semantic attribute *)
126+
* mutable lval : Obj.t; (* Its semantic attribute *)
127127
* mutable symb_start : position; (* Start pos. of the current symbol*)
128128
* mutable symb_end : position; (* End pos. of the current symbol *)
129129
* mutable asp : int; (* The stack pointer for attributes *)
@@ -152,8 +152,8 @@ type parse_tables
152152
type parser_env
153153

154154

155-
let caml_parse_engine : parse_tables -> parser_env -> (*Parsing.parser_input *)Caml_obj_extern.t -> Caml_obj_extern.t -> Caml_obj_extern.t =
156-
[%raw{|function (tables /* parser_table */, env /* parser_env */, cmd /* parser_input*/, arg /* Caml_obj_extern.t*/) {
155+
let caml_parse_engine : parse_tables -> parser_env -> (*Parsing.parser_input *)Obj.t -> Obj.t -> Obj.t =
156+
[%raw{|function (tables /* parser_table */, env /* parser_env */, cmd /* parser_input*/, arg /* Obj.t*/) {
157157
var ERRCODE = 256;
158158
//var START = 0;
159159
//var TOKEN_READ = 1;
@@ -174,7 +174,7 @@ let caml_parse_engine : parse_tables -> parser_env -> (*Parsing.parser_input *)C
174174
var env_stacksize = 'stacksize';
175175
var env_stackbase = 'stackbase';
176176
var env_curr_char = 'curr_char';
177-
var env_lval = 'lval'; // Caml_obj_extern.t
177+
var env_lval = 'lval'; // Obj.t
178178
var env_symb_start = 'symb_start'; // position
179179
var env_symb_end = 'symb_end'; // position
180180
var env_asp = 'asp';

Diff for: ‎jscomp/runtime/caml_parser.mli

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ type parser_env
3131

3232
val caml_parse_engine :
3333
parse_tables -> parser_env ->
34-
Caml_obj_extern.t (* Parsing.parser_input *) -> Caml_obj_extern.t ->
35-
(* parser_output *) Caml_obj_extern.t
34+
Obj.t (* Parsing.parser_input *) -> Obj.t ->
35+
(* parser_output *) Obj.t
3636

3737

3838

Diff for: ‎jscomp/runtime/caml_splice_call.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* along with this program; if not, write to the Free Software
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

25-
type obj = Caml_obj_extern.t
25+
type obj = Obj.t
2626

2727
let spliceApply : obj -> obj -> obj = [%raw{|function(fn,args){
2828
var i, argLen;

0 commit comments

Comments
 (0)