@@ -22,10 +22,14 @@ let fprintf = Format.fprintf
2222
2323
2424
25- let print_if ppf flag printer arg =
25+ let print_if_pipe ppf flag printer arg =
2626 if ! flag then fprintf ppf " %a@." printer arg;
2727 arg
2828
29+ let print_if ppf flag printer arg =
30+ if ! flag then fprintf ppf " %a@." printer arg
31+
32+
2933
3034let process_with_gentype filename =
3135 match ! Clflags. bs_gentype with
@@ -103,15 +107,15 @@ let interface ppf fname outputprefix =
103107 Compmisc. init_path false ;
104108 Pparse. parse_interface ~tool_name: Js_config. tool_name ppf fname
105109 |> Ppx_entry. rewrite_signature
106- |> print_if ppf Clflags. dump_parsetree Printast. interface
107- |> print_if ppf Clflags. dump_source Pprintast. signature
110+ |> print_if_pipe ppf Clflags. dump_parsetree Printast. interface
111+ |> print_if_pipe ppf Clflags. dump_source Pprintast. signature
108112 |> after_parsing_sig ppf outputprefix
109113
110114let interface_mliast ppf fname outputprefix =
111115 Compmisc. init_path false ;
112116 Binary_ast. read_ast Mli fname
113- |> print_if ppf Clflags. dump_parsetree Printast. interface
114- |> print_if ppf Clflags. dump_source Pprintast. signature
117+ |> print_if_pipe ppf Clflags. dump_parsetree Printast. interface
118+ |> print_if_pipe ppf Clflags. dump_source Pprintast. signature
115119 |> after_parsing_sig ppf outputprefix
116120
117121
@@ -140,43 +144,41 @@ let after_parsing_impl ppf outputprefix ast =
140144 Lam_compile_env. reset () ;
141145 let env = Compmisc. initial_env() in
142146 Env. set_unit_name modulename;
143-
144147 let (typedtree, coercion, _, _) =
145- ast
146- |> Typemod. type_implementation_more ?check_exists:(if ! Js_config. force_cmi then None else Some () ) ! Location. input_name outputprefix modulename env
147- |> print_if ppf Clflags. dump_typedtree
148- (fun fmt (ty ,co ,_ ,_ ) -> Printtyped. implementation_with_coercion fmt (ty,co))
149- in
148+ Typemod. type_implementation_more
149+ ?check_exists:(if ! Js_config. force_cmi then None else Some () )
150+ ! Location. input_name outputprefix modulename env ast in
151+ let typedtree_coercion = (typedtree, coercion) in
152+ print_if ppf Clflags. dump_typedtree
153+ Printtyped. implementation_with_coercion typedtree_coercion ;
150154 if ! Clflags. print_types || ! Js_config. cmi_only then begin
151155 Warnings. check_fatal () ;
152156 end else begin
153- (typedtree, coercion)
154- |> Translmod. transl_implementation modulename
155- |> (fun lambda ->
156- let js_program =
157- print_if ppf Clflags. dump_rawlambda Printlambda. lambda (get_lambda lambda)
158- |> Lam_compile_main. compile outputprefix in
159- if not ! Js_config. cmj_only then
160- Lam_compile_main. lambda_as_module
161- js_program
162- outputprefix
163- );
157+ let lambda = Translmod. transl_implementation modulename typedtree_coercion in
158+ let js_program =
159+ print_if_pipe ppf Clflags. dump_rawlambda Printlambda. lambda (get_lambda lambda)
160+ |> Lam_compile_main. compile outputprefix in
161+ if not ! Js_config. cmj_only then
162+ Lam_compile_main. lambda_as_module
163+ js_program
164+ outputprefix
165+ ;
164166 end ;
165167 process_with_gentype (outputprefix ^ " .cmt" )
166168 end
167169let implementation ppf fname outputprefix =
168170 Compmisc. init_path false ;
169171 Pparse. parse_implementation ~tool_name: Js_config. tool_name ppf fname
170172 |> Ppx_entry. rewrite_implementation
171- |> print_if ppf Clflags. dump_parsetree Printast. implementation
172- |> print_if ppf Clflags. dump_source Pprintast. structure
173+ |> print_if_pipe ppf Clflags. dump_parsetree Printast. implementation
174+ |> print_if_pipe ppf Clflags. dump_source Pprintast. structure
173175 |> after_parsing_impl ppf outputprefix
174176
175177let implementation_mlast ppf fname outputprefix =
176178 Compmisc. init_path false ;
177179 Binary_ast. read_ast Ml fname
178- |> print_if ppf Clflags. dump_parsetree Printast. implementation
179- |> print_if ppf Clflags. dump_source Pprintast. structure
180+ |> print_if_pipe ppf Clflags. dump_parsetree Printast. implementation
181+ |> print_if_pipe ppf Clflags. dump_source Pprintast. structure
180182 |> after_parsing_impl ppf outputprefix
181183
182184
@@ -212,7 +214,7 @@ let implementation_map ppf sourcefile outputprefix =
212214 ) in
213215 Compmisc. init_path false ;
214216 ml_ast
215- |> print_if ppf Clflags. dump_parsetree Printast. implementation
216- |> print_if ppf Clflags. dump_source Pprintast. structure
217+ |> print_if_pipe ppf Clflags. dump_parsetree Printast. implementation
218+ |> print_if_pipe ppf Clflags. dump_source Pprintast. structure
217219 |> after_parsing_impl ppf outputprefix
218220
0 commit comments