From: Rudolf Polzer Date: Thu, 26 Apr 2012 09:16:19 +0000 (+0200) Subject: fix parameter handling X-Git-Tag: xonotic-v0.7.0~55^2~36 X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fxonotic.git;a=commitdiff_plain;h=f4052bc234b181da3462fed6479674ace0711795 fix parameter handling --- diff --git a/misc/tools/progs-analyzer.pl b/misc/tools/progs-analyzer.pl index bc4623d5..2adab78b 100644 --- a/misc/tools/progs-analyzer.pl +++ b/misc/tools/progs-analyzer.pl @@ -552,10 +552,43 @@ sub find_uninitialized_locals($$) { $watchme{$_} = { flags => $watchme{$_}, - valid => ($_ >= $func->{parm_start} && $_ < $p) # preinitialize parameters + valid => 0 }; } + # mark parameters as initialized + for($func->{parm_start} .. ($p-1)) + { + $watchme{$_}{valid} = 1 + if defined $watchme{$_}; + } + # an initial run of STORE instruction is for receiving extra parameters + # (beyond 8). Only possible if the function is declared as having 8 params. + # Extra parameters behave otherwise like temps, but are initialized at + # startup. + for($func->{first_statement} .. (@{$progs->{statements}}-1)) + { + my $s = $progs->{statements}[$_]; + if($s->{op} eq 'STORE_V') + { + $watchme{$s->{a}}{valid} = 1 + if defined $watchme{$s->{a}}; + $watchme{$s->{a}+1}{valid} = 1 + if defined $watchme{$s->{a}+1}; + $watchme{$s->{a}+2}{valid} = 1 + if defined $watchme{$s->{a}+2}; + } + elsif($s->{op} =~ /^STORE_/) + { + $watchme{$s->{a}}{valid} = 1 + if defined $watchme{$s->{a}}; + } + else + { + last; + } + } + my %warned = (); run_nfa $progs, $func->{first_statement}, \%watchme, sub { @@ -760,7 +793,6 @@ sub parse_progs($) } $p{temps} = \%istemp; $p{consts} = \%isconst; - # TODO rather detect consts by only reading instructions print STDERR "Naming...\n";