1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
Main::load_apps();
my %proto2node;
@ARGV==1 or die "usage: OUTFILE\n";
open my $out, ">", $ARGV[0]
or die "can't create outfile $ARGV[0]: $!\n";
print $out <<'.';
digraph "Big Object Zoo" {
.
foreach my $app (Core::Application::list_loaded()) {
foreach my $proto (@{$app->object_types}) {
my $node_id="n".scalar(keys %proto2node);
$proto2node{$proto}=$node_id;
print $out " $node_id [label=\"", $app->name, "::", $proto->full_name, "\"];\n";
}
}
while (my ($proto, $to_node)=each %proto2node) {
my %ancestors;
@ancestors{grep { exists $proto2node{$_} } @{$proto->linear_isa}}=();
foreach my $super (grep { exists $proto2node{$_} } @{$proto->linear_isa}) {
delete @ancestors{@{$super->linear_isa}};
}
my $to_node=$proto2node{$proto};
print $out " $proto2node{$_} -> $to_node;\n" for keys %ancestors;
}
print $out "}\n";
close $out;
|