Skip to content

Commit

Permalink
remove Caml_sys completely
Browse files Browse the repository at this point in the history
  • Loading branch information
cometkim committed Aug 27, 2024
1 parent b45dbed commit 182df9c
Show file tree
Hide file tree
Showing 35 changed files with 40 additions and 1,318 deletions.
4 changes: 0 additions & 4 deletions jscomp/core/lam_compat.ml
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ let cmp_int (cmp : comparison) (a : int) b : bool =
| Cge -> a >= b

type compile_time_constant =
| Big_endian
| Ostype_unix
| Ostype_win32
| Ostype
| Backend_type

(** relies on the fact that [compile_time_constant] is enum type *)
Expand Down
4 changes: 0 additions & 4 deletions jscomp/core/lam_compat.mli
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ type boxed_integer = Lambda.boxed_integer = Pbigint | Pint32 | Pint64
type comparison = Lambda.comparison = Ceq | Cneq | Clt | Cgt | Cle | Cge

type compile_time_constant =
| Big_endian
| Ostype_unix
| Ostype_win32
| Ostype
| Backend_type

type let_kind = Lambda.let_kind = Strict | Alias | StrictOpt | Variable
Expand Down
15 changes: 0 additions & 15 deletions jscomp/core/lam_compile_primitive.ml
Original file line number Diff line number Diff line change
Expand Up @@ -372,21 +372,6 @@ let translate output_prefix loc (cxt : Lam_compile_context.t)
| Pis_poly_var_block -> E.is_type_object (Ext_list.singleton_exn args)
| Pctconst ct -> (
match ct with
| Big_endian -> E.bool Sys.big_endian
| Ostype -> E.runtime_call Js_runtime_modules.sys "os_type" args
| Ostype_unix ->
E.string_equal
(E.runtime_call Js_runtime_modules.sys "os_type" args)
(E.str "Unix")
| Ostype_win32 ->
E.string_equal
(E.runtime_call Js_runtime_modules.sys "os_type" args)
(E.str "Win32")
(* | Max_wosize ->
(* max_array_length*)
E.int 2147483647l (* 2 ^ 31 - 1 *) *)
(* 4_294_967_295l not representable*)
(* 2 ^ 32 - 1*)
| Backend_type ->
E.make_block E.zero_int_literal
(Blk_constructor { name = "Other"; num_nonconst = 1; tag = 0; attrs = [] })
Expand Down
6 changes: 0 additions & 6 deletions jscomp/core/lam_convert.ml
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,6 @@ let lam_prim ~primitive:(p : Lambda.primitive) ~args loc : Lam.t =
Lam.const (Const_int { i = 32l; comment = None })
| Max_wosize ->
Lam.const (Const_int { i = 2147483647l; comment = Some "Max_wosize" })
| Big_endian -> prim ~primitive:(Pctconst Big_endian) ~args loc
| Ostype_unix -> prim ~primitive:(Pctconst Ostype_unix) ~args loc
| Ostype_win32 -> prim ~primitive:(Pctconst Ostype_win32) ~args loc
| Ostype_cygwin -> Lam.false_
| Backend_type -> prim ~primitive:(Pctconst Backend_type) ~args loc)
| Pcvtbint (a, b) -> (
match (a, b) with
Expand Down Expand Up @@ -455,8 +451,6 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) :
(* ATT: Currently, the arity is one due to PPX *)
prim ~primitive:Pdebugger ~args:[] loc
| _ when s = "#null" -> Lam.const Const_js_null
| _ when s = "#os_type" ->
prim ~primitive:(Pctconst Ostype) ~args:[ unit ] loc
| _ when s = "#undefined" -> Lam.const (Const_js_undefined {is_unit = false})
| _ when s = "#init_mod" -> (
let args = Ext_list.map args convert_aux in
Expand Down
4 changes: 0 additions & 4 deletions jscomp/core/lam_dispatch_primitive.ml
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,6 @@ let translate loc (prim_name : string) (args : J.expression list) : J.expression
like normal one to set the identifier *)
| "?exn_slot_name" | "?is_extension" -> call Js_runtime_modules.exceptions
| "?as_js_exn" -> call Js_runtime_modules.caml_js_exceptions
| "?sys_get_argv" | "?sys_file_exists" | "?sys_time" | "?sys_getenv"
| "?sys_getcwd" (* check browser or nodejs *)
| "?sys_is_directory" | "?sys_exit" ->
call Js_runtime_modules.sys
| "?make_float_vect"
| "?floatarray_create" (* TODO: compile float array into TypedArray*) ->
E.runtime_call Js_runtime_modules.array "make_float" args
Expand Down
4 changes: 0 additions & 4 deletions jscomp/core/lam_print.ml
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,6 @@ let primitive ppf (prim : Lam_primitive.t) =
| Pctconst c ->
let const_name =
match c with
| Big_endian -> "big_endian"
| Ostype_unix -> "ostype_unix"
| Ostype_win32 -> "ostype_win32"
| Ostype -> "ostype"
| Backend_type -> "backend_type"
in
fprintf ppf "sys.constant_%s" const_name
Expand Down
4 changes: 0 additions & 4 deletions jscomp/ext/js_runtime_modules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@

let exceptions = "Caml_exceptions"

let io = "Caml_io"

let sys = "Caml_sys"

let obj_runtime = "Caml_obj"

let array = "Caml_array"
Expand Down
4 changes: 0 additions & 4 deletions jscomp/ml/lambda.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,9 @@


type compile_time_constant =
| Big_endian
| Word_size
| Int_size
| Max_wosize
| Ostype_unix
| Ostype_win32
| Ostype_cygwin
| Backend_type

type loc_kind =
Expand Down
4 changes: 0 additions & 4 deletions jscomp/ml/lambda.mli
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,9 @@
open Asttypes

type compile_time_constant =
| Big_endian
| Word_size
| Int_size
| Max_wosize
| Ostype_unix
| Ostype_win32
| Ostype_cygwin
| Backend_type

type loc_kind =
Expand Down
4 changes: 0 additions & 4 deletions jscomp/ml/printlambda.ml
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,9 @@ let primitive ppf = function
| Parraysets -> fprintf ppf "array.set"
| Pctconst c ->
let const_name = match c with
| Big_endian -> "big_endian"
| Word_size -> "word_size"
| Int_size -> "int_size"
| Max_wosize -> "max_wosize"
| Ostype_unix -> "ostype_unix"
| Ostype_win32 -> "ostype_win32"
| Ostype_cygwin -> "ostype_cygwin"
| Backend_type -> "backend_type" in
fprintf ppf "sys.constant_%s" const_name
| Pisint -> fprintf ppf "isint"
Expand Down
4 changes: 0 additions & 4 deletions jscomp/ml/translcore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -323,14 +323,10 @@ let primitives_table =
("%sequand", Psequand);
("%sequor", Psequor);
("%boolnot", Pnot);
("%big_endian", Pctconst Big_endian);
("%backend_type", Pctconst Backend_type);
("%word_size", Pctconst Word_size);
("%int_size", Pctconst Int_size);
("%max_wosize", Pctconst Max_wosize);
("%ostype_unix", Pctconst Ostype_unix);
("%ostype_win32", Pctconst Ostype_win32);
("%ostype_cygwin", Pctconst Ostype_cygwin);
("%negint", Pnegint);
("%succint", Poffsetint 1);
("%predint", Poffsetint (-1));
Expand Down
111 changes: 0 additions & 111 deletions jscomp/runtime/caml_sys.res

This file was deleted.

38 changes: 0 additions & 38 deletions jscomp/runtime/caml_sys.resi

This file was deleted.

4 changes: 1 addition & 3 deletions jscomp/runtime/release.ninja
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ o runtime/caml_splice_call.cmj : cc_cmi runtime/caml_splice_call.res | runtime/c
o runtime/caml_splice_call.cmi : cc runtime/caml_splice_call.resi | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
o runtime/caml_string.cmj : cc_cmi runtime/caml_string.res | runtime/caml_string.cmi runtime/caml_string_extern.cmj
o runtime/caml_string.cmi : cc runtime/caml_string.resi | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
o runtime/caml_sys.cmj : cc_cmi runtime/caml_sys.res | runtime/caml_array_extern.cmj runtime/caml_sys.cmi runtime/caml_undefined_extern.cmj
o runtime/caml_sys.cmi : cc runtime/caml_sys.resi | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
o runtime/caml_array_extern.cmi runtime/caml_array_extern.cmj : cc runtime/caml_array_extern.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
o runtime/caml_bigint_extern.cmi runtime/caml_bigint_extern.cmj : cc runtime/caml_bigint_extern.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
o runtime/caml_float_extern.cmi runtime/caml_float_extern.cmj : cc runtime/caml_float_extern.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
Expand All @@ -56,4 +54,4 @@ o runtime/caml_nativeint_extern.cmi runtime/caml_nativeint_extern.cmj : cc runti
o runtime/caml_string_extern.cmi runtime/caml_string_extern.cmj : cc runtime/caml_string_extern.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
o runtime/caml_undefined_extern.cmi runtime/caml_undefined_extern.cmj : cc runtime/caml_undefined_extern.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
o runtime/curry.cmi runtime/curry.cmj : cc runtime/curry.res | runtime/bs_stdlib_mini.cmi runtime/caml_array.cmj runtime/caml_array_extern.cmj runtime/js.cmi runtime/js.cmj
o runtime : phony runtime/bs_stdlib_mini.cmi runtime/js.cmj runtime/js.cmi runtime/caml.cmi runtime/caml.cmj runtime/caml_array.cmi runtime/caml_array.cmj runtime/caml_bigint.cmi runtime/caml_bigint.cmj runtime/caml_bytes.cmi runtime/caml_bytes.cmj runtime/caml_exceptions.cmi runtime/caml_exceptions.cmj runtime/caml_float.cmi runtime/caml_float.cmj runtime/caml_hash.cmi runtime/caml_hash.cmj runtime/caml_hash_primitive.cmi runtime/caml_hash_primitive.cmj runtime/caml_int32.cmi runtime/caml_int32.cmj runtime/caml_int64.cmi runtime/caml_int64.cmj runtime/caml_md5.cmi runtime/caml_md5.cmj runtime/caml_module.cmi runtime/caml_module.cmj runtime/caml_obj.cmi runtime/caml_obj.cmj runtime/caml_option.cmi runtime/caml_option.cmj runtime/caml_splice_call.cmi runtime/caml_splice_call.cmj runtime/caml_string.cmi runtime/caml_string.cmj runtime/caml_sys.cmi runtime/caml_sys.cmj runtime/caml_array_extern.cmi runtime/caml_array_extern.cmj runtime/caml_bigint_extern.cmi runtime/caml_bigint_extern.cmj runtime/caml_float_extern.cmi runtime/caml_float_extern.cmj runtime/caml_int64_extern.cmi runtime/caml_int64_extern.cmj runtime/caml_js_exceptions.cmi runtime/caml_js_exceptions.cmj runtime/caml_nativeint_extern.cmi runtime/caml_nativeint_extern.cmj runtime/caml_string_extern.cmi runtime/caml_string_extern.cmj runtime/caml_undefined_extern.cmi runtime/caml_undefined_extern.cmj runtime/curry.cmi runtime/curry.cmj
o runtime : phony runtime/bs_stdlib_mini.cmi runtime/js.cmj runtime/js.cmi runtime/caml.cmi runtime/caml.cmj runtime/caml_array.cmi runtime/caml_array.cmj runtime/caml_bigint.cmi runtime/caml_bigint.cmj runtime/caml_bytes.cmi runtime/caml_bytes.cmj runtime/caml_exceptions.cmi runtime/caml_exceptions.cmj runtime/caml_float.cmi runtime/caml_float.cmj runtime/caml_hash.cmi runtime/caml_hash.cmj runtime/caml_hash_primitive.cmi runtime/caml_hash_primitive.cmj runtime/caml_int32.cmi runtime/caml_int32.cmj runtime/caml_int64.cmi runtime/caml_int64.cmj runtime/caml_md5.cmi runtime/caml_md5.cmj runtime/caml_module.cmi runtime/caml_module.cmj runtime/caml_obj.cmi runtime/caml_obj.cmj runtime/caml_option.cmi runtime/caml_option.cmj runtime/caml_splice_call.cmi runtime/caml_splice_call.cmj runtime/caml_string.cmi runtime/caml_string.cmj runtime/caml_array_extern.cmi runtime/caml_array_extern.cmj runtime/caml_bigint_extern.cmi runtime/caml_bigint_extern.cmj runtime/caml_float_extern.cmi runtime/caml_float_extern.cmj runtime/caml_int64_extern.cmi runtime/caml_int64_extern.cmj runtime/caml_js_exceptions.cmi runtime/caml_js_exceptions.cmj runtime/caml_nativeint_extern.cmi runtime/caml_nativeint_extern.cmj runtime/caml_string_extern.cmi runtime/caml_string_extern.cmj runtime/caml_undefined_extern.cmi runtime/caml_undefined_extern.cmj runtime/curry.cmi runtime/curry.cmj
22 changes: 0 additions & 22 deletions jscomp/stdlib-406/pervasives.res
Original file line number Diff line number Diff line change
Expand Up @@ -211,26 +211,4 @@ let rec \"@" = (l1, l2) =>

/* Miscellaneous */

external sys_exit: int => 'a = "?sys_exit"

let exit_function = ref(ignore)

let at_exit = f => {
let g = exit_function.contents
exit_function :=
(
() => {
f()
g()
}
)
}

let do_at_exit = () => exit_function.contents()

let exit = retcode => {
do_at_exit()
sys_exit(retcode)
}

type int32 = int
22 changes: 0 additions & 22 deletions jscomp/stdlib-406/pervasives.resi
Original file line number Diff line number Diff line change
Expand Up @@ -619,25 +619,3 @@ external incr: ref<int> => unit = "%incr"
/** Decrement the integer contained in the given reference.
Equivalent to [fun r -> r := pred !r]. */
external decr: ref<int> => unit = "%decr"

/* {1 Program termination} */

/** Terminate the process, returning the given status code
to the operating system: usually 0 to indicate no errors,
and a small positive integer to indicate failure.
All open output channels are flushed with [flush_all].
An implicit [exit 0] is performed each time a program
terminates normally. An implicit [exit 2] is performed if the program
terminates early because of an uncaught exception. */
let exit: int => 'a

/** Register the given function to be called at program termination
time. The functions registered with [at_exit] will be called when
the program does any of the following:
- executes {!Pervasives.exit}
- terminates, either normally or because of an uncaught
exception
- executes the C function [caml_shutdown].
The functions are called in 'last in, first out' order: the
function most recently added with [at_exit] is called first. */
let at_exit: (unit => unit) => unit
Loading

0 comments on commit 182df9c

Please sign in to comment.