mirror of
https://github.com/mi57730/a2d.git
synced 2025-08-12 22:25:08 +00:00
stats.pl: add 'scoped' command
This commit is contained in:
12
res/stats.pl
12
res/stats.pl
@@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
# stats.pl < source.s -- dump stats
|
# stats.pl < source.s -- dump stats
|
||||||
# stats.pl unscoped < source.s -- list Lxxxx symbols not within 2 scopes
|
# stats.pl unscoped < source.s -- list Lxxxx symbols not within 2 scopes
|
||||||
# stats.pl single < source.s -- list Lxxxx symbols with no references
|
# stats.pl scoped < source.s -- list Lxxxx symbols within 2 scopes
|
||||||
|
# stats.pl raw < source.s -- list $xxxx usage
|
||||||
|
# stats.pl unrefed < source.s -- list Lxxxx symbols with no references
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
@@ -11,6 +13,7 @@ my $command = shift(@ARGV) // "";
|
|||||||
|
|
||||||
my %defs;
|
my %defs;
|
||||||
my %refs;
|
my %refs;
|
||||||
|
my %scoped;
|
||||||
my %unscoped;
|
my %unscoped;
|
||||||
my %raw;
|
my %raw;
|
||||||
my $depth = 0;
|
my $depth = 0;
|
||||||
@@ -29,6 +32,7 @@ while (<STDIN>) {
|
|||||||
$_ = $2;
|
$_ = $2;
|
||||||
$defs{$def} = ($defs{$def} // 0) + 1;
|
$defs{$def} = ($defs{$def} // 0) + 1;
|
||||||
$unscoped{$def} = 1 if $depth < 2;
|
$unscoped{$def} = 1 if $depth < 2;
|
||||||
|
$scoped{$def} = 1 if $depth >= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach my $term (split /[ (),+\-*\/]/, $_) {
|
foreach my $term (split /[ (),+\-*\/]/, $_) {
|
||||||
@@ -50,12 +54,16 @@ foreach my $def (keys %defs) {
|
|||||||
my $defs = scalar(keys %defs);
|
my $defs = scalar(keys %defs);
|
||||||
my $unscoped = scalar(keys %unscoped);
|
my $unscoped = scalar(keys %unscoped);
|
||||||
my $raws = scalar(keys %raw);
|
my $raws = scalar(keys %raw);
|
||||||
my $scoped = $defs - $unscoped;
|
my $scoped = scalar(keys %scoped);
|
||||||
|
|
||||||
if ($command eq "unscoped") {
|
if ($command eq "unscoped") {
|
||||||
foreach my $def (sort keys %unscoped) {
|
foreach my $def (sort keys %unscoped) {
|
||||||
print "$def\n";
|
print "$def\n";
|
||||||
}
|
}
|
||||||
|
} elsif ($command eq "scoped") {
|
||||||
|
foreach my $def (sort keys %scoped) {
|
||||||
|
print "$def\n";
|
||||||
|
}
|
||||||
} elsif ($command eq "unrefed") {
|
} elsif ($command eq "unrefed") {
|
||||||
foreach my $def (sort keys %defs) {
|
foreach my $def (sort keys %defs) {
|
||||||
print "$def\n" unless defined $refs{$def};
|
print "$def\n" unless defined $refs{$def};
|
||||||
|
Reference in New Issue
Block a user