mirror of
https://github.com/mi57730/a2d.git
synced 2024-06-25 21:29:30 +00:00
Update stats tool
This commit is contained in:
parent
366d092d91
commit
60062360ca
|
@ -161,7 +161,7 @@ L7207: .byte $29
|
||||||
entry 0, $66D8
|
entry 0, $66D8
|
||||||
|
|
||||||
L7232: .byte $29
|
L7232: .byte $29
|
||||||
L7233: entry 0, $72CD
|
entry 0, $72CD
|
||||||
entry 0, $736C
|
entry 0, $736C
|
||||||
entry 0, $65F0
|
entry 0, $65F0
|
||||||
entry 0, $6693
|
entry 0, $6693
|
||||||
|
|
48
res/stats.pl
48
res/stats.pl
|
@ -1,31 +1,57 @@
|
||||||
#!/usr/bin/env perl
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
|
# stats.pl < source.s -- dump stats
|
||||||
|
# stats.pl unscoped < source.s -- list Lxxxx symbols not within 2 scopes
|
||||||
|
# stats.pl single < source.s -- list Lxxxx symbols with no references
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
my %terms;
|
my $command = shift(@ARGV) // "";
|
||||||
|
|
||||||
|
my %defs;
|
||||||
|
my %refs;
|
||||||
my %unscoped;
|
my %unscoped;
|
||||||
my $depth = 0;
|
my $depth = 0;
|
||||||
|
|
||||||
while (<STDIN>) {
|
while (<STDIN>) {
|
||||||
++$depth if m/\.proc/ || m/\.scope/;
|
++$depth if m/\.proc/ || m/\.scope/;
|
||||||
--$depth if m/\.endproc/ || m/\.endscope/;
|
--$depth if m/\.endproc/ || m/\.endscope/;
|
||||||
foreach my $term (split /\b/, $_) {
|
|
||||||
|
if (m/^(L[0-9A-F]{4}):(.*)/) {
|
||||||
|
my $def = $1;
|
||||||
|
$_ = $2;
|
||||||
|
$defs{$def} = ($defs{$def} // 0) + 1;
|
||||||
|
$unscoped{$def} = 1 if $depth < 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach my $term (split /(?<!::)\b/, $_) {
|
||||||
if ($term =~ /^L[0-9A-F]{4}$/) {
|
if ($term =~ /^L[0-9A-F]{4}$/) {
|
||||||
$terms{$term} = 0 unless defined $terms{$term};
|
$refs{$term} = 0 unless defined $refs{$term};
|
||||||
$terms{$term} += 1;
|
$refs{$term} += 1;
|
||||||
$unscoped{$term} = 1 if $depth < 2;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my $single = 0;
|
my $unrefed = 0;
|
||||||
foreach my $key (keys %terms) {
|
foreach my $def (keys %defs) {
|
||||||
++$single if $terms{$key} == 1;
|
++$unrefed unless defined $refs{$def};
|
||||||
}
|
}
|
||||||
|
|
||||||
my $terms = scalar(keys %terms);
|
my $defs = scalar(keys %defs);
|
||||||
my $unscoped = scalar(keys %unscoped);
|
my $unscoped = scalar(keys %unscoped);
|
||||||
my $scoped = $terms - $unscoped;
|
my $scoped = $defs - $unscoped;
|
||||||
|
|
||||||
print "unscoped: $unscoped scoped: $scoped single: $single\n";
|
if ($command eq "unscoped") {
|
||||||
|
foreach my $def (sort keys %unscoped) {
|
||||||
|
print "$def\n";
|
||||||
|
}
|
||||||
|
} elsif ($command eq "unrefed") {
|
||||||
|
foreach my $def (sort keys %defs) {
|
||||||
|
print "$def\n" unless defined $refs{$def};
|
||||||
|
}
|
||||||
|
} elsif ($command eq "") {
|
||||||
|
print "unscoped: $unscoped scoped: $scoped unrefed: $unrefed\n";
|
||||||
|
} else {
|
||||||
|
die "Unknown command: $command\n";
|
||||||
|
}
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
#!/usr/bin/env perl
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
use warnings;
|
|
||||||
|
|
||||||
my %terms;
|
|
||||||
my %unscoped;
|
|
||||||
my $depth = 0;
|
|
||||||
|
|
||||||
while (<STDIN>) {
|
|
||||||
++$depth if m/\.proc/ || m/\.scope/;
|
|
||||||
--$depth if m/\.endproc/ || m/\.endscope/;
|
|
||||||
foreach my $term (split /\b/, $_) {
|
|
||||||
if ($term =~ /^L[0-9A-F]{4}$/) {
|
|
||||||
$terms{$term} = 0 unless defined $terms{$term};
|
|
||||||
$terms{$term} += 1;
|
|
||||||
$unscoped{$term} = 1 if $depth < 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach my $term (sort keys %unscoped) {
|
|
||||||
print "$term\n";
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user