toplevels: label the wrap_mod argument
parent
221fee0d85
commit
a30e621190
|
@ -449,7 +449,7 @@ let preprocess_phrase ppf phr =
|
|||
if !Clflags.dump_source then Pprintast.top_phrase ppf phr;
|
||||
phr
|
||||
|
||||
let use_channel ppf wrap_mod ic name filename =
|
||||
let use_channel ppf ~wrap_in_module ic name filename =
|
||||
let lb = Lexing.from_channel ic in
|
||||
Location.init lb filename;
|
||||
(* Skip initial #! line if any *)
|
||||
|
@ -461,7 +461,7 @@ let use_channel ppf wrap_mod ic name filename =
|
|||
(fun ph ->
|
||||
let ph = preprocess_phrase ppf ph in
|
||||
if not (execute_phrase !use_print_results ppf ph) then raise Exit)
|
||||
(if wrap_mod then
|
||||
(if wrap_in_module then
|
||||
parse_mod_use_file name lb
|
||||
else
|
||||
!parse_use_file lb);
|
||||
|
@ -485,27 +485,30 @@ let use_output ppf command =
|
|||
| 0 ->
|
||||
let ic = open_in_bin fn in
|
||||
Misc.try_finally ~always:(fun () -> close_in ic)
|
||||
(fun () -> use_channel ppf false ic "" "(command-output)")
|
||||
(fun () ->
|
||||
use_channel ppf ~wrap_in_module:false ic "" "(command-output)")
|
||||
| n ->
|
||||
fprintf ppf "Command exited with code %d.@." n;
|
||||
false)
|
||||
|
||||
let use_file ppf wrap_mod name =
|
||||
let use_file ppf ~wrap_in_module name =
|
||||
match name with
|
||||
| "" ->
|
||||
use_channel ppf wrap_mod stdin name "(stdin)"
|
||||
use_channel ppf ~wrap_in_module stdin name "(stdin)"
|
||||
| _ ->
|
||||
match Load_path.find name with
|
||||
| filename ->
|
||||
let ic = open_in_bin filename in
|
||||
Misc.try_finally ~always:(fun () -> close_in ic)
|
||||
(fun () -> use_channel ppf wrap_mod ic name filename)
|
||||
(fun () -> use_channel ppf ~wrap_in_module ic name filename)
|
||||
| exception Not_found ->
|
||||
fprintf ppf "Cannot find file %s.@." name;
|
||||
false
|
||||
|
||||
let mod_use_file ppf name = use_file ppf true name
|
||||
let use_file ppf name = use_file ppf false name
|
||||
let mod_use_file ppf name =
|
||||
use_file ppf ~wrap_in_module:true name
|
||||
let use_file ppf name =
|
||||
use_file ppf ~wrap_in_module:false name
|
||||
|
||||
let use_silently ppf name =
|
||||
protect_refs [ R (use_print_results, false) ] (fun () -> use_file ppf name)
|
||||
|
|
|
@ -394,7 +394,7 @@ let preprocess_phrase ppf phr =
|
|||
if !Clflags.dump_source then Pprintast.top_phrase ppf phr;
|
||||
phr
|
||||
|
||||
let use_channel ppf wrap_mod ic name filename =
|
||||
let use_channel ppf ~wrap_in_module ic name filename =
|
||||
let lb = Lexing.from_channel ic in
|
||||
Warnings.reset_fatal ();
|
||||
Location.init lb filename;
|
||||
|
@ -408,7 +408,7 @@ let use_channel ppf wrap_mod ic name filename =
|
|||
(fun ph ->
|
||||
let ph = preprocess_phrase ppf ph in
|
||||
if not (execute_phrase !use_print_results ppf ph) then raise Exit)
|
||||
(if wrap_mod then
|
||||
(if wrap_in_module then
|
||||
parse_mod_use_file name lb
|
||||
else
|
||||
!parse_use_file lb);
|
||||
|
@ -431,27 +431,30 @@ let use_output ppf command =
|
|||
| 0 ->
|
||||
let ic = open_in_bin fn in
|
||||
Misc.try_finally ~always:(fun () -> close_in ic)
|
||||
(fun () -> use_channel ppf false ic "" "(command-output)")
|
||||
(fun () ->
|
||||
use_channel ppf ~wrap_in_module:false ic "" "(command-output)")
|
||||
| n ->
|
||||
fprintf ppf "Command exited with code %d.@." n;
|
||||
false)
|
||||
|
||||
let use_file ppf wrap_mod name =
|
||||
let use_file ppf ~wrap_in_module name =
|
||||
match name with
|
||||
| "" ->
|
||||
use_channel ppf wrap_mod stdin name "(stdin)"
|
||||
use_channel ppf ~wrap_in_module stdin name "(stdin)"
|
||||
| _ ->
|
||||
match Load_path.find name with
|
||||
| filename ->
|
||||
let ic = open_in_bin filename in
|
||||
Misc.try_finally ~always:(fun () -> close_in ic)
|
||||
(fun () -> use_channel ppf wrap_mod ic name filename)
|
||||
(fun () -> use_channel ppf ~wrap_in_module ic name filename)
|
||||
| exception Not_found ->
|
||||
fprintf ppf "Cannot find file %s.@." name;
|
||||
false
|
||||
|
||||
let mod_use_file ppf name = use_file ppf true name
|
||||
let use_file ppf name = use_file ppf false name
|
||||
let mod_use_file ppf name =
|
||||
use_file ppf ~wrap_in_module:true name
|
||||
let use_file ppf name =
|
||||
use_file ppf ~wrap_in_module:false name
|
||||
|
||||
let use_silently ppf name =
|
||||
protect_refs [ R (use_print_results, false) ] (fun () -> use_file ppf name)
|
||||
|
|
Loading…
Reference in New Issue