]> git.xonotic.org Git - xonotic/xonotic.git/blobdiff - misc/tools/progs-analyzer.pl
Use time only if it exists.
[xonotic/xonotic.git] / misc / tools / progs-analyzer.pl
old mode 100644 (file)
new mode 100755 (executable)
index e7d7826..d0df1c4
@@ -1,3 +1,5 @@
+#!/usr/bin/perl
+
 use strict;
 use warnings;
 use Digest::SHA;
@@ -125,6 +127,10 @@ sub checkop($)
        {
                return { a => 'inglobal', b => 'inglobalfunc' };
        }
+       if($op =~ /^INVALID#/)
+       {
+               return { isinvalid => 1 };
+       }
        return { a => 'inglobal', b => 'inglobal', c => 'outglobal' };
 }
 
@@ -673,6 +679,10 @@ sub find_uninitialized_locals($$)
                                }
                        }
 
+                       if($c->{isinvalid})
+                       {
+                               ++$warned{$ip}{''}{"Invalid opcode"};
+                       }
                        for(qw(a b c))
                        {
                                my $type = $c->{$_};
@@ -1217,12 +1227,12 @@ sub parse_progs($)
                my $file = $p{getstring}->($f->{s_file});
                die "Out of range first_statement in function $_ (name: \"$name\", file: \"$file\", first statement: $f->{first_statement})"
                        if $f->{first_statement} >= @{$p{statements}};
-               die "Out of range parm_start in function $_ (name: \"$name\", file: \"$file\", first statement: $f->{first_statement})"
-                       if $f->{parm_start} < 0 || $f->{parm_start} >= @{$p{globals}};
-               die "Out of range locals in function $_ (name: \"$name\", file: \"$file\", first statement: $f->{first_statement})"
-                       if $f->{locals} < 0 || $f->{parm_start} + $f->{locals} >= @{$p{globals}};
                if($f->{first_statement} >= 0)
                {
+                       die "Out of range parm_start in function $_ (name: \"$name\", file: \"$file\", first statement: $f->{first_statement})"
+                               if $f->{parm_start} < 0 || $f->{parm_start} >= @{$p{globals}};
+                       die "Out of range locals in function $_ (name: \"$name\", file: \"$file\", first statement: $f->{first_statement})"
+                               if $f->{locals} < 0 || $f->{parm_start} + $f->{locals} > @{$p{globals}};
                        die "Out of range numparms $f->{numparms} in function $_ (name: \"$name\", file: \"$file\", first statement: $f->{first_statement})"
                                if $f->{numparms} < 0 || $f->{numparms} > 8;
                        my $totalparms = 0;
@@ -1233,7 +1243,9 @@ sub parse_progs($)
                                $totalparms += $f->{parm_size}[$_];
                        }
                        die "Out of range parms in function $_ (name: \"$name\", file: \"$file\", first statement: $f->{first_statement})"
-                               if $f->{locals} < 0 || $f->{parm_start} + $totalparms >= @{$p{globals}};
+                               if $f->{parm_start} + $totalparms > @{$p{globals}};
+                       die "More parms than locals in function $_ (name: \"$name\", file: \"$file\", first statement: $f->{first_statement})"
+                               if $totalparms > $f->{locals};
                }
        }