https://github.com/charguer/ocaml
Raw File
Tip revision: 0251b8eed4ea5360802ea92b1bd804c212e10237 authored by No author on 29 October 1996, 14:58:38 UTC
This commit was manufactured by cvs2svn to create tag 'ocaml103'.
Tip revision: 0251b8e
ocamlsize
#!/usr/local/bin/perl

foreach $f (@ARGV) {
  open(FILE, $f) || die("Cannot open $f");
  seek(FILE, -28, 2);
  $code_size = do read_int();
  $data_size = do read_int();
  $symbol_size = do read_int();
  $debug_size = do read_int();
  read(FILE, $magic, 12);
  print $f, ":\n" if ($#ARGV > 0);
  printf ("\tcode: %d    data: %d    symbols: %d    debug: %d\n",
          $code_size, $data_size, $symbol_size, $debug_size);
  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