1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# line 10 "ghc-asm-sgi.lprl"
sub mangle_asm {
local($in_asmf, $out_asmf) = @_;
local($fun_code);
# multi-line regexp matching:
local($*) = 1;
local($i, $c);
&init_FUNNY_THINGS();
open(INASM, "< $in_asmf")
|| &tidy_up_and_die(1,"$Pgm: failed to open `$in_asmf' (to read)\n");
open(OUTASM,"> $out_asmf")
|| &tidy_up_and_die(1,"$Pgm: failed to open `$out_asmf' (to write)\n");
# just copy through now...
while (<INASM>) {
print OUTASM $_;
}
close(OUTASM) || &tidy_up_and_die(1,"Failed writing to $out_asmf\n");
close(INASM) || &tidy_up_and_die(1,"Failed reading from $in_asmf\n");
}
# line 36 "ghc-asm-sgi.lprl"
sub init_FUNNY_THINGS {
print STDERR "SGI: init_FUNNY_THINGS\n";
}
# line 48 "ghc-asm-sgi.lprl"
sub rev_tbl {
local($symb, $tbl, $discard1) = @_;
local($before) = '';
local($label) = '';
local(@words) = ();
local($after) = '';
local(@lines) = split(/\n/, $tbl);
local($i);
for ($i = 0; $i <= $#lines && $lines[$i] !~ /^\t\.word\s+/; $i++) {
$label .= $lines[$i] . "\n",
next if $lines[$i] =~ /^[A-Za-z0-9_]+:$/
|| $lines[$i] =~ /^\t\.global/;
$before .= $lines[$i] . "\n"; # otherwise...
}
for ( ; $i <= $#lines && $lines[$i] =~ /^\t\.word\s+/; $i++) {
push(@words, $lines[$i]);
}
# now throw away the first word (entry code):
shift(@words) if $discard1;
for (; $i <= $#lines; $i++) {
$after .= $lines[$i] . "\n";
}
$tbl = $before . join("\n", (reverse @words)) . "\n" . $label . $after;
# print STDERR "before=$before\n";
# print STDERR "label=$label\n";
# print STDERR "words=",(reverse @words),"\n";
# print STDERR "after=$after\n";
$tbl;
}
# line 88 "ghc-asm-sgi.lprl"
# make "require"r happy...
1;
|