Skip to content

Commit 19d8e38

Browse files
authored
Merge pull request #4742 from rescript-lang/cleanup
fix #4718 and clean up
2 parents 3cd7da9 + fcf8315 commit 19d8e38

Some content is hidden

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

44 files changed

+18583
-18634
lines changed

jscomp/bsb/bsb_global_paths.ml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,3 @@ let vendor_bsdep =
6464

6565
;; assert (Sys.file_exists bsc_dir)
6666

67-
let ocaml_version = "4.06.1"
68-
69-
let ocaml_dir =
70-
Filename.(concat (concat (dirname bsc_dir) "native") ocaml_version)
71-
72-
let ocaml_lib_dir =
73-
Filename.(concat (concat ocaml_dir "lib") "ocaml")

jscomp/bsb/bsb_global_paths.mli

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,3 @@ val vendor_ninja : string
3333

3434
val vendor_bsdep : string
3535

36-
val ocaml_dir : string
37-
38-
val ocaml_lib_dir : string

jscomp/bsb/bsb_ninja_rule.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ let make_custom_rules
152152
in
153153
let mk_ast ~(has_pp : bool) ~has_ppx ~has_reason_react_jsx : string =
154154
Ext_buffer.clear buf ;
155-
Ext_buffer.add_string buf "$bsc $warnings";
155+
Ext_buffer.add_string buf "$bsc $warnings -bs-v ";
156+
Ext_buffer.add_string buf Bs_version.version;
156157
(match refmt with
157158
| None -> ()
158159
| Some x ->

jscomp/common/ml_binary.ml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ let read_ast (type t ) (kind : t kind) ic : t =
3636
| Mli -> Config.ast_intf_magic_number in
3737
let buffer = really_input_string ic (String.length magic) in
3838
assert(buffer = magic); (* already checked by apply_rewriter *)
39-
Location.set_input_name @@ input_value ic;
39+
Location.set_input_name (input_value ic);
4040
input_value ic
4141

4242
let write_ast (type t) (kind : t kind)
@@ -54,4 +54,14 @@ let magic_of_kind : type a . a kind -> string = function
5454
| Ml -> Config.ast_impl_magic_number
5555
| Mli -> Config.ast_intf_magic_number
5656

57-
57+
58+
let read_my_ast (type t ) (_ : t kind) ic : t =
59+
Location.set_input_name (input_line ic);
60+
input_value ic
61+
62+
let write_my_ast (type t) ( _ : t kind)
63+
(fname : string)
64+
(pt : t) oc =
65+
output_string oc fname;
66+
output_char oc '\n';
67+
output_value oc pt

jscomp/common/ml_binary.mli

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424

2525

2626

27+
(* This file was used to read reason ast
28+
and part of parsing binary ast
29+
*)
2730
type _ kind =
2831
| Ml : Parsetree.structure kind
2932
| Mli : Parsetree.signature kind
@@ -34,4 +37,16 @@ val read_ast : 'a kind -> in_channel -> 'a
3437
val write_ast :
3538
'a kind -> string -> 'a -> out_channel -> unit
3639

37-
val magic_of_kind : 'a kind -> string
40+
val magic_of_kind : 'a kind -> string
41+
42+
val read_my_ast :
43+
'a kind ->
44+
in_channel ->
45+
'a
46+
47+
val write_my_ast :
48+
'a kind ->
49+
string ->
50+
'a ->
51+
out_channel ->
52+
unit

jscomp/core/js_cmj_format.ml

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -72,47 +72,33 @@ let make
7272
}
7373

7474

75-
let verify_magic_in_beg ic =
76-
let buffer = really_input_string ic Ext_cmj_magic.cmj_magic_number_length in
77-
if buffer <> Ext_cmj_magic.cmj_magic_number then
78-
Ext_fmt.failwithf ~loc:__LOC__
79-
"cmj files have incompatible versions, please rebuilt using the new compiler : %s"
80-
__LOC__
8175

8276

8377
(* Serialization .. *)
8478
let from_file name : t =
8579
let ic = open_in_bin name in
86-
verify_magic_in_beg ic ;
8780
let _digest = Digest.input ic in
8881
let v : t = input_value ic in
8982
close_in ic ;
9083
v
9184

9285
let from_file_with_digest name : t * Digest.t =
9386
let ic = open_in_bin name in
94-
verify_magic_in_beg ic ;
9587
let digest = Digest.input ic in
9688
let v : t = input_value ic in
9789
close_in ic ;
9890
v,digest
9991

10092

10193
let from_string s : t =
102-
let magic_number = String.sub s 0 Ext_cmj_magic.cmj_magic_number_length in
103-
if magic_number = Ext_cmj_magic.cmj_magic_number then
104-
Marshal.from_string s Ext_cmj_magic.header_length
105-
else
106-
Ext_fmt.failwithf ~loc:__LOC__
107-
"cmj files have incompatible versions, please rebuilt using the new compiler : %s"
108-
__LOC__
94+
Marshal.from_string s Ext_digest.length
10995

11096

11197
let for_sure_not_changed (name : string) (header : string) =
11298
if Sys.file_exists name then
11399
let ic = open_in_bin name in
114100
let holder =
115-
really_input_string ic Ext_cmj_magic.header_length in
101+
really_input_string ic Ext_digest.length in
116102
close_in ic;
117103
holder = header
118104
else false
@@ -123,7 +109,7 @@ let for_sure_not_changed (name : string) (header : string) =
123109
let to_file name ~check_exists (v : t) =
124110
let s = Marshal.to_string v [] in
125111
let cur_digest = Digest.string s in
126-
let header = Ext_cmj_magic.cmj_magic_number ^ cur_digest in
112+
let header = cur_digest in
127113
if not (check_exists && for_sure_not_changed name header) then
128114
let oc = open_out_bin name in
129115
output_string oc header;

jscomp/depends/binary_ast.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ let read_ast (type t ) (kind : t Ml_binary.kind) fn : t =
3333
try
3434
let dep_size = input_binary_int ic in
3535
seek_in ic (pos_in ic + dep_size) ;
36-
let ast = Ml_binary.read_ast kind ic in
36+
let ast = Ml_binary.read_my_ast kind ic in
3737
close_in ic;
3838
ast
3939
with exn ->
@@ -59,6 +59,6 @@ let write_ast (type t) ~(sourcefile : string) ~output (kind : t Ml_binary.kind)
5959
) output_set ;
6060
output_binary_int oc (Ext_buffer.length buf);
6161
Ext_buffer.output_buffer oc buf;
62-
Ml_binary.write_ast kind sourcefile pt oc;
62+
Ml_binary.write_my_ast kind sourcefile pt oc;
6363
close_out oc
6464

jscomp/ext/ext_cmj_magic.ml

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

jscomp/main/astdump_main.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
current Ast format (10/10/2020)
2+
3+
-- input_binary_int ic (size)
4+
module,
5+
module,
6+
...
7+
--- seek_in ic (pos_in ic + size)
8+
fname
9+
marshalled ast
10+
11+
12+
13+

jscomp/main/astdump_main.ml

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

0 commit comments

Comments
 (0)