https://github.com/charguer/ocaml
Raw File
Tip revision: c5e68e7af18edbb05ada1097d834183755bed602 authored by No author on 09 December 1998, 10:32:54 UTC
This commit was manufactured by cvs2svn to create tag 'ocaml201'.
Tip revision: c5e68e7
ocamlsize
#!/usr/local/bin/perl

foreach $f (@ARGV) {
  open(FILE, $f) || die("Cannot open $f");
  seek(FILE, -36, 2);
  $path_size = do read_int();
  $code_size = do read_int();
  $prim_size = do read_int();
  $data_size = do read_int();
  $symbol_size = do read_int();
  $debug_size = do read_int();
  read(FILE, $magic, 12);
  if ($path_size > 0) {
      seek(FILE, -($path_size + $code_size + $prim_size + $data_size +
                   $symbol_size + $debug_size + 36), 2);
      read(FILE, $path, $path_size);
  } else {
      $path = "(default runtime)\n";
  }
  print $f, ":\n" if ($#ARGV > 0);
  printf ("\tcode: %d    data: %d    symbols: %d    debug: %d\n",
          $code_size, $data_size, $symbol_size, $debug_size);
  printf ("\tmagic number: %s     runtime system: %s",
          $magic, $path);
  close(FILE);
}

sub read_int {
  read(FILE, $buff, 4) == 4 || die("Truncated bytecode file $f");
  @int = unpack("C4", $buff);
  return ($int[0] << 24) + ($int[1] << 16) + ($int[2] << 8) + $int[3];
}
back to top