git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@406 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Xavier Leroy 1995-11-06 11:09:33 +00:00
parent 9b594e281a
commit 038c717741
2 changed files with 31 additions and 14 deletions

View File

@ -127,6 +127,10 @@ O_TEXT Sys.Open_text";
# Initialize the table %conv
%conv = split(/\s+/, $convtbl);
# Parse options
$_ = $ARGV[0];
$keep_semisemi = 1, shift if /^-semi/;
# Open input.
$infile = $ARGV[0];
open(IN, $infile) || die("Cannot open $infile");
@ -181,8 +185,10 @@ close(IN);
sub convert {
chop;
# Double-semicolon
return if /^;;\s*$/;
s/;;//;
if (! $keep_semisemi) {
return if /^;;\s*$/;
s/;;//;
}
# Identifiers that have been renamed
s/([A-Za-z][A-Za-z0-9'_]*(__[A-Za-z][A-Za-z0-9'_]*)?)/$conv{$1} || $1/eg;
# 'type glop == tau'

View File

@ -18,6 +18,11 @@ open Format
open Clambda
open Compilenv
let print_digest d =
for i = 0 to String.length d - 1 do
print_string(Printf.sprintf "%02x" (Char.code d.[i]))
done
let rec print_approx = function
Value_closure(fundesc, approx) ->
open_hovbox 2;
@ -43,18 +48,19 @@ let rec print_approx = function
let print_name_crc (name, crc) =
print_space(); print_string name;
print_string " ("; print_int crc; print_string ")"
print_string " ("; print_digest crc; print_string ")"
let print_infos (ui, crc) =
print_string "Name: "; print_string ui.ui_name; print_newline();
print_string "CRC: "; print_int crc; print_newline();
print_string "CRC of implementation: "; print_digest crc; print_newline();
print_string "CRC of interface: "; print_digest ui.ui_interface; print_newline();
open_hovbox 2;
print_string "Interfaces imported:";
List.iter print_name_crc ui.ui_interfaces;
List.iter print_name_crc ui.ui_imports_cmi;
close_box(); print_newline();
open_hovbox 2;
print_string "Implementations imported:";
List.iter print_name_crc ui.ui_imports;
List.iter print_name_crc ui.ui_imports_cmx;
close_box(); print_newline();
open_hovbox 2;
print_string "Approximation:"; print_space(); print_approx ui.ui_approx;
@ -72,27 +78,32 @@ let print_infos (ui, crc) =
ui.ui_apply_fun;
close_box(); print_newline()
let read_unit_info filename =
let print_unit_info filename =
let ic = open_in_bin filename in
try
let buffer = String.create (String.length cmx_magic_number) in
really_input ic buffer 0 (String.length cmx_magic_number);
if buffer <> cmx_magic_number then begin
if buffer = cmx_magic_number then begin
let ui = (input_value ic : unit_infos) in
let crc = Digest.input ic in
close_in ic;
print_infos (ui, crc)
end else if buffer = cmxa_magic_number then begin
let info_crc_list = (input_value ic : (unit_infos * Digest.t) list) in
close_in ic;
List.iter print_infos info_crc_list
end else begin
close_in ic;
prerr_endline "Wrong magic number";
exit 2
end;
let ui = (input_value ic : unit_infos) in
let crc = input_binary_int ic in
close_in ic;
(ui, crc)
end
with End_of_file | Failure _ ->
close_in ic;
prerr_endline "Error reading file";
exit 2
let main () =
print_infos(read_unit_info Sys.argv.(1));
print_unit_info Sys.argv.(1);
exit 0
let _ = main ()