forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen_slots.ml
executable file
·38 lines (32 loc) · 1.16 KB
/
gen_slots.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#directory "+compiler-libs";;
#load "ocamlcommon.cma";;
#mod_use "../jscomp/type_int_to_string.ml"
let slots_of_stdlib_cmi filename : string list =
let info = Cmi_format.read_cmi (Filename.concat Config.standard_library filename) in
List.map (fun x -> Ident.name (Type_int_to_string.name_of_signature_item x)) @@
List.filter Type_int_to_string.serializable_signature info.cmi_sign
let code_of_array files =
let code =
List.map (fun file ->
let codes = slots_of_stdlib_cmi file in
Printf.sprintf "let %s = [| %s |]"
(Filename.chop_extension file )
(String.concat ";" (List.map (Printf.sprintf "%S") codes)) ) files in
String.concat "\n" code
(** Generate fixed slots
ATTENTION: we need re-run the code when we upgrade the compiler
We do this to avoid dependencies
*)
let _ =
Format.fprintf Format.std_formatter {|
(* Generated by scripts/gen_slots.ml, should be updated everytime when we upgrade the compiler *)
%s@.
|}
(code_of_array
["pervasives.cmi";
"camlinternalOO.cmi";
"camlinternalMod.cmi";
"string.cmi";
"array.cmi";
"list.cmi"
])