@@ -19,7 +19,13 @@ let output_prefix name =
19
19
| Some oname ->
20
20
Filename. remove_extension oname
21
21
22
-
22
+ let set_abs_input_name sourcefile =
23
+ let sourcefile =
24
+ if ! Location. absname && Filename. is_relative sourcefile then
25
+ Ext_path. absolute_cwd_path sourcefile
26
+ else sourcefile in
27
+ Location. set_input_name sourcefile;
28
+ sourcefile
23
29
24
30
25
31
let setup_error_printer (syntax_kind : [ `ml | `reason | `rescript ] )=
@@ -59,52 +65,68 @@ let handle_reason (type a) (kind : a Ml_binary.kind) sourcefile ppf opref =
59
65
ppf tmpfile opref ; );
60
66
Ast_reason_pp. clean tmpfile
61
67
62
-
68
+
63
69
64
70
let process_file sourcefile
65
71
?(kind ) ppf =
66
72
(* This is a better default then "", it will be changed later
67
73
The {!Location.input_name} relies on that we write the binary ast
68
74
properly
69
75
*)
70
- Location. set_input_name sourcefile;
71
- let opref = output_prefix sourcefile in
72
76
let kind =
73
77
match kind with
74
78
| None -> Ext_file_extensions. classify_input (Ext_filename. get_extension_maybe sourcefile)
75
79
| Some kind -> kind in
76
80
match kind with
77
- | Re -> handle_reason Ml sourcefile ppf opref
81
+ | Re ->
82
+ let sourcefile = set_abs_input_name sourcefile in
83
+ let opref = output_prefix sourcefile in
84
+ handle_reason Ml sourcefile ppf opref
78
85
| Rei ->
86
+ let sourcefile = set_abs_input_name sourcefile in
87
+ let opref = output_prefix sourcefile in
79
88
handle_reason Mli sourcefile ppf opref
80
89
| Ml ->
90
+ let sourcefile = set_abs_input_name sourcefile in
91
+ let opref = output_prefix sourcefile in
81
92
Js_implementation. implementation
82
93
~parser: Pparse_driver. parse_implementation
83
94
ppf sourcefile opref
84
95
| Mli ->
96
+ let sourcefile = set_abs_input_name sourcefile in
97
+ let opref = output_prefix sourcefile in
85
98
Js_implementation. interface
86
99
~parser: Pparse_driver. parse_interface
87
100
ppf sourcefile opref
88
101
| Res ->
102
+ let sourcefile = set_abs_input_name sourcefile in
103
+ let opref = output_prefix sourcefile in
89
104
setup_error_printer `rescript ;
90
105
Js_implementation. implementation
91
106
~parser: Res_driver. parse_implementation
92
107
ppf sourcefile opref
93
108
| Resi ->
109
+ let sourcefile = set_abs_input_name sourcefile in
110
+ let opref = output_prefix sourcefile in
94
111
setup_error_printer `rescript ;
95
112
Js_implementation. interface
96
113
~parser: Res_driver. parse_interface
97
114
ppf sourcefile opref
98
115
| Intf_ast
99
116
->
117
+ let opref = output_prefix sourcefile in
100
118
Js_implementation. interface_mliast ppf sourcefile opref
101
119
setup_error_printer ;
102
120
| Impl_ast
103
121
->
122
+ let opref = output_prefix sourcefile in
104
123
Js_implementation. implementation_mlast ppf sourcefile opref
105
124
setup_error_printer;
106
125
| Mlmap
107
- -> Js_implementation. implementation_map ppf sourcefile opref
126
+ ->
127
+ Location. set_input_name sourcefile;
128
+ let opref = output_prefix sourcefile in
129
+ Js_implementation. implementation_map ppf sourcefile opref
108
130
| Cmi
109
131
->
110
132
let cmi_sign = (Cmi_format. read_cmi sourcefile).cmi_sign in
0 commit comments