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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
package B::Terse;
use strict;
use B qw(peekop class ad walkoptree walkoptree_exec
main_start main_root cstring svref_2object);
use B::Asmdata qw(@specialsv_name);
sub terse {
my ($order, $cvref) = @_;
my $cv = svref_2object($cvref);
if ($order eq "exec") {
walkoptree_exec($cv->START, "terse");
} else {
walkoptree($cv->ROOT, "terse");
}
}
sub compile {
my $order = shift;
my @options = @_;
if (@options) {
return sub {
my $objname;
foreach $objname (@options) {
$objname = "main::$objname" unless $objname =~ /::/;
eval "terse(\$order, \\&$objname)";
die "terse($order, \\&$objname) failed: $@" if $@;
}
}
} else {
if ($order eq "exec") {
return sub { walkoptree_exec(main_start, "terse") }
} else {
return sub { walkoptree(main_root, "terse") }
}
}
}
sub indent {
my $level = shift;
return " " x $level;
}
sub B::OP::terse {
my ($op, $level) = @_;
my $targ = $op->targ;
$targ = ($targ > 0) ? " [$targ]" : "";
print indent($level), peekop($op), $targ, "\n";
}
sub B::SVOP::terse {
my ($op, $level) = @_;
print indent($level), peekop($op), " ";
$op->sv->terse(0);
}
sub B::GVOP::terse {
my ($op, $level) = @_;
print indent($level), peekop($op), " ";
$op->gv->terse(0);
}
sub B::PMOP::terse {
my ($op, $level) = @_;
my $precomp = $op->precomp;
print indent($level), peekop($op),
defined($precomp) ? " /$precomp/\n" : " (regexp not compiled)\n";
}
sub B::PVOP::terse {
my ($op, $level) = @_;
print indent($level), peekop($op), " ", cstring($op->pv), "\n";
}
sub B::COP::terse {
my ($op, $level) = @_;
my $label = $op->label;
if ($label) {
$label = " label ".cstring($label);
}
print indent($level), peekop($op), $label, "\n";
}
sub B::PV::terse {
my ($sv, $level) = @_;
print indent($level);
printf "%s (0x%lx) %s\n", class($sv), ad($sv), cstring($sv->PV);
}
sub B::AV::terse {
my ($sv, $level) = @_;
print indent($level);
printf "%s (0x%lx) FILL %d\n", class($sv), ad($sv), $sv->FILL;
}
sub B::GV::terse {
my ($gv, $level) = @_;
my $stash = $gv->STASH->NAME;
if ($stash eq "main") {
$stash = "";
} else {
$stash = $stash . "::";
}
print indent($level);
printf "%s (0x%lx) *%s%s\n", class($gv), ad($gv), $stash, $gv->NAME;
}
sub B::IV::terse {
my ($sv, $level) = @_;
print indent($level);
printf "%s (0x%lx) %d\n", class($sv), ad($sv), $sv->IV;
}
sub B::NV::terse {
my ($sv, $level) = @_;
print indent($level);
printf "%s (0x%lx) %s\n", class($sv), ad($sv), $sv->NV;
}
sub B::NULL::terse {
my ($sv, $level) = @_;
print indent($level);
printf "%s (0x%lx)\n", class($sv), ad($sv);
}
sub B::SPECIAL::terse {
my ($sv, $level) = @_;
print indent($level);
printf "%s #%d %s\n", class($sv), $$sv, $specialsv_name[$$sv];
}
1;
|