+ my $f = $p{functions}[$_];
+ die "Out of range name in function $_"
+ if $f->{s_name} < 0 || $f->{s_name} >= length $p{strings};
+ my $name = $p{getstring}->($f->{s_name});
+ die "Out of range file in function $_"
+ if $f->{s_file} < 0 || $f->{s_file} >= length $p{strings};
+ 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}};
+ 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;
+ for(0..($f->{numparms}-1))
+ {
+ die "Out of range parm_size[$_] in function $_ (name: \"$name\", file: \"$file\", first statement: $f->{first_statement})"
+ unless { 0 => 1, 1 => 1, 3 => 1 }->{$f->{parm_size}[$_]};
+ $totalparms += $f->{parm_size}[$_];
+ }
+ die "Out of range parms in function $_ (name: \"$name\", file: \"$file\", first statement: $f->{first_statement})"
+ 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};
+ }
+ }
+
+ print STDERR "Range checking statements...\n";
+ for my $ip(0 .. (@{$p{statements}}-1))
+ {
+ my $s = $p{statements}[$ip];