@@ -28,12 +28,12 @@ let print_if ppf flag printer arg =
28
28
29
29
30
30
31
- let after_parsing_sig ppf sourcefile outputprefix ast =
31
+ let after_parsing_sig ppf outputprefix ast =
32
32
if ! Js_config. binary_ast then
33
33
begin
34
34
Binary_ast. write_ast
35
35
Mli
36
- ~fname: sourcefile
36
+ ~sourcefile: ! Location. input_name
37
37
~output: (outputprefix ^ if ! Js_config. is_reason then Literals. suffix_reiast else Literals. suffix_mliast)
38
38
(* to support relocate to another directory *)
39
39
ast
@@ -46,7 +46,7 @@ let after_parsing_sig ppf sourcefile outputprefix ast =
46
46
47
47
if Js_config. get_diagnose () then
48
48
Format. fprintf Format. err_formatter " Building %s@." ! Location. input_name;
49
- let modulename = module_of_filename ppf sourcefile outputprefix in
49
+ let modulename = module_of_filename ppf ! Location. input_name outputprefix in
50
50
Lam_compile_env. reset () ;
51
51
let initial_env = Compmisc. initial_env () in
52
52
Env. set_unit_name modulename;
@@ -74,30 +74,28 @@ let after_parsing_sig ppf sourcefile outputprefix ast =
74
74
#else
75
75
let sg = Env. save_signature ?check_exists:(if ! Js_config. force_cmi then None else Some () ) sg modulename (outputprefix ^ " .cmi" ) in
76
76
#end
77
- Typemod. save_signature modulename tsg outputprefix sourcefile
77
+ Typemod. save_signature modulename tsg outputprefix ! Location. input_name
78
78
initial_env sg ;
79
79
end
80
80
end
81
81
let interface ppf sourcefile outputprefix =
82
- Js_config. set_current_file sourcefile ;
83
82
Compmisc. init_path false ;
84
83
Ocaml_parse. parse_interface ppf sourcefile
85
84
|> print_if ppf Clflags. dump_parsetree Printast. interface
86
85
|> print_if ppf Clflags. dump_source Pprintast. signature
87
- |> after_parsing_sig ppf sourcefile outputprefix
86
+ |> after_parsing_sig ppf outputprefix
88
87
89
- let interface_mliast ppf sourcefile outputprefix =
90
- Js_config. set_current_file sourcefile ;
88
+ let interface_mliast ppf fname outputprefix =
91
89
Compmisc. init_path false ;
92
- Binary_ast. read_ast Mli sourcefile
90
+ Binary_ast. read_ast Mli fname
93
91
|> print_if ppf Clflags. dump_parsetree Printast. interface
94
92
|> print_if ppf Clflags. dump_source Pprintast. signature
95
- |> after_parsing_sig ppf sourcefile outputprefix
93
+ |> after_parsing_sig ppf outputprefix
96
94
97
- let after_parsing_impl ppf sourcefile outputprefix ast =
95
+ let after_parsing_impl ppf outputprefix ast =
98
96
99
97
if ! Js_config. binary_ast then
100
- Binary_ast. write_ast ~fname: sourcefile
98
+ Binary_ast. write_ast ~sourcefile: ! Location. input_name
101
99
Ml ~output: (outputprefix ^
102
100
if ! Js_config. is_reason then Literals. suffix_reast else Literals. suffix_mlast
103
101
)
@@ -109,14 +107,14 @@ let after_parsing_impl ppf sourcefile outputprefix ast =
109
107
110
108
if Js_config. get_diagnose () then
111
109
Format. fprintf Format. err_formatter " Building %s@." ! Location. input_name;
112
- let modulename = Compenv. module_of_filename ppf sourcefile outputprefix in
110
+ let modulename = Compenv. module_of_filename ppf ! Location. input_name outputprefix in
113
111
Lam_compile_env. reset () ;
114
112
let env = Compmisc. initial_env() in
115
113
Env. set_unit_name modulename;
116
- try
114
+
117
115
let (typedtree, coercion, finalenv, current_signature) =
118
116
ast
119
- |> Typemod. type_implementation_more ?check_exists:(if ! Js_config. force_cmi then None else Some () ) sourcefile outputprefix modulename env
117
+ |> Typemod. type_implementation_more ?check_exists:(if ! Js_config. force_cmi then None else Some () ) ! Location. input_name outputprefix modulename env
120
118
|> print_if ppf Clflags. dump_typedtree
121
119
(fun fmt (ty ,co ,_ ,_ ) -> Printtyped. implementation_with_coercion fmt (ty,co))
122
120
in
@@ -134,46 +132,27 @@ let after_parsing_impl ppf sourcefile outputprefix ast =
134
132
#end
135
133
->
136
134
ignore (print_if ppf Clflags. dump_rawlambda Printlambda. lambda lambda);
137
- try
138
135
Lam_compile_main. lambda_as_module
139
136
finalenv
140
- outputprefix lambda with
141
- | e ->
142
- (* Save to a file instead so that it will not scare user *)
143
- (if Js_config. get_diagnose () then
144
- begin
145
- let file = " bsc.dump" in
146
- Ext_pervasives. with_file_as_chan file
147
- (fun ch -> output_string ch @@
148
- Printexc. raw_backtrace_to_string (Printexc. get_raw_backtrace () ));
149
- Ext_log. err __LOC__
150
- " Compilation fatal error, stacktrace saved into %s when compiling %s"
151
- file sourcefile;
152
- end ;
153
- raise e)
137
+ outputprefix lambda
154
138
);
155
139
156
140
end ;
157
141
Stypes. dump (Some (outputprefix ^ " .annot" ));
158
- with x ->
159
- Stypes. dump (Some (outputprefix ^ " .annot" ));
160
- raise x
161
142
end
162
143
let implementation ppf sourcefile outputprefix =
163
144
Compmisc. init_path false ;
164
- Js_config. set_current_file sourcefile ;
165
145
Ocaml_parse. parse_implementation ppf sourcefile
166
146
|> print_if ppf Clflags. dump_parsetree Printast. implementation
167
147
|> print_if ppf Clflags. dump_source Pprintast. structure
168
- |> after_parsing_impl ppf sourcefile outputprefix
148
+ |> after_parsing_impl ppf outputprefix
169
149
170
- let implementation_mlast ppf sourcefile outputprefix =
150
+ let implementation_mlast ppf fname outputprefix =
171
151
Compmisc. init_path false ;
172
- Js_config. set_current_file sourcefile ;
173
- Binary_ast. read_ast Ml sourcefile
152
+ Binary_ast. read_ast Ml fname
174
153
|> print_if ppf Clflags. dump_parsetree Printast. implementation
175
154
|> print_if ppf Clflags. dump_source Pprintast. structure
176
- |> after_parsing_impl ppf sourcefile outputprefix
155
+ |> after_parsing_impl ppf outputprefix
177
156
178
157
179
158
@@ -209,5 +188,5 @@ let implementation_map ppf sourcefile outputprefix =
209
188
ml_ast
210
189
|> print_if ppf Clflags. dump_parsetree Printast. implementation
211
190
|> print_if ppf Clflags. dump_source Pprintast. structure
212
- |> after_parsing_impl ppf sourcefile outputprefix
191
+ |> after_parsing_impl ppf outputprefix
213
192
0 commit comments