line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Dump::Streamer; |
2
|
24
|
|
|
24
|
|
293572
|
use strict; |
|
24
|
|
|
|
|
39
|
|
|
24
|
|
|
|
|
652
|
|
3
|
24
|
|
|
24
|
|
95
|
use warnings; |
|
24
|
|
|
|
|
26
|
|
|
24
|
|
|
|
|
580
|
|
4
|
24
|
|
|
24
|
|
84
|
use warnings::register; |
|
24
|
|
|
|
|
29
|
|
|
24
|
|
|
|
|
2662
|
|
5
|
|
|
|
|
|
|
|
6
|
24
|
|
|
24
|
|
91
|
use B (); |
|
24
|
|
|
|
|
25
|
|
|
24
|
|
|
|
|
316
|
|
7
|
24
|
|
|
24
|
|
71
|
use B::Deparse (); |
|
24
|
|
|
|
|
23
|
|
|
24
|
|
|
|
|
252
|
|
8
|
24
|
|
|
24
|
|
12044
|
use B::Utils (); |
|
24
|
|
|
|
|
104655
|
|
|
24
|
|
|
|
|
533
|
|
9
|
24
|
|
|
24
|
|
13393
|
use Data::Dumper (); |
|
24
|
|
|
|
|
170327
|
|
|
24
|
|
|
|
|
605
|
|
10
|
24
|
|
|
24
|
|
143
|
use DynaLoader (); |
|
24
|
|
|
|
|
31
|
|
|
24
|
|
|
|
|
287
|
|
11
|
24
|
|
|
24
|
|
74
|
use Exporter (); |
|
24
|
|
|
|
|
32
|
|
|
24
|
|
|
|
|
253
|
|
12
|
24
|
|
|
24
|
|
11216
|
use IO::File (); |
|
24
|
|
|
|
|
178588
|
|
|
24
|
|
|
|
|
1147
|
|
13
|
24
|
|
|
24
|
|
139
|
use Symbol (); |
|
24
|
|
|
|
|
30
|
|
|
24
|
|
|
|
|
311
|
|
14
|
24
|
|
|
24
|
|
16204
|
use Text::Abbrev (); |
|
24
|
|
|
|
|
825
|
|
|
24
|
|
|
|
|
468
|
|
15
|
24
|
|
|
24
|
|
16756
|
use Text::Balanced (); |
|
24
|
|
|
|
|
189635
|
|
|
24
|
|
|
|
|
729
|
|
16
|
24
|
|
|
24
|
|
182
|
use overload (); |
|
24
|
|
|
|
|
32
|
|
|
24
|
|
|
|
|
374
|
|
17
|
|
|
|
|
|
|
|
18
|
24
|
|
|
24
|
|
18138
|
use Data::Dump::Streamer::_::Printers; |
|
24
|
|
|
|
|
46
|
|
|
24
|
|
|
|
|
947
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# use overload qw("" printit); # does diabolical stuff. |
21
|
|
|
|
|
|
|
|
22
|
24
|
|
|
|
|
2632
|
use vars qw( |
23
|
|
|
|
|
|
|
$VERSION |
24
|
|
|
|
|
|
|
$XS_VERSION |
25
|
|
|
|
|
|
|
$AUTOLOAD |
26
|
|
|
|
|
|
|
@ISA |
27
|
|
|
|
|
|
|
@EXPORT @EXPORT_OK @EXPORT_FAIL %EXPORT_TAGS |
28
|
|
|
|
|
|
|
%Freeze |
29
|
|
|
|
|
|
|
%Thaw |
30
|
|
|
|
|
|
|
$DEBUG |
31
|
|
|
|
|
|
|
$HasPadWalker |
32
|
24
|
|
|
24
|
|
104
|
); |
|
24
|
|
|
|
|
33
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$DEBUG=0; |
35
|
24
|
|
|
24
|
|
1447
|
BEGIN{ $HasPadWalker=eval "use PadWalker 0.99; 1"; } |
|
24
|
|
|
24
|
|
10394
|
|
|
24
|
|
|
|
|
15101
|
|
|
24
|
|
|
|
|
759
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
BEGIN { |
38
|
24
|
|
|
24
|
|
53
|
$VERSION ='2.40'; |
39
|
24
|
|
|
|
|
34
|
$XS_VERSION = $VERSION; |
40
|
24
|
|
|
|
|
1284
|
$VERSION = eval $VERSION; # used for beta stuff. |
41
|
24
|
|
|
|
|
309
|
@ISA = qw(Exporter DynaLoader); |
42
|
24
|
|
|
|
|
62
|
@EXPORT=qw(Dump DumpLex DumpVars); |
43
|
24
|
|
|
|
|
126
|
@EXPORT_OK = qw( |
44
|
|
|
|
|
|
|
Dump |
45
|
|
|
|
|
|
|
DumpLex |
46
|
|
|
|
|
|
|
DumpVars |
47
|
|
|
|
|
|
|
Stream |
48
|
|
|
|
|
|
|
alias_av |
49
|
|
|
|
|
|
|
alias_hv |
50
|
|
|
|
|
|
|
alias_ref |
51
|
|
|
|
|
|
|
push_alias |
52
|
|
|
|
|
|
|
dualvar |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
alias_to |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
blessed |
57
|
|
|
|
|
|
|
reftype |
58
|
|
|
|
|
|
|
refaddr |
59
|
|
|
|
|
|
|
refcount |
60
|
|
|
|
|
|
|
sv_refcount |
61
|
|
|
|
|
|
|
looks_like_number |
62
|
|
|
|
|
|
|
regex |
63
|
|
|
|
|
|
|
readonly |
64
|
|
|
|
|
|
|
make_ro |
65
|
|
|
|
|
|
|
_make_ro |
66
|
|
|
|
|
|
|
reftype_or_glob |
67
|
|
|
|
|
|
|
refaddr_or_glob |
68
|
|
|
|
|
|
|
globname |
69
|
|
|
|
|
|
|
is_numeric |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
all_keys |
72
|
|
|
|
|
|
|
legal_keys |
73
|
|
|
|
|
|
|
hidden_keys |
74
|
|
|
|
|
|
|
lock_ref_keys |
75
|
|
|
|
|
|
|
lock_keys |
76
|
|
|
|
|
|
|
lock_ref_keys_plus |
77
|
|
|
|
|
|
|
lock_keys_plus |
78
|
|
|
|
|
|
|
SvREADONLY_ref |
79
|
|
|
|
|
|
|
SvREFCNT_ref |
80
|
|
|
|
|
|
|
isweak |
81
|
|
|
|
|
|
|
weaken |
82
|
|
|
|
|
|
|
weak_refcount |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
readonly_set |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Dumper |
87
|
|
|
|
|
|
|
DDumper |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
alias |
90
|
|
|
|
|
|
|
sqz |
91
|
|
|
|
|
|
|
usqz |
92
|
|
|
|
|
|
|
); |
93
|
|
|
|
|
|
|
|
94
|
24
|
|
|
|
|
564
|
%EXPORT_TAGS = ( |
95
|
|
|
|
|
|
|
undump => [ qw( alias_av alias_hv alias_ref make_ro |
96
|
|
|
|
|
|
|
lock_ref_keys |
97
|
|
|
|
|
|
|
lock_keys |
98
|
|
|
|
|
|
|
lock_ref_keys_plus |
99
|
|
|
|
|
|
|
lock_keys_plus |
100
|
|
|
|
|
|
|
alias_to |
101
|
|
|
|
|
|
|
dualvar |
102
|
|
|
|
|
|
|
weaken |
103
|
|
|
|
|
|
|
usqz |
104
|
|
|
|
|
|
|
) |
105
|
|
|
|
|
|
|
], |
106
|
|
|
|
|
|
|
special=> [ qw( readonly_set ) ], |
107
|
|
|
|
|
|
|
all => [ @EXPORT,@EXPORT_OK ], |
108
|
|
|
|
|
|
|
alias => [ qw( alias_av alias_hv alias_ref push_alias ) ], |
109
|
|
|
|
|
|
|
bin => [ @EXPORT_OK ], |
110
|
|
|
|
|
|
|
Dumper => [ qw( Dumper DDumper )], |
111
|
|
|
|
|
|
|
util => [ qw ( |
112
|
|
|
|
|
|
|
dualvar |
113
|
|
|
|
|
|
|
blessed reftype refaddr refcount sv_refcount |
114
|
|
|
|
|
|
|
readonly looks_like_number regex is_numeric |
115
|
|
|
|
|
|
|
make_ro readonly_set reftype_or_glob |
116
|
|
|
|
|
|
|
refaddr_or_glob globname |
117
|
|
|
|
|
|
|
weak_refcount isweak weaken |
118
|
|
|
|
|
|
|
) |
119
|
|
|
|
|
|
|
], |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
); |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
124
|
0
|
|
|
0
|
0
|
0
|
sub alias_to { return shift } |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
#warn $VERSION; |
127
|
24
|
|
|
|
|
9757
|
Data::Dump::Streamer->bootstrap($XS_VERSION); |
128
|
24
|
50
|
|
|
|
867
|
if ($]>=5.013010) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
129
|
|
|
|
|
|
|
# As I write this, 5.13.10 doesn't exist so I'm guessing that |
130
|
|
|
|
|
|
|
# we can begin using the ordinary core function again. |
131
|
24
|
50
|
|
24
|
|
1597
|
eval q[ |
|
24
|
|
|
|
|
129
|
|
|
24
|
|
|
|
|
28
|
|
|
24
|
|
|
|
|
4837
|
|
132
|
|
|
|
|
|
|
use re qw(regexp_pattern is_regexp); |
133
|
|
|
|
|
|
|
*regex= *regexp_pattern; |
134
|
|
|
|
|
|
|
] or die $@; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
elsif ($]>=5.013006) { |
137
|
|
|
|
|
|
|
# Perl-5.13.6 through perl-5.13.9 began returning modifier |
138
|
|
|
|
|
|
|
# flags that weren't yet legal at the time. |
139
|
0
|
0
|
|
|
|
0
|
eval q[ |
140
|
|
|
|
|
|
|
use re qw(regexp_pattern is_regexp); |
141
|
|
|
|
|
|
|
sub regex { |
142
|
|
|
|
|
|
|
if (wantarray) { |
143
|
|
|
|
|
|
|
my ($pat,$mod) = regexp_pattern($_[0]); |
144
|
|
|
|
|
|
|
if ($mod) { |
145
|
|
|
|
|
|
|
$mod =~ tr/dlua?//d; |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
return ($pat,$mod); |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
else { |
150
|
|
|
|
|
|
|
return scalar regexp_pattern($_[0]); |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
1; |
154
|
|
|
|
|
|
|
] or die $@; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
elsif ($]>=5.009004) { |
157
|
0
|
0
|
|
|
|
0
|
eval q[ |
158
|
|
|
|
|
|
|
use re qw(regexp_pattern is_regexp); |
159
|
|
|
|
|
|
|
*regex= *regexp_pattern; |
160
|
|
|
|
|
|
|
1; |
161
|
|
|
|
|
|
|
] or die $@; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
else { |
164
|
0
|
|
|
|
|
0
|
eval q[sub is_regexp($) { defined regex($_[0]) }]; |
165
|
|
|
|
|
|
|
} |
166
|
24
|
50
|
|
|
|
94
|
if ($]<=5.008) { |
167
|
0
|
|
|
|
|
0
|
*hidden_keys=sub(\%) { return () }; |
|
0
|
|
|
|
|
0
|
|
168
|
0
|
|
|
|
|
0
|
*legal_keys=sub(\%) { return keys %{$_[0]} }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
169
|
0
|
|
|
|
|
0
|
*all_keys=sub(\%\@\@) { @{$_[1]}=keys %{$_[0]}; @$_[2]=(); }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
170
|
|
|
|
|
|
|
} |
171
|
24
|
50
|
|
|
|
871
|
if ( $]<5.008 ) { |
172
|
24
|
|
|
24
|
|
127
|
no strict 'refs'; |
|
24
|
|
|
|
|
31
|
|
|
24
|
|
|
|
|
7615
|
|
173
|
0
|
|
|
|
|
0
|
foreach my $sub (qw(lock_keys lock_keys_plus )) { |
174
|
|
|
|
|
|
|
*$sub=sub(\%;@) { |
175
|
0
|
|
|
|
|
0
|
warnings::warn "$sub doesn't do anything before Perl 5.8.0\n"; |
176
|
0
|
|
|
|
|
0
|
return $_[0]; |
177
|
|
|
|
|
|
|
} |
178
|
0
|
|
|
|
|
0
|
} |
179
|
0
|
|
|
|
|
0
|
foreach my $sub (qw(lock_ref_keys lock_ref_keys_plus )) { |
180
|
|
|
|
|
|
|
*$sub=sub($;@) { |
181
|
0
|
|
|
|
|
0
|
warnings::warn "$sub doesn't do anything before Perl 5.8.0\n"; |
182
|
0
|
|
|
|
|
0
|
return $_[0]; |
183
|
|
|
|
|
|
|
} |
184
|
0
|
|
|
|
|
0
|
} |
185
|
|
|
|
|
|
|
} else { |
186
|
|
|
|
|
|
|
eval <<'EO_HU' |
187
|
|
|
|
|
|
|
use Hash::Util qw(lock_keys); |
188
|
|
|
|
|
|
|
sub lock_ref_keys($;@) { |
189
|
|
|
|
|
|
|
my $hash=shift; |
190
|
|
|
|
|
|
|
Carp::confess("lock_ref_keys(): Not a ref '$hash'") |
191
|
|
|
|
|
|
|
unless ref $hash; |
192
|
|
|
|
|
|
|
lock_keys(%$hash,@_); |
193
|
|
|
|
|
|
|
$hash |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
EO_HU |
196
|
24
|
50
|
|
24
|
0
|
1390
|
; |
|
24
|
|
|
6
|
|
12833
|
|
|
24
|
|
|
|
|
55067
|
|
|
24
|
|
|
|
|
124
|
|
|
6
|
|
|
|
|
14051
|
|
|
6
|
|
|
|
|
25
|
|
|
6
|
|
|
|
|
21
|
|
|
6
|
|
|
|
|
274
|
|
197
|
|
|
|
|
|
|
*lock_ref_keys_plus=sub($;@){ |
198
|
43
|
|
|
43
|
|
5589
|
my ($hash,@keys)=@_; |
199
|
43
|
|
|
|
|
35
|
my @delete; |
200
|
43
|
|
|
|
|
54
|
Internals::hv_clear_placeholders(%$hash); |
201
|
43
|
|
|
|
|
54
|
foreach my $key (@keys) { |
202
|
86
|
100
|
|
|
|
127
|
unless (exists($hash->{$key})) { |
203
|
85
|
|
|
|
|
92
|
$hash->{$key}=undef; |
204
|
85
|
|
|
|
|
115
|
push @delete,$key; |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
} |
207
|
43
|
|
|
|
|
59
|
SvREADONLY_ref($hash,1); |
208
|
43
|
|
|
|
|
33
|
delete @{$hash}{@delete}; |
|
43
|
|
|
|
|
67
|
|
209
|
43
|
|
|
|
|
208
|
$hash |
210
|
24
|
|
|
|
|
3038
|
}; |
211
|
24
|
|
|
6
|
|
83
|
*lock_keys_plus=sub(\%;@){lock_ref_keys_plus(@_)}; |
|
6
|
|
|
|
|
3550
|
|
212
|
|
|
|
|
|
|
} |
213
|
24
|
50
|
|
|
|
112
|
if ($] <= 5.008008) { |
214
|
0
|
|
|
|
|
0
|
*disable_overloading = \&SvAMAGIC_off; |
215
|
|
|
|
|
|
|
*restore_overloading = sub ($$) { |
216
|
0
|
|
|
|
|
0
|
SvAMAGIC_on($_[0], undef); |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
# Visit all classes we are ISA and fetch the () entry from |
219
|
|
|
|
|
|
|
# every stash. |
220
|
0
|
|
|
|
|
0
|
my %done; |
221
|
0
|
|
|
|
|
0
|
my %todo = ( |
222
|
|
|
|
|
|
|
$_[0] => undef, |
223
|
|
|
|
|
|
|
UNIVERSAL => undef, |
224
|
|
|
|
|
|
|
); |
225
|
24
|
|
|
24
|
|
125
|
no strict 'refs'; |
|
24
|
|
|
|
|
28
|
|
|
24
|
|
|
|
|
4636
|
|
226
|
0
|
|
|
|
|
0
|
for my $todo_class (keys %todo) { |
227
|
0
|
|
|
|
|
0
|
delete $todo{$todo_class}; |
228
|
0
|
|
|
|
|
0
|
$done{$todo_class} = undef; |
229
|
0
|
|
|
|
|
0
|
for my $isa (@{"${todo_class}::ISA"}) { |
|
0
|
|
|
|
|
0
|
|
230
|
0
|
0
|
|
|
|
0
|
$todo{$isa} = undef unless exists $done{$isa}; |
231
|
|
|
|
|
|
|
} |
232
|
|
|
|
|
|
|
} |
233
|
0
|
|
|
|
|
0
|
}; |
234
|
|
|
|
|
|
|
} else { |
235
|
|
|
|
|
|
|
*disable_overloading = sub ($) { |
236
|
|
|
|
|
|
|
# we use eval because $_[0] might be read-only |
237
|
|
|
|
|
|
|
# its a crappy solution, but whatever, it works |
238
|
55
|
|
|
55
|
|
56
|
eval { bless $_[0], 'Does::Not::Exist' }; |
|
55
|
|
|
|
|
93
|
|
239
|
24
|
|
|
|
|
413
|
}; |
240
|
|
|
|
|
|
|
*restore_overloading = sub ($$) { |
241
|
55
|
|
|
55
|
|
63
|
eval { bless $_[0], $_[1] } |
|
55
|
|
|
|
|
109
|
|
242
|
24
|
|
|
|
|
66
|
}; |
243
|
|
|
|
|
|
|
} |
244
|
24
|
|
|
|
|
63
|
my %fail=map { ( $_ => 1 ) } @EXPORT_FAIL; |
|
0
|
|
|
|
|
0
|
|
245
|
24
|
|
|
|
|
43
|
@EXPORT_OK=grep { !$fail{$_} } @EXPORT_OK; |
|
1008
|
|
|
|
|
2564
|
|
246
|
|
|
|
|
|
|
} |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
sub import { |
249
|
26
|
|
|
26
|
|
1047
|
my ($pkg) = @_; |
250
|
26
|
|
|
|
|
46
|
my ($idx, $alias); |
251
|
|
|
|
|
|
|
|
252
|
26
|
100
|
|
|
|
219
|
if ($idx = (grep lc($_[$_]) eq 'as', 0..$#_)) { |
253
|
|
|
|
|
|
|
#print "found alias at $idx:\n"; |
254
|
2
|
|
|
|
|
5
|
($idx, $alias) = splice(@_, $idx, 2); |
255
|
|
|
|
|
|
|
#print "found alias: $idx => $alias\n"; |
256
|
|
|
|
|
|
|
|
257
|
24
|
|
|
24
|
|
129
|
no strict 'refs'; |
|
24
|
|
|
|
|
32
|
|
|
24
|
|
|
|
|
16111
|
|
258
|
2
|
|
|
|
|
3
|
*{$alias.'::'} = *{__PACKAGE__.'::'}; |
|
2
|
|
|
|
|
51
|
|
|
2
|
|
|
|
|
4
|
|
259
|
|
|
|
|
|
|
} |
260
|
26
|
|
|
|
|
6892
|
$pkg->export_to_level(1,@_); |
261
|
|
|
|
|
|
|
} |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
# NOTE |
264
|
|
|
|
|
|
|
# ---- |
265
|
|
|
|
|
|
|
# This module uses the term 'sv' in a way that is misleading. |
266
|
|
|
|
|
|
|
# It doesn't always mean the same as it would in the core. |
267
|
|
|
|
|
|
|
# |
268
|
|
|
|
|
|
|
# 1. data is breadth first traversed first, in the pretty much |
269
|
|
|
|
|
|
|
# self contained Data() routine which farms out a bit to |
270
|
|
|
|
|
|
|
# _reg_ref and _reg_scalar which handle "registering" items for |
271
|
|
|
|
|
|
|
# later use, such as their depth, refcount, "name", etc. But |
272
|
|
|
|
|
|
|
# ONLY for references and scalars whose refcount is over 2. |
273
|
|
|
|
|
|
|
# Most real SV's will have a refcount of 2 when we look at them |
274
|
|
|
|
|
|
|
# (from the perl side) so we actually don't know about them (trust me) |
275
|
|
|
|
|
|
|
# They _cant_ be referenced twice, and they can't be aliased so we can |
276
|
|
|
|
|
|
|
# can just ignore them until the second pass. |
277
|
|
|
|
|
|
|
# 2.Once this has happened Out() is called which starts off a |
278
|
|
|
|
|
|
|
# normal depth first traverse over the structure. It calls into |
279
|
|
|
|
|
|
|
# 3._dump_sv which in the case of a reference falls through to _dump_rv. |
280
|
|
|
|
|
|
|
# Aliasing and a bunch of stuff like that are checked here before we even |
281
|
|
|
|
|
|
|
# look at the reference type. |
282
|
|
|
|
|
|
|
# 4.If its a ref we fall through to dumping the reference in _dump_rv. |
283
|
|
|
|
|
|
|
# Here we handle duplicate refs, and manage depth checks, blessing, refs |
284
|
|
|
|
|
|
|
#(which is scary nasty horrible code) and then pass on to _dump_type where |
285
|
|
|
|
|
|
|
# type is one of 'code', 'qr', 'array' etc. Each of these which have children |
286
|
|
|
|
|
|
|
# then call back into _dump_sv as required. |
287
|
|
|
|
|
|
|
# 5. Because of the way perl works, we can't emit anything more than a DAG in a |
288
|
|
|
|
|
|
|
# single statement, so for more complex structures we need to add in the broken |
289
|
|
|
|
|
|
|
# links. I call these "fix statements", and they encompass copying reference |
290
|
|
|
|
|
|
|
# values, creating aliases, or even dumping globs. When a fix statement is needed |
291
|
|
|
|
|
|
|
# any of the _dump_foo methods will call _add_fix and add to the list of fixes. |
292
|
|
|
|
|
|
|
# after every root level _dump_sv call from Out() any fix statements possible to be |
293
|
|
|
|
|
|
|
# resolved will be emitted and removed from the fix list. This happens in |
294
|
|
|
|
|
|
|
# _dump_apply_fix, which is another piece of horrible code. |
295
|
|
|
|
|
|
|
# |
296
|
|
|
|
|
|
|
# Anyway, its terribly ugly, but for anything I can think to throw at i works. |
297
|
|
|
|
|
|
|
# demerphq |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
=encoding utf8 |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
=head1 NAME |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
Data::Dump::Streamer - Accurately serialize a data structure as Perl code. |
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
=head1 SYNOPSIS |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
use Data::Dump::Streamer; |
308
|
|
|
|
|
|
|
use DDS; # optionally installed alias |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
Dump($x,$y); # Prints to STDOUT |
311
|
|
|
|
|
|
|
Dump($x,$y)->Out(); # " " |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
my $o=Data::Dump::Streamer->new(); # Returns a new ... |
314
|
|
|
|
|
|
|
my $o=Dump(); # ... uninitialized object. |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
my $o=Dump($x,$y); # Returns an initialized object |
317
|
|
|
|
|
|
|
my $s=Dump($x,$y)->Out(); # " a string of the dumped obj |
318
|
|
|
|
|
|
|
my @l=Dump($x,$y); # " a list of code fragments |
319
|
|
|
|
|
|
|
my @l=Dump($x,$y)->Out(); # " a list of code fragments |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
Dump($x,$y)->To(\*STDERR)->Out(); # Prints to STDERR |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
Dump($x,$y)->Names('foo','bar') # Specify Names |
324
|
|
|
|
|
|
|
->Out(); |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
Dump($x,$y)->Indent(0)->Out(); # No indent |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
Dump($x,$y)->To(\*STDERR) # Output to STDERR |
329
|
|
|
|
|
|
|
->Indent(0) # ... no indent |
330
|
|
|
|
|
|
|
->Names('foo','bar') # ... specify Names |
331
|
|
|
|
|
|
|
->Out(); # Print... |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
$o->Data($x,$y); # OO form of what Dump($x,$y) does. |
334
|
|
|
|
|
|
|
$o->Names('Foo','Names'); # ... |
335
|
|
|
|
|
|
|
$o->Out(); # ... |
336
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
=head1 DESCRIPTION |
338
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
Given a list of scalars or reference variables, writes out |
340
|
|
|
|
|
|
|
their contents in perl syntax. The references can also be |
341
|
|
|
|
|
|
|
objects. The contents of each variable is output using the least |
342
|
|
|
|
|
|
|
number of Perl statements as convenient, usually only one. |
343
|
|
|
|
|
|
|
Self-referential structures, closures, and objects are output |
344
|
|
|
|
|
|
|
correctly. |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
The return value can be evaled to get back an identical copy |
347
|
|
|
|
|
|
|
of the original reference structure. In some cases this may |
348
|
|
|
|
|
|
|
require the use of utility subs that |
349
|
|
|
|
|
|
|
L will optionally |
350
|
|
|
|
|
|
|
export. |
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
This module is very similar in concept to the core module |
353
|
|
|
|
|
|
|
L, with the major differences |
354
|
|
|
|
|
|
|
being that this module is designed to output to a stream |
355
|
|
|
|
|
|
|
instead of constructing its output in memory (trading speed |
356
|
|
|
|
|
|
|
for memory), and that the traversal over the data structure |
357
|
|
|
|
|
|
|
is effectively breadth first versus the depth first |
358
|
|
|
|
|
|
|
traversal done by the others. |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
In fact the data structure is scanned twice, first in |
361
|
|
|
|
|
|
|
breadth first mode to perform structural analysis, and then |
362
|
|
|
|
|
|
|
in depth first mode to actually produce the output, but |
363
|
|
|
|
|
|
|
obeying the depth relationships of the first pass. |
364
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
=head2 Caveats Dumping Closures (CODE Refs) |
366
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
As of version 1.11 DDS has had the ability to dump closures properly. This |
368
|
|
|
|
|
|
|
means that the lexicals that are bound to the closure are dumped along |
369
|
|
|
|
|
|
|
with the subroutine that uses them. This makes it much easier to debug |
370
|
|
|
|
|
|
|
code that uses closures and to a certain extent provides a persistency |
371
|
|
|
|
|
|
|
framework for closure based code. The way this works is that DDS figures |
372
|
|
|
|
|
|
|
out what all the lexicals are that are bound to CODE refs it is dumping |
373
|
|
|
|
|
|
|
and then pretends that it had originally been called with all of them as |
374
|
|
|
|
|
|
|
its arguments, (along with the original arguments as well of course.) |
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
One consequence of the way the dumping process works is that all of the |
377
|
|
|
|
|
|
|
recreated subroutines will be in the same scope. This of course can lead |
378
|
|
|
|
|
|
|
to collisions as two subroutines can easily be bound to different |
379
|
|
|
|
|
|
|
variables that have the same name. |
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
The way that DDS resolves these collisions is that it renames one of the |
382
|
|
|
|
|
|
|
variables with a special name so that presumably there are no collisions. |
383
|
|
|
|
|
|
|
However this process is very simplistic with no checks to prevent |
384
|
|
|
|
|
|
|
collisions with other lexicals or other globals that may be used by other |
385
|
|
|
|
|
|
|
dumped code. In some situations it may be necessary to change the default |
386
|
|
|
|
|
|
|
value of the rename template which may be done by using the C |
387
|
|
|
|
|
|
|
method. |
388
|
|
|
|
|
|
|
|
389
|
|
|
|
|
|
|
Similarly to the problem of colliding lexicals is the problem of colliding |
390
|
|
|
|
|
|
|
lexicals and globals. DDS pays no attention to globals when dumping |
391
|
|
|
|
|
|
|
closures which can potentially result in lexicals being declared that will |
392
|
|
|
|
|
|
|
eclipse their global namesake. There is currently no way around this other |
393
|
|
|
|
|
|
|
than to avoid accessing a global and a lexical with the same name from the |
394
|
|
|
|
|
|
|
subs being dumped. An example is |
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
my $a = sub { $a++ }; |
397
|
|
|
|
|
|
|
Dump( sub { $a->() } ); |
398
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
which will not be dumped correctly. Generally speaking this kind of thing |
400
|
|
|
|
|
|
|
is bad practice anyway, so this should probably be viewed as a "feature". |
401
|
|
|
|
|
|
|
:-) |
402
|
|
|
|
|
|
|
|
403
|
|
|
|
|
|
|
Generally if the closures being dumped avoid accessing lexicals and |
404
|
|
|
|
|
|
|
globals with the same name from out of scope and that all of the CODE |
405
|
|
|
|
|
|
|
being dumped avoids vars with the C in their names the dumps |
406
|
|
|
|
|
|
|
should be valid and should eval back into existence properly. |
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
Note that the behaviour of dumping closures is subject to change in future |
409
|
|
|
|
|
|
|
versions as its possible that I will put some additional effort into more |
410
|
|
|
|
|
|
|
sophisticated ways of avoiding name collisions in the dump. |
411
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
=head1 USAGE |
413
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
While Data::Dump::Streamer is at heart an object oriented module, it is |
415
|
|
|
|
|
|
|
expected (based on experience with using L) |
416
|
|
|
|
|
|
|
that the common case will not exploit these features. Nevertheless the |
417
|
|
|
|
|
|
|
method based approach is convenient and accordingly a compromise hybrid |
418
|
|
|
|
|
|
|
approach has been provided via the C subroutine. Such as |
419
|
|
|
|
|
|
|
|
420
|
|
|
|
|
|
|
Dump($foo); |
421
|
|
|
|
|
|
|
$as_string= Dump($foo)->Out(); |
422
|
|
|
|
|
|
|
|
423
|
|
|
|
|
|
|
All attribute methods are designed to be chained together. This means |
424
|
|
|
|
|
|
|
that when used as set attribute (called with arguments) they return the |
425
|
|
|
|
|
|
|
object they were called against. When used as get attributes (called |
426
|
|
|
|
|
|
|
without arguments) they return the value of the attribute. |
427
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
From an OO point of view the key methods are the C and C |
429
|
|
|
|
|
|
|
methods. These correspond to the breadth first and depth first traversal, |
430
|
|
|
|
|
|
|
and need to be called in this order. Some attributes I be set prior |
431
|
|
|
|
|
|
|
to the C phase and some need only be set before the C |
432
|
|
|
|
|
|
|
phase. |
433
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
Attributes once set last the lifetime of the object, unless explicitly |
435
|
|
|
|
|
|
|
reset. |
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
=head2 Controlling Object Representation |
438
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
This module provides hooks to allow objects to override how they are |
440
|
|
|
|
|
|
|
represented. The basic idea is that a subroutine (or method) is provided |
441
|
|
|
|
|
|
|
which is responsible for the override. The return of the method governs |
442
|
|
|
|
|
|
|
how the object will be represented when dumped, and how it will be |
443
|
|
|
|
|
|
|
restored. The basic calling convention is |
444
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
my ( $proxy, $thaw, $postop )= $callback->($obj); |
446
|
|
|
|
|
|
|
#or = $obj->$method(); |
447
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
The L|/Freezer> method controls what methods to use as a default method |
449
|
|
|
|
|
|
|
and also allows per class overrides. When dumping an object of a given |
450
|
|
|
|
|
|
|
class the first time it tries to execute the class specific handler if |
451
|
|
|
|
|
|
|
it is specified, then the user specific generic handler if its been |
452
|
|
|
|
|
|
|
specified and then "DDS_freeze". This means that class authors can |
453
|
|
|
|
|
|
|
implement a C method and their objects will automatically |
454
|
|
|
|
|
|
|
be serialized as necessary. B that if either the class specific or |
455
|
|
|
|
|
|
|
generic handler is defined but false C will not be used |
456
|
|
|
|
|
|
|
even if it is present. |
457
|
|
|
|
|
|
|
|
458
|
|
|
|
|
|
|
The interface of the L|/Freezer> handler in detail is as follows: |
459
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
=over 4 |
461
|
|
|
|
|
|
|
|
462
|
|
|
|
|
|
|
=item B> |
463
|
|
|
|
|
|
|
|
464
|
|
|
|
|
|
|
The object being dumped. |
465
|
|
|
|
|
|
|
|
466
|
|
|
|
|
|
|
=item B> |
467
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
This is what will be dumped instead of C<$obj>. It may be one of |
469
|
|
|
|
|
|
|
the following values: |
470
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
=over 8 |
472
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
=item I> (first time only) |
474
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
On the first time a serialization hook is called in a dump it may return |
476
|
|
|
|
|
|
|
undef or the empty list to indicate that it shouldn't be used again for |
477
|
|
|
|
|
|
|
this class during this pass. Any other time undef is treated the same |
478
|
|
|
|
|
|
|
as false. |
479
|
|
|
|
|
|
|
|
480
|
|
|
|
|
|
|
=item I |
481
|
|
|
|
|
|
|
|
482
|
|
|
|
|
|
|
A false value for C<$proxy> is taken to mean that it should be ignored. |
483
|
|
|
|
|
|
|
Its like saying IgnoreClass(ref($obj)); B that undef has a special |
484
|
|
|
|
|
|
|
meaning when the callback is called the first time. |
485
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
=item I |
487
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
A reference that will be dumped instead of the object. |
489
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
=item I |
491
|
|
|
|
|
|
|
|
492
|
|
|
|
|
|
|
A string that is to be treated as code and inserted directly into the |
493
|
|
|
|
|
|
|
dump stream as a proxy for the original. Note that the code must be |
494
|
|
|
|
|
|
|
able to execute inline or in other words must evaluate to a perl EXPR. |
495
|
|
|
|
|
|
|
Use C to wrap multistatement code. |
496
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
=back |
498
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
=item B> |
500
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
This values is used to allow extra control over how the object will be |
502
|
|
|
|
|
|
|
recreated when dumped. It is used for converting the C<$proxy> representation |
503
|
|
|
|
|
|
|
into the real thing. It is only relevant when C<$proxy> is a reference. |
504
|
|
|
|
|
|
|
|
505
|
|
|
|
|
|
|
=over 8 |
506
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
=item I |
508
|
|
|
|
|
|
|
|
509
|
|
|
|
|
|
|
Indicates no thaw action is to be included for this object. |
510
|
|
|
|
|
|
|
|
511
|
|
|
|
|
|
|
=item I |
512
|
|
|
|
|
|
|
|
513
|
|
|
|
|
|
|
A string matching C<< /^(->)?((?:\w*::)\w+)(\(\))?$/ >> in which case it |
514
|
|
|
|
|
|
|
is taken as a sub name when the string ends in () and a method name |
515
|
|
|
|
|
|
|
when the string doesn't. If the C<< -> >> is present then the sub or method |
516
|
|
|
|
|
|
|
is called inline. If it is not then the sub or method is called |
517
|
|
|
|
|
|
|
after the main dump. |
518
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
=item I |
520
|
|
|
|
|
|
|
|
521
|
|
|
|
|
|
|
Any other string, in which case the result will be taken as code |
522
|
|
|
|
|
|
|
which will be emitted after the main dump. It will be wrapped |
523
|
|
|
|
|
|
|
in a for loop that aliases C<$_> to the variable in question. |
524
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
=back |
526
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
=item B> |
528
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
This is the similar to C<$thaw> but is called in process instead |
530
|
|
|
|
|
|
|
of being emitted as part of the dump. Any return is ignored. |
531
|
|
|
|
|
|
|
It is only relevant when C<$proxy> is a reference. |
532
|
|
|
|
|
|
|
|
533
|
|
|
|
|
|
|
=over 8 |
534
|
|
|
|
|
|
|
|
535
|
|
|
|
|
|
|
=item I |
536
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
No postdump action is to occur. |
538
|
|
|
|
|
|
|
|
539
|
|
|
|
|
|
|
=item I |
540
|
|
|
|
|
|
|
|
541
|
|
|
|
|
|
|
The code ref will be called after serialization is complete |
542
|
|
|
|
|
|
|
with the object as the argument. |
543
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
=item I |
545
|
|
|
|
|
|
|
|
546
|
|
|
|
|
|
|
The method will be called after serialization is complete |
547
|
|
|
|
|
|
|
|
548
|
|
|
|
|
|
|
=back |
549
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
=back |
551
|
|
|
|
|
|
|
|
552
|
|
|
|
|
|
|
An example DDS_freeze method is one I had to put together for an object |
553
|
|
|
|
|
|
|
which contained a key whose value was a ref to an array tied to the value |
554
|
|
|
|
|
|
|
of another key. Dumping this got crazy, so I wanted to suppress dumping |
555
|
|
|
|
|
|
|
the tied array. I did it this way: |
556
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
sub DDS_freeze { |
558
|
|
|
|
|
|
|
my $self=shift; |
559
|
|
|
|
|
|
|
delete $self->{'tie'}; |
560
|
|
|
|
|
|
|
return ($self,'->fix_tie','fix_tie'); |
561
|
|
|
|
|
|
|
} |
562
|
|
|
|
|
|
|
|
563
|
|
|
|
|
|
|
sub fix_tie { |
564
|
|
|
|
|
|
|
my $self=shift; |
565
|
|
|
|
|
|
|
if ( ! $self->{'tie'} ) { |
566
|
|
|
|
|
|
|
$self->{str}="" unless defined $self->{str}; |
567
|
|
|
|
|
|
|
tie my @a, 'Tie::Array::PackedC', $self->{str}; |
568
|
|
|
|
|
|
|
$self->{'tie'} = \@a; |
569
|
|
|
|
|
|
|
} |
570
|
|
|
|
|
|
|
return $self; |
571
|
|
|
|
|
|
|
} |
572
|
|
|
|
|
|
|
|
573
|
|
|
|
|
|
|
The C<$postop> means the object is relatively unaffected after the |
574
|
|
|
|
|
|
|
dump, the C<$thaw> says that we should also include the method |
575
|
|
|
|
|
|
|
inline as we dump. An example dump of an object like this might be |
576
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
$Foo1=bless({ str=>'' },'Foo')->fix_tie(); |
578
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
Wheras if we omit the C<< -> >> then we would get: |
580
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
$Foo1=bless({ str=>'' },'Foo'); |
582
|
|
|
|
|
|
|
$Foo1->fix_tie(); |
583
|
|
|
|
|
|
|
|
584
|
|
|
|
|
|
|
In our example it wouldn't actually make a difference, but the former |
585
|
|
|
|
|
|
|
style can be nicer to read if the object is embedded in another. |
586
|
|
|
|
|
|
|
However the non arrow notation is slightly more dangerous, in that |
587
|
|
|
|
|
|
|
its possible that the internals of the object will not be fully linked |
588
|
|
|
|
|
|
|
when the method is evaluated. The second form guarantees that the object |
589
|
|
|
|
|
|
|
will be fully linked when the method is evaluated. |
590
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
See L for a different way |
592
|
|
|
|
|
|
|
to control the representation of hash based objects. |
593
|
|
|
|
|
|
|
|
594
|
|
|
|
|
|
|
=head2 Controlling Hash Traversal and Display Order |
595
|
|
|
|
|
|
|
|
596
|
|
|
|
|
|
|
When dumping a hash you may control the order the keys will be output |
597
|
|
|
|
|
|
|
and which keys will be included. The basic idea is to specify a subroutine |
598
|
|
|
|
|
|
|
which takes a hash as an argument and returns a reference to an array |
599
|
|
|
|
|
|
|
containing the keys to be dumped. |
600
|
|
|
|
|
|
|
|
601
|
|
|
|
|
|
|
You can use the L routine or the L routine to |
602
|
|
|
|
|
|
|
specify the sorter to be used. |
603
|
|
|
|
|
|
|
|
604
|
|
|
|
|
|
|
The routine will be called in the following way: |
605
|
|
|
|
|
|
|
|
606
|
|
|
|
|
|
|
( $key_array, $thaw ) = $sorter->($hash,($pass=0),$addr,$class); |
607
|
|
|
|
|
|
|
( $key_array,) = $sorter->($hash,($pass=1),$addr,$class); |
608
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
C<$hash> is the hash to be dumped, C<$addr> is the refaddr() of the |
610
|
|
|
|
|
|
|
C<$hash>, and C<$class> will be set if the hash has been blessed. |
611
|
|
|
|
|
|
|
|
612
|
|
|
|
|
|
|
When C<$pass> is 0 the C<$thaw> variable may be supplied as well as the |
613
|
|
|
|
|
|
|
keyorder. If it is defined then it specifies what thaw action to perform |
614
|
|
|
|
|
|
|
after dumping the hash. See L|/$thaw> in L
|
615
|
|
|
|
|
|
|
Representation> for details as to how it works. This allows an object |
616
|
|
|
|
|
|
|
to define those keys needed to recreate itself properly, and a followup |
617
|
|
|
|
|
|
|
hook to recreate the rest. |
618
|
|
|
|
|
|
|
|
619
|
|
|
|
|
|
|
B that if a L method is defined and returns |
620
|
|
|
|
|
|
|
a L|/$thaw> then the L|/$thaw> returned by the sorter |
621
|
|
|
|
|
|
|
will override it. |
622
|
|
|
|
|
|
|
|
623
|
|
|
|
|
|
|
=head2 Controlling Array Presentation and Run Length Encoding |
624
|
|
|
|
|
|
|
|
625
|
|
|
|
|
|
|
By default Data::Dump::Streamer will "run length encode" array values. |
626
|
|
|
|
|
|
|
This means that when an array value is simple (ie, its not referenced and |
627
|
|
|
|
|
|
|
does contain a reference) and is repeated multiple times the output will |
628
|
|
|
|
|
|
|
be single a list multiplier statement, and not each item output |
629
|
|
|
|
|
|
|
separately. Thus: L|/Dump> will be output something like |
630
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
$ARRAY1 = [ (0) x 4 ]; |
632
|
|
|
|
|
|
|
|
633
|
|
|
|
|
|
|
This is particularly useful when dealing with large arrays that are only |
634
|
|
|
|
|
|
|
partly filled, and when accidentally the array has been made very large, |
635
|
|
|
|
|
|
|
such as with the improper use of pseudo-hash notation. |
636
|
|
|
|
|
|
|
|
637
|
|
|
|
|
|
|
To disable this feature you may set the L property to FALSE, by |
638
|
|
|
|
|
|
|
default it is enabled and set to TRUE. |
639
|
|
|
|
|
|
|
|
640
|
|
|
|
|
|
|
=head2 Installing I as a package alias |
641
|
|
|
|
|
|
|
|
642
|
|
|
|
|
|
|
Its possible to have an alias to Data::Dump::Streamer created and |
643
|
|
|
|
|
|
|
installed for easier usage in one liners and short scripts. |
644
|
|
|
|
|
|
|
Data::Dump::Streamer is a bit long to type sometimes. However because this |
645
|
|
|
|
|
|
|
technically means polluting the root level namespace, and having it listed |
646
|
|
|
|
|
|
|
on CPAN, I have elected to have the installer not install it by default. |
647
|
|
|
|
|
|
|
If you wish it to be installed you must explicitly state so when |
648
|
|
|
|
|
|
|
Build.Pl is run: |
649
|
|
|
|
|
|
|
|
650
|
|
|
|
|
|
|
perl Build.Pl DDS [Other Module::Build options] |
651
|
|
|
|
|
|
|
|
652
|
|
|
|
|
|
|
Then a normal './Build test, ./Build install' invocation will install DDS. |
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
Using DDS is identical to Data::Dump::Streamer. |
655
|
|
|
|
|
|
|
|
656
|
|
|
|
|
|
|
=head2 use-time package aliasing |
657
|
|
|
|
|
|
|
|
658
|
|
|
|
|
|
|
You can also specify an alias at use-time, then use that alias in the rest |
659
|
|
|
|
|
|
|
of your program, thus avoiding the permanent (but modest) namespace |
660
|
|
|
|
|
|
|
pollution of the previous method. |
661
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
use Data::Dumper::Streamer as => 'DDS'; |
663
|
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
# or if you prefer |
665
|
|
|
|
|
|
|
use Data::Dumper::Streamer; |
666
|
|
|
|
|
|
|
import Data::Dumper::Streamer as => 'DDS'; |
667
|
|
|
|
|
|
|
|
668
|
|
|
|
|
|
|
You can use any alias you like, but that doesn't mean you should.. Folks |
669
|
|
|
|
|
|
|
doing as => 'DBI' will be mercilessly ridiculed. |
670
|
|
|
|
|
|
|
|
671
|
|
|
|
|
|
|
=head2 PadWalker support |
672
|
|
|
|
|
|
|
|
673
|
|
|
|
|
|
|
If PadWalker 1.0 is installed you can use DumpLex() to try to |
674
|
|
|
|
|
|
|
automatically determine the names of the vars being dumped. As |
675
|
|
|
|
|
|
|
long as the vars being dumped have my or our declarations in scope |
676
|
|
|
|
|
|
|
the vars will be correctly named. Padwalker will also be used |
677
|
|
|
|
|
|
|
instead of the B:: modules when dumping closures when it is available. |
678
|
|
|
|
|
|
|
|
679
|
|
|
|
|
|
|
=head1 INTERFACE |
680
|
|
|
|
|
|
|
|
681
|
|
|
|
|
|
|
=head2 Data::Dumper Compatibility |
682
|
|
|
|
|
|
|
|
683
|
|
|
|
|
|
|
For drop in compatibility with the Dumper() usage of Data::Dumper, you may |
684
|
|
|
|
|
|
|
request that the L method is exported. It will not be exported by |
685
|
|
|
|
|
|
|
default. In addition the standard Data::Dumper::Dumper() may be exported |
686
|
|
|
|
|
|
|
on request as C. If you provide the tag C<:Dumper> then both will |
687
|
|
|
|
|
|
|
be exported. |
688
|
|
|
|
|
|
|
|
689
|
|
|
|
|
|
|
=over 4 |
690
|
|
|
|
|
|
|
|
691
|
|
|
|
|
|
|
=item Dumper |
692
|
|
|
|
|
|
|
|
693
|
|
|
|
|
|
|
=item Dumper LIST |
694
|
|
|
|
|
|
|
|
695
|
|
|
|
|
|
|
A synonym for scalar Dump(LIST)->Out for usage compatibility with |
696
|
|
|
|
|
|
|
L |
697
|
|
|
|
|
|
|
|
698
|
|
|
|
|
|
|
=item DDumper |
699
|
|
|
|
|
|
|
|
700
|
|
|
|
|
|
|
=item DDumper LIST |
701
|
|
|
|
|
|
|
|
702
|
|
|
|
|
|
|
A secondary export of the actual L |
703
|
|
|
|
|
|
|
subroutine. |
704
|
|
|
|
|
|
|
|
705
|
|
|
|
|
|
|
=back |
706
|
|
|
|
|
|
|
|
707
|
|
|
|
|
|
|
=head2 Constructors |
708
|
|
|
|
|
|
|
|
709
|
|
|
|
|
|
|
=over 4 |
710
|
|
|
|
|
|
|
|
711
|
|
|
|
|
|
|
=item new |
712
|
|
|
|
|
|
|
|
713
|
|
|
|
|
|
|
Creates a new Data::Dump::Streamer object. Currently takes no |
714
|
|
|
|
|
|
|
arguments and simply returns the new object with a default style |
715
|
|
|
|
|
|
|
configuration. |
716
|
|
|
|
|
|
|
|
717
|
|
|
|
|
|
|
See C for a better way to do things. |
718
|
|
|
|
|
|
|
|
719
|
|
|
|
|
|
|
=cut |
720
|
|
|
|
|
|
|
|
721
|
|
|
|
|
|
|
sub _compressor { |
722
|
4
|
100
|
|
4
|
|
9
|
return "use Data::Dump::Streamer qw(usqz);\n" |
723
|
|
|
|
|
|
|
if !@_; |
724
|
2
|
|
|
|
|
7
|
return sqz($_[0], "usqz('", "')" ); |
725
|
|
|
|
|
|
|
} |
726
|
|
|
|
|
|
|
|
727
|
|
|
|
|
|
|
sub new { |
728
|
50
|
|
|
50
|
1
|
111165
|
my $class = shift; |
729
|
50
|
|
|
|
|
1090
|
my $self = bless { |
730
|
|
|
|
|
|
|
style => { |
731
|
|
|
|
|
|
|
hashsep => '=>', # use this to separate key vals |
732
|
|
|
|
|
|
|
arysep => ',', |
733
|
|
|
|
|
|
|
pairsep => ',', |
734
|
|
|
|
|
|
|
optspace => ' ', |
735
|
|
|
|
|
|
|
bless => 'bless()', # use this to bless objects, needs fixing |
736
|
|
|
|
|
|
|
|
737
|
|
|
|
|
|
|
compress => 0, # if nonzero use compressor to compress strings |
738
|
|
|
|
|
|
|
# longer than this value. |
739
|
|
|
|
|
|
|
compressor => \&_compressor, |
740
|
|
|
|
|
|
|
|
741
|
|
|
|
|
|
|
indent => 2, # should we indent at all? |
742
|
|
|
|
|
|
|
indentkeys => 1, # indent keys |
743
|
|
|
|
|
|
|
declare => 0, # predeclare vars? allows refs to root vars if 0 |
744
|
|
|
|
|
|
|
sortkeys => {}, |
745
|
|
|
|
|
|
|
verbose => 1, # use long names and detailed fill ins |
746
|
|
|
|
|
|
|
dumpglob => 1, # dump glob contents |
747
|
|
|
|
|
|
|
deparseglob => 1, |
748
|
|
|
|
|
|
|
deparse => 1, # deparse code refs? |
749
|
|
|
|
|
|
|
freezer => 'DDS_freeze', # default freezer |
750
|
|
|
|
|
|
|
freeze_class => {}, # freeze classes |
751
|
|
|
|
|
|
|
|
752
|
|
|
|
|
|
|
rle => 1, # run length encode arrays |
753
|
|
|
|
|
|
|
ignore => {}, # ignore classes |
754
|
|
|
|
|
|
|
indentcols => 2, # indent this number of cols |
755
|
|
|
|
|
|
|
ro => 1, # track readonly vars |
756
|
|
|
|
|
|
|
dualvars => 1, # dump dualvars |
757
|
|
|
|
|
|
|
eclipsename => "%s_eclipse_%d", |
758
|
|
|
|
|
|
|
|
759
|
|
|
|
|
|
|
purity => 1, # test |
760
|
|
|
|
|
|
|
|
761
|
|
|
|
|
|
|
# use this if deparse is 0 |
762
|
|
|
|
|
|
|
codestub => 'sub { Carp::confess "Dumped code stub!" }', |
763
|
|
|
|
|
|
|
formatstub => 'do{ local *F; eval "format F =\nFormat Stub\n.\n"; *F{FORMAT} }', |
764
|
|
|
|
|
|
|
# use these opts if deparse is 1 |
765
|
|
|
|
|
|
|
deparseopts => ["-sCi2v'Useless const omitted'"], |
766
|
|
|
|
|
|
|
special => 0, |
767
|
|
|
|
|
|
|
|
768
|
|
|
|
|
|
|
# not yet implemented |
769
|
|
|
|
|
|
|
array_warn => 10_000, # warn if an array has more than this number of elements |
770
|
|
|
|
|
|
|
array_chop => 32_767, # chop arrays over this size |
771
|
|
|
|
|
|
|
array_max => 1_000_000, # die if arrays have more than this size |
772
|
|
|
|
|
|
|
smart_array => 1, # special handling of very large arrays |
773
|
|
|
|
|
|
|
# with hashes as their 0 index. (pseudo-hash error detection) |
774
|
|
|
|
|
|
|
}, |
775
|
|
|
|
|
|
|
debug => 0, |
776
|
|
|
|
|
|
|
cataloged => 0, |
777
|
|
|
|
|
|
|
ref_id => 0, |
778
|
|
|
|
|
|
|
sv_id => 0 |
779
|
|
|
|
|
|
|
}, $class; |
780
|
|
|
|
|
|
|
|
781
|
50
|
|
|
|
|
212
|
return $self; |
782
|
|
|
|
|
|
|
} |
783
|
|
|
|
|
|
|
|
784
|
|
|
|
|
|
|
sub _safe_self { |
785
|
1002
|
|
|
1002
|
|
1058
|
my $self = shift; |
786
|
1002
|
100
|
|
|
|
2015
|
unless ( ref $self ) { |
787
|
7
|
|
|
|
|
15
|
$self = $self->new(); |
788
|
|
|
|
|
|
|
} |
789
|
1002
|
|
|
|
|
5466
|
return $self; |
790
|
|
|
|
|
|
|
} |
791
|
|
|
|
|
|
|
|
792
|
|
|
|
|
|
|
sub Dumper { |
793
|
0
|
|
|
0
|
1
|
0
|
return scalar Dump(@_)->Out(); |
794
|
|
|
|
|
|
|
} |
795
|
|
|
|
|
|
|
|
796
|
|
|
|
|
|
|
sub DDumper { |
797
|
0
|
|
|
0
|
1
|
0
|
return Data::Dumper::Dumper(@_); |
798
|
|
|
|
|
|
|
} |
799
|
|
|
|
|
|
|
|
800
|
|
|
|
|
|
|
#sub _is_utf8 { length $_[0] != do { use bytes; length $_[0] } } |
801
|
|
|
|
|
|
|
|
802
|
0
|
|
|
|
|
0
|
BEGIN { |
803
|
24
|
|
|
24
|
|
9337
|
my $numeric_rex=qr/\A-?(?:0|[1-9]\d*)(\.\d+(?
|
804
|
|
|
|
|
|
|
|
805
|
|
|
|
|
|
|
# used by _qquote below |
806
|
24
|
|
|
|
|
23328
|
my %esc = ( |
807
|
|
|
|
|
|
|
"\a" => "\\a", |
808
|
|
|
|
|
|
|
"\b" => "\\b", |
809
|
|
|
|
|
|
|
"\t" => "\\t", |
810
|
|
|
|
|
|
|
"\n" => "\\n", |
811
|
|
|
|
|
|
|
"\f" => "\\f", |
812
|
|
|
|
|
|
|
"\r" => "\\r", |
813
|
|
|
|
|
|
|
"\e" => "\\e", |
814
|
|
|
|
|
|
|
); |
815
|
|
|
|
|
|
|
|
816
|
|
|
|
|
|
|
# Taken from Data::Dumper::qquote() 2.12. |
817
|
|
|
|
|
|
|
# Changed utf8 handling from that version |
818
|
|
|
|
|
|
|
# put a string value in double quotes |
819
|
|
|
|
|
|
|
# Fixes by [ysth] |
820
|
|
|
|
|
|
|
sub _qquote { |
821
|
540
|
|
|
540
|
|
379
|
my $str = shift; |
822
|
540
|
|
|
|
|
383
|
my @ret; |
823
|
540
|
|
|
|
|
711
|
while (length($str)) { |
824
|
540
|
|
|
|
|
955
|
local($_)=substr($str,0,72,""); |
825
|
540
|
|
|
|
|
584
|
s/([\\\"\@\$])/\\$1/g; |
826
|
|
|
|
|
|
|
|
827
|
540
|
100
|
|
|
|
823
|
unless (/[^ !""\#\$%&''()*+,\-.\/0-9:;<=>?\@A-Z[\\\]^_`a-z{|}~]/) { |
828
|
508
|
|
|
|
|
629
|
push @ret,qq("$_"); # fast exit |
829
|
508
|
|
|
|
|
838
|
next; |
830
|
|
|
|
|
|
|
} |
831
|
|
|
|
|
|
|
|
832
|
|
|
|
|
|
|
|
833
|
32
|
|
|
|
|
120
|
s/([\a\b\t\n\f\r\e])/$esc{$1}/g; |
834
|
|
|
|
|
|
|
|
835
|
32
|
|
|
|
|
27
|
if ( ord('^') == 94 ) { |
836
|
|
|
|
|
|
|
# ascii / utf8 |
837
|
|
|
|
|
|
|
# no need for 3 digits in escape if followed by a digit |
838
|
32
|
|
|
|
|
30
|
s/([\0-\037])(?!\d) / sprintf '\\%o', ord($1)/xeg; |
|
0
|
|
|
|
|
0
|
|
839
|
32
|
|
|
|
|
31
|
s/([\0-\037\177]) / sprintf '\\%03o', ord($1)/xeg; |
|
0
|
|
|
|
|
0
|
|
840
|
|
|
|
|
|
|
|
841
|
24
|
100
|
|
24
|
|
134
|
if (length $_ != do { use bytes; length $_ }) { |
|
24
|
|
|
|
|
32
|
|
|
24
|
|
|
|
|
172
|
|
|
32
|
|
|
|
|
29
|
|
|
32
|
|
|
|
|
53
|
|
842
|
24
|
|
|
24
|
|
14612
|
use utf8; #perl 5.6.1 needs this, 5.9.2 doesn't. sigh |
|
24
|
|
|
|
|
224
|
|
|
24
|
|
|
|
|
94
|
|
843
|
6
|
|
|
|
|
12
|
s/([\200-\377]) / sprintf '\\%03o', ord($1)/xeg; |
|
0
|
|
|
|
|
0
|
|
844
|
6
|
|
|
|
|
16
|
s/([^\040-\176])/ sprintf '\\x{%x}', ord($1)/xeg; |
|
10
|
|
|
|
|
40
|
|
845
|
|
|
|
|
|
|
} else { |
846
|
|
|
|
|
|
|
# must not be under "use utf8" for 5.6.x |
847
|
26
|
|
|
|
|
30
|
s/([\200-\377]) / sprintf '\\%03o', ord($1)/xeg; |
|
2
|
|
|
|
|
15
|
|
848
|
|
|
|
|
|
|
} |
849
|
|
|
|
|
|
|
} else { |
850
|
|
|
|
|
|
|
# ebcdic |
851
|
|
|
|
|
|
|
s{([^ !""\#\$%&''()*+,\-.\/0-9:;<=>?\@A-Z[\\\]^_`a-z{|}~])(?!\d)} |
852
|
|
|
|
|
|
|
{ |
853
|
|
|
|
|
|
|
my $v = ord($1); '\\'.sprintf(($v <= 037 ? '%o' : '%03o'), $v) |
854
|
|
|
|
|
|
|
}eg; |
855
|
|
|
|
|
|
|
s{([^ !""\#\$%&''()*+,\-.\/0-9:;<=>?\@A-Z[\\\]^_`a-z{|}~])} |
856
|
|
|
|
|
|
|
{'\\'.sprintf('%03o',ord($1))}eg; |
857
|
|
|
|
|
|
|
} |
858
|
|
|
|
|
|
|
|
859
|
32
|
|
|
|
|
95
|
push @ret,qq("$_"); |
860
|
|
|
|
|
|
|
} |
861
|
540
|
|
|
|
|
1027
|
return join ".\n\t",@ret; |
862
|
|
|
|
|
|
|
} |
863
|
|
|
|
|
|
|
|
864
|
|
|
|
|
|
|
|
865
|
|
|
|
|
|
|
# single quote |
866
|
|
|
|
|
|
|
sub _quote { |
867
|
1747
|
|
|
1747
|
|
2427
|
my $v = join "", @_; |
868
|
1747
|
100
|
|
|
|
8772
|
if ($v=~$numeric_rex) { |
|
|
100
|
|
|
|
|
|
869
|
608
|
|
|
|
|
1000
|
return $v; |
870
|
|
|
|
|
|
|
} elsif ($v!~/[^\x20-\x7E]/) { |
871
|
1131
|
|
|
|
|
1039
|
$v =~ s/([\\''])/\\$1/g; |
872
|
1131
|
|
|
|
|
2793
|
return "'$v'"; |
873
|
|
|
|
|
|
|
} |
874
|
8
|
|
|
|
|
20
|
return _qquote($v); |
875
|
|
|
|
|
|
|
} |
876
|
|
|
|
|
|
|
|
877
|
|
|
|
|
|
|
# quote a key |
878
|
|
|
|
|
|
|
sub _quotekey { |
879
|
4764
|
|
|
4764
|
|
3864
|
my $key = shift; |
880
|
4764
|
50
|
33
|
|
|
36915
|
if (!defined($key) or $key eq '') { |
|
|
100
|
100
|
|
|
|
|
881
|
0
|
|
|
|
|
0
|
return '""' |
882
|
|
|
|
|
|
|
} elsif ($key=~$numeric_rex or $key =~ /\A-?[A-Za-z_]\w*\z/) { |
883
|
4232
|
|
|
|
|
7455
|
return $key |
884
|
|
|
|
|
|
|
} else { |
885
|
532
|
|
|
|
|
587
|
_qquote($key); |
886
|
|
|
|
|
|
|
} |
887
|
|
|
|
|
|
|
} |
888
|
|
|
|
|
|
|
} |
889
|
|
|
|
|
|
|
|
890
|
|
|
|
|
|
|
my %ttrans = ( |
891
|
|
|
|
|
|
|
reftype( {} ) => '%', |
892
|
|
|
|
|
|
|
reftype( [] ) => '@', |
893
|
|
|
|
|
|
|
reftype( \ 'foo' ) => '$', |
894
|
|
|
|
|
|
|
reftype( \\'foo' ) => '$', # REF |
895
|
|
|
|
|
|
|
reftype( sub{} ) => '&', |
896
|
|
|
|
|
|
|
'' => '$', |
897
|
|
|
|
|
|
|
); |
898
|
|
|
|
|
|
|
|
899
|
|
|
|
|
|
|
|
900
|
|
|
|
|
|
|
sub _make_name { |
901
|
790
|
|
|
790
|
|
832
|
my ( $self, $obj, $indx ) = @_; |
902
|
|
|
|
|
|
|
#warn Dumper($self->{unames})."'$self->{unames}' |
903
|
|
|
|
|
|
|
# : @{$self->{unames}||[]} @{[defined $indx ? $indx : '-']}"; |
904
|
790
|
|
100
|
|
|
3442
|
my $uname = ( $self->{unames} || [] )->[ $indx || 0 ]; |
|
|
|
100
|
|
|
|
|
905
|
|
|
|
|
|
|
|
906
|
790
|
100
|
|
|
|
1667
|
unless ($uname) { |
|
|
100
|
|
|
|
|
|
907
|
503
|
|
66
|
|
|
2517
|
my $name = blessed($_[1]) |
908
|
|
|
|
|
|
|
|| reftype($_[1]) |
909
|
|
|
|
|
|
|
|| ((readonly($_[1]) && (\$_[1] != \undef)) ? "RO" : "VAR"); |
910
|
503
|
100
|
|
|
|
887
|
unless ($self->{style}{verbose}) { |
911
|
2
|
|
|
|
|
2
|
my $n=1; |
912
|
2
|
|
|
|
|
4
|
(my $abr=$name)=~s/(\w)\w*::/$1/g; |
913
|
2
|
|
33
|
|
|
10
|
$self->{type_abrv}{$name}||=$name; |
914
|
2
|
|
33
|
|
|
11
|
while ($n<=length($abr) and |
|
|
|
33
|
|
|
|
|
915
|
|
|
|
|
|
|
$self->{type_abrv}{substr($abr,0,$n)} and |
916
|
|
|
|
|
|
|
$self->{type_abrv}{substr($abr,0,$n)} ne $name) { |
917
|
0
|
|
|
|
|
0
|
$n++; |
918
|
|
|
|
|
|
|
} |
919
|
2
|
50
|
|
|
|
4
|
if ($n<=length($abr)) { |
920
|
2
|
|
|
|
|
5
|
$self->{type_abrv}{substr($abr,0,$n)}=$name; |
921
|
|
|
|
|
|
|
return '$' . |
922
|
|
|
|
|
|
|
substr($abr,0,$n) . |
923
|
2
|
|
|
|
|
8
|
( ++$self->{type_ids}{$name} ); |
924
|
|
|
|
|
|
|
} |
925
|
|
|
|
|
|
|
} |
926
|
501
|
|
|
|
|
674
|
$name =~ s/::/_/g; |
927
|
501
|
|
|
|
|
1517
|
($name)=$name=~/(\w+)/; #take the first word; |
928
|
501
|
|
|
|
|
1690
|
return '$' . $name . ( ++$self->{type_ids}{$name} ); |
929
|
|
|
|
|
|
|
} elsif ( $uname =~ /^[-*]/ ) { |
930
|
155
|
|
100
|
|
|
467
|
my $type = reftype( $_[1] ) || ''; |
931
|
155
|
|
|
|
|
723
|
$uname =~ s//$ttrans{$type}/; |
932
|
155
|
|
|
|
|
393
|
$uname; |
933
|
|
|
|
|
|
|
} else { |
934
|
132
|
|
|
|
|
357
|
return '$' . $uname; |
935
|
|
|
|
|
|
|
} |
936
|
|
|
|
|
|
|
} |
937
|
|
|
|
|
|
|
|
938
|
|
|
|
|
|
|
#=item diag |
939
|
|
|
|
|
|
|
# |
940
|
|
|
|
|
|
|
#Outputs to STDOUT a list of all values that have been identified of being |
941
|
|
|
|
|
|
|
#worth of study. For development/debugging purposes only at this point. |
942
|
|
|
|
|
|
|
# |
943
|
|
|
|
|
|
|
#=cut |
944
|
|
|
|
|
|
|
|
945
|
|
|
|
|
|
|
sub diag { |
946
|
0
|
|
|
0
|
0
|
0
|
my $self=shift; |
947
|
0
|
|
0
|
|
|
0
|
my $handle=shift || \*STDOUT; |
948
|
0
|
|
|
|
|
0
|
print $handle "+---+\n"; |
949
|
|
|
|
|
|
|
|
950
|
0
|
|
|
|
|
0
|
my $oidx; |
951
|
0
|
|
|
|
|
0
|
foreach my $idx (1..$self->{sv_id}) { |
952
|
0
|
|
|
|
|
0
|
print $handle $self->diag_sv_idx($idx); |
953
|
|
|
|
|
|
|
} |
954
|
0
|
0
|
0
|
|
|
0
|
print "-----\n" if $self->{ref_id} and $self->{sv_id}; |
955
|
0
|
|
0
|
|
|
0
|
foreach my $idx (1..($self->{ref_id}||0)) { |
956
|
0
|
|
|
|
|
0
|
print $handle $self->diag_ref_idx($idx); |
957
|
|
|
|
|
|
|
|
958
|
|
|
|
|
|
|
} |
959
|
0
|
|
|
|
|
0
|
print $handle "+---+\n"; |
960
|
0
|
|
|
|
|
0
|
$self; |
961
|
|
|
|
|
|
|
} |
962
|
|
|
|
|
|
|
|
963
|
|
|
|
|
|
|
sub remove_deref { |
964
|
4689
|
|
|
4689
|
0
|
4476
|
my $var=shift; |
965
|
|
|
|
|
|
|
|
966
|
4689
|
|
|
|
|
3311
|
my ($brace,$rest,$sigil); |
967
|
4689
|
100
|
|
|
|
8389
|
if ($var=~s/^([\@\%\$])(?=\$)//) { |
968
|
220
|
|
|
|
|
357
|
($sigil,$brace)=($1,$var) |
969
|
|
|
|
|
|
|
} else { |
970
|
4469
|
|
|
|
|
3460
|
local $@; |
971
|
4469
|
|
|
|
|
13939
|
($brace,$rest,$sigil)= Text::Balanced::extract_bracketed( $var, '{q}',qr/[\@\%\$]/ ); |
972
|
|
|
|
|
|
|
} |
973
|
4689
|
100
|
100
|
|
|
224627
|
if ($brace and !$rest) { |
974
|
406
|
|
|
|
|
1013
|
$brace=~s/^\{(.*)\}$/$1/; |
975
|
406
|
50
|
|
|
|
1077
|
return wantarray ? ($sigil,$brace) : $brace; |
976
|
|
|
|
|
|
|
} else { |
977
|
4283
|
|
|
|
|
5483
|
return; |
978
|
|
|
|
|
|
|
} |
979
|
|
|
|
|
|
|
} |
980
|
|
|
|
|
|
|
|
981
|
|
|
|
|
|
|
my %tname=qw(HASH % ARRAY @ SCALAR $ REF $); |
982
|
|
|
|
|
|
|
|
983
|
|
|
|
|
|
|
sub _build_name { |
984
|
5711
|
|
|
5711
|
|
6623
|
my ( $self, $name, $type, $val ) = @_; |
985
|
|
|
|
|
|
|
|
986
|
5711
|
50
|
|
|
|
7784
|
$DEBUG>1 and print STDOUT " _build_name( $name '$type' => "; |
987
|
5711
|
50
|
|
|
|
8289
|
$type=$tname{$type} if $tname{$type}; |
988
|
5711
|
100
|
|
|
|
12185
|
if ($type=~/[[{]/) { |
|
|
50
|
|
|
|
|
|
989
|
|
|
|
|
|
|
|
990
|
4579
|
|
|
|
|
4722
|
$name=~s/[\@\%]\$/\$/; |
991
|
4579
|
|
|
|
|
5266
|
my ($sigil,$brace)=remove_deref($name); |
992
|
4579
|
100
|
100
|
|
|
19320
|
if ( $name =~ /^([\@\%\$])(\w+)$/ or $sigil |
|
|
|
100
|
|
|
|
|
993
|
|
|
|
|
|
|
or $name=~/^\*.*\{(?:SCALAR|HASH|ARRAY)\}$/ |
994
|
|
|
|
|
|
|
) |
995
|
|
|
|
|
|
|
{ |
996
|
|
|
|
|
|
|
|
997
|
3243
|
100
|
66
|
|
|
8954
|
$name .= '->' if !($name =~ s/^[\@\%]/\$/) |
998
|
|
|
|
|
|
|
or $sigil; |
999
|
3243
|
|
|
|
|
4329
|
$name=~s/^\$(\$.*)->$/\$\{$1\}->/; |
1000
|
|
|
|
|
|
|
} |
1001
|
|
|
|
|
|
|
|
1002
|
4579
|
50
|
|
|
|
6530
|
$DEBUG>1 and print STDOUT "$name => "; |
1003
|
|
|
|
|
|
|
|
1004
|
4579
|
100
|
|
|
|
6909
|
if ( $type eq '[' ) { |
|
|
50
|
|
|
|
|
|
1005
|
2197
|
|
|
|
|
3241
|
$name .= "[$val]"; |
1006
|
|
|
|
|
|
|
} elsif ( $type eq '{' ) { |
1007
|
2382
|
|
|
|
|
3131
|
$name .= "{" . _quotekey($val) . "}"; |
1008
|
|
|
|
|
|
|
} else { |
1009
|
0
|
|
|
|
|
0
|
Carp::confess "Fallen off the end of the world..."; |
1010
|
|
|
|
|
|
|
} |
1011
|
|
|
|
|
|
|
} elsif ( $type =~ /^[\@\%\$]$/ ) { |
1012
|
1132
|
100
|
100
|
|
|
3590
|
$name = "{$name}" |
1013
|
|
|
|
|
|
|
if $name =~ /[\[\{]/ or $name=~/^\*/; |
1014
|
1132
|
50
|
66
|
|
|
3671
|
$name = $type . $name |
1015
|
|
|
|
|
|
|
unless substr( $name, 0, 1 ) eq $type and $type ne '$'; |
1016
|
|
|
|
|
|
|
|
1017
|
|
|
|
|
|
|
} else { |
1018
|
24
|
|
|
24
|
|
143
|
no warnings; # XXX - why is this here? Yves |
|
24
|
|
|
|
|
28
|
|
|
24
|
|
|
|
|
165478
|
|
1019
|
0
|
|
|
|
|
0
|
Carp::confess "unimplemented _build_name"; |
1020
|
|
|
|
|
|
|
} |
1021
|
5711
|
50
|
|
|
|
8345
|
$DEBUG>1 and print "$name )\n"; |
1022
|
5711
|
|
|
|
|
11155
|
$name; |
1023
|
|
|
|
|
|
|
} |
1024
|
|
|
|
|
|
|
|
1025
|
|
|
|
|
|
|
sub _reset { |
1026
|
352
|
|
|
352
|
|
361
|
my $self=shift; |
1027
|
352
|
|
|
|
|
2282
|
foreach my $key (keys %$self) { |
1028
|
11353
|
100
|
|
|
|
18567
|
next unless $key=~/^(sv|ref|fix|cat|type|names|reqs|cache)/; |
1029
|
8672
|
|
|
|
|
10744
|
delete $self->{$key}; |
1030
|
|
|
|
|
|
|
} |
1031
|
352
|
|
|
|
|
1016
|
$self->{sv_id}=$self->{ref_id}=0; |
1032
|
352
|
|
|
|
|
422
|
$self; |
1033
|
|
|
|
|
|
|
} |
1034
|
|
|
|
|
|
|
|
1035
|
|
|
|
|
|
|
sub diag_sv_idx { |
1036
|
0
|
|
|
0
|
0
|
0
|
my $self=shift; |
1037
|
0
|
|
|
|
|
0
|
my $idx=shift; |
1038
|
0
|
|
0
|
|
|
0
|
my $prefix=shift||''; |
1039
|
0
|
|
|
|
|
0
|
my $oidx=$self->{ref}{$self->{sva}[$idx]}; |
1040
|
|
|
|
|
|
|
my $ret=$prefix. |
1041
|
|
|
|
|
|
|
sprintf "S%s%2d : %#x(c%2d|%2d) Dp:%2d %s Du:%s => %s %s %s %s\n", |
1042
|
|
|
|
|
|
|
($self->{special}{$idx} ? '*' : ' '),$idx, |
1043
|
0
|
|
|
|
|
0
|
(map { $self->{$_}[$idx] } qw( sva svc svt svd )), |
1044
|
|
|
|
|
|
|
($self->{svro}[$idx] ? 'RO ' : 'RW'), |
1045
|
|
|
|
|
|
|
(!$self->{svdu}[$idx] |
1046
|
|
|
|
|
|
|
? '-' |
1047
|
0
|
|
|
|
|
0
|
: defined ${$self->{svdu}[$idx]} |
1048
|
0
|
|
|
|
|
0
|
? ${$self->{svdu}[$idx]} |
1049
|
|
|
|
|
|
|
: '?'), |
1050
|
|
|
|
|
|
|
$self->{svn}[$idx], |
1051
|
|
|
|
|
|
|
(defined $self->{unames}[$idx-1] ? "($self->{unames}[$idx-1])" : ""), |
1052
|
|
|
|
|
|
|
(($oidx) ? "< $self->{refn}[$oidx] >" : ""), |
1053
|
0
|
0
|
|
|
|
0
|
($self->{svon}{$idx} ? ": $self->{svon}{$idx}" : "") |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1054
|
|
|
|
|
|
|
; |
1055
|
0
|
0
|
0
|
|
|
0
|
if ($prefix and $oidx) { |
1056
|
0
|
|
|
|
|
0
|
$ret.=$prefix.$self->diag_ref_idx($oidx); |
1057
|
|
|
|
|
|
|
} |
1058
|
0
|
|
|
|
|
0
|
$ret; |
1059
|
|
|
|
|
|
|
} |
1060
|
|
|
|
|
|
|
|
1061
|
|
|
|
|
|
|
sub diag_ref_idx { |
1062
|
0
|
|
|
0
|
0
|
0
|
my $self=shift; |
1063
|
0
|
|
|
|
|
0
|
my $idx=shift; |
1064
|
0
|
|
|
|
|
0
|
my $oidx=$self->{sv}{$self->{refa}[$idx]}; |
1065
|
|
|
|
|
|
|
sprintf "R %2d : %#x(c%2d|%2d) Dp:%2d Du:%s => %s %s\n", |
1066
|
|
|
|
|
|
|
$idx, |
1067
|
|
|
|
|
|
|
(map { |
1068
|
0
|
0
|
|
|
|
0
|
defined $self->{$_}[$idx] ? $self->{$_}[$idx] : -1 |
1069
|
|
|
|
|
|
|
} qw(refa refc reft refd )), |
1070
|
|
|
|
|
|
|
(!$self->{refdu}[$idx] |
1071
|
|
|
|
|
|
|
? '-' |
1072
|
0
|
|
|
|
|
0
|
: defined ${$self->{refdu}[$idx]} |
1073
|
0
|
|
|
|
|
0
|
? ${$self->{refdu}[$idx]} |
1074
|
|
|
|
|
|
|
: '?'), |
1075
|
0
|
0
|
|
|
|
0
|
$self->{refn}[$idx], |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
1076
|
|
|
|
|
|
|
(($oidx) ? " < $self->{svn}[$oidx] >" : "") |
1077
|
|
|
|
|
|
|
; |
1078
|
|
|
|
|
|
|
} |
1079
|
|
|
|
|
|
|
|
1080
|
|
|
|
|
|
|
|
1081
|
|
|
|
|
|
|
=item Dump |
1082
|
|
|
|
|
|
|
|
1083
|
|
|
|
|
|
|
=item Dump VALUES |
1084
|
|
|
|
|
|
|
|
1085
|
|
|
|
|
|
|
Smart non method based constructor. |
1086
|
|
|
|
|
|
|
|
1087
|
|
|
|
|
|
|
This routine behaves very differently depending on the context it is |
1088
|
|
|
|
|
|
|
called in and whether arguments are provided. |
1089
|
|
|
|
|
|
|
|
1090
|
|
|
|
|
|
|
If called with no arguments it is exactly equivalent to calling |
1091
|
|
|
|
|
|
|
|
1092
|
|
|
|
|
|
|
Data::Dump::Streamer->new() |
1093
|
|
|
|
|
|
|
|
1094
|
|
|
|
|
|
|
which means it returns an object reference. |
1095
|
|
|
|
|
|
|
|
1096
|
|
|
|
|
|
|
If called with arguments and in scalar context it is equivalent to calling |
1097
|
|
|
|
|
|
|
|
1098
|
|
|
|
|
|
|
Data::Dump::Streamer->new()->Data(@vals) |
1099
|
|
|
|
|
|
|
|
1100
|
|
|
|
|
|
|
except that the actual depth first traversal is I until C |
1101
|
|
|
|
|
|
|
is called. This means that options that must be provided before the |
1102
|
|
|
|
|
|
|
C phase can be provided after the call to C. Again, it |
1103
|
|
|
|
|
|
|
returns a object reference. |
1104
|
|
|
|
|
|
|
|
1105
|
|
|
|
|
|
|
If called with arguments and in void or list context it is equivelent to |
1106
|
|
|
|
|
|
|
calling |
1107
|
|
|
|
|
|
|
|
1108
|
|
|
|
|
|
|
Data::Dump::Streamer->new()->Data(@vals)->Out() |
1109
|
|
|
|
|
|
|
|
1110
|
|
|
|
|
|
|
The reason this is true in list context is to make |
1111
|
|
|
|
|
|
|
C do the right thing. And also that combined with |
1112
|
|
|
|
|
|
|
method chaining options can be added or removed as required quite easily |
1113
|
|
|
|
|
|
|
and naturally. |
1114
|
|
|
|
|
|
|
|
1115
|
|
|
|
|
|
|
So to put it short: |
1116
|
|
|
|
|
|
|
|
1117
|
|
|
|
|
|
|
my $obj=Dump($x,$y); # Returns an object |
1118
|
|
|
|
|
|
|
my $str=Dump($x,$y)->Out(); # Returns a string of the dump. |
1119
|
|
|
|
|
|
|
my @code=Dump($x,$y); # Returns a list of the dump. |
1120
|
|
|
|
|
|
|
|
1121
|
|
|
|
|
|
|
Dump($x,$y); # prints the dump. |
1122
|
|
|
|
|
|
|
print Dump($x,$y); # prints the dump. |
1123
|
|
|
|
|
|
|
|
1124
|
|
|
|
|
|
|
It should be noted that the setting of C<$\> will affect the behaviour of |
1125
|
|
|
|
|
|
|
both of |
1126
|
|
|
|
|
|
|
|
1127
|
|
|
|
|
|
|
Dump($x,$y); |
1128
|
|
|
|
|
|
|
print Dump($x,$y); |
1129
|
|
|
|
|
|
|
|
1130
|
|
|
|
|
|
|
but it will not affect the behaviour of |
1131
|
|
|
|
|
|
|
|
1132
|
|
|
|
|
|
|
print scalar Dump($x,$y); |
1133
|
|
|
|
|
|
|
|
1134
|
|
|
|
|
|
|
B As of 1.11 Dump also works as a method, with identical properties |
1135
|
|
|
|
|
|
|
as when called as a subroutine, with the exception that when called with |
1136
|
|
|
|
|
|
|
no arguments it is a synonym for C. Thus |
1137
|
|
|
|
|
|
|
|
1138
|
|
|
|
|
|
|
$obj->Dump($foo)->Names('foo')->Out(); |
1139
|
|
|
|
|
|
|
|
1140
|
|
|
|
|
|
|
will work fine, as will the odd looking: |
1141
|
|
|
|
|
|
|
|
1142
|
|
|
|
|
|
|
$obj->Dump($foo)->Names('foo')->Dump(); |
1143
|
|
|
|
|
|
|
|
1144
|
|
|
|
|
|
|
which are both the same as |
1145
|
|
|
|
|
|
|
|
1146
|
|
|
|
|
|
|
$obj->Names('foo')->Data($foo)->Out(); |
1147
|
|
|
|
|
|
|
|
1148
|
|
|
|
|
|
|
Hopefully this should make method use more or less DWIM. |
1149
|
|
|
|
|
|
|
|
1150
|
|
|
|
|
|
|
=cut |
1151
|
|
|
|
|
|
|
|
1152
|
|
|
|
|
|
|
my %args_insideout; |
1153
|
|
|
|
|
|
|
|
1154
|
|
|
|
|
|
|
sub DESTROY { |
1155
|
47
|
|
|
47
|
|
18086
|
my $self=shift; |
1156
|
47
|
50
|
|
|
|
1475
|
delete $args_insideout{Data::Dump::Streamer::refaddr $self} if $self; |
1157
|
|
|
|
|
|
|
} |
1158
|
|
|
|
|
|
|
|
1159
|
|
|
|
|
|
|
sub Dump { |
1160
|
34
|
|
|
34
|
1
|
26455
|
my $obj; |
1161
|
34
|
100
|
100
|
|
|
206
|
if ( blessed($_[0]) and blessed($_[0]) eq __PACKAGE__ ) { |
1162
|
3
|
|
|
|
|
4
|
$obj=shift; |
1163
|
|
|
|
|
|
|
} |
1164
|
34
|
100
|
|
|
|
86
|
if (@_) { |
1165
|
15
|
100
|
66
|
|
|
66
|
if ( defined wantarray and !wantarray ) { |
1166
|
8
|
|
66
|
|
|
37
|
$obj ||= __PACKAGE__->new(); |
1167
|
8
|
|
|
|
|
22
|
$obj->_make_args(@_); |
1168
|
8
|
|
|
|
|
39
|
return $obj; |
1169
|
|
|
|
|
|
|
} else { |
1170
|
7
|
|
50
|
|
|
22
|
$obj||=__PACKAGE__; |
1171
|
7
|
|
|
|
|
27
|
return $obj->Data(@_)->Out(); |
1172
|
|
|
|
|
|
|
} |
1173
|
|
|
|
|
|
|
} else { |
1174
|
19
|
100
|
|
|
|
69
|
if ($obj) { |
1175
|
2
|
|
|
|
|
7
|
return $obj->Out(); |
1176
|
|
|
|
|
|
|
} else { |
1177
|
17
|
|
|
|
|
62
|
return __PACKAGE__->new(); |
1178
|
|
|
|
|
|
|
} |
1179
|
|
|
|
|
|
|
} |
1180
|
|
|
|
|
|
|
} |
1181
|
|
|
|
|
|
|
|
1182
|
|
|
|
|
|
|
|
1183
|
|
|
|
|
|
|
=item DumpLex VALUES |
1184
|
|
|
|
|
|
|
|
1185
|
|
|
|
|
|
|
DumpLex is similar to Dump except it will try to automatically determine |
1186
|
|
|
|
|
|
|
the names to use for the variables being dumped by using PadWalker to |
1187
|
|
|
|
|
|
|
have a poke around the calling lexical scope to see what is declared. If |
1188
|
|
|
|
|
|
|
a name for a var can't be found then it will be named according to the |
1189
|
|
|
|
|
|
|
normal scheme. When PadWalker isn't installed this is just a wrapper for |
1190
|
|
|
|
|
|
|
L. |
1191
|
|
|
|
|
|
|
|
1192
|
|
|
|
|
|
|
Thanks to Ovid for the idea of this. See L for a |
1193
|
|
|
|
|
|
|
similar wrapper around L. |
1194
|
|
|
|
|
|
|
|
1195
|
|
|
|
|
|
|
=cut |
1196
|
|
|
|
|
|
|
|
1197
|
|
|
|
|
|
|
|
1198
|
|
|
|
|
|
|
sub DumpLex { |
1199
|
2
|
50
|
|
2
|
1
|
79
|
if ( ! $HasPadWalker ) { |
1200
|
|
|
|
|
|
|
#warn( "Can't use DumpLex without ". |
1201
|
|
|
|
|
|
|
# "PadWalker v1.0 or later installed."); |
1202
|
0
|
|
|
|
|
0
|
goto &Dump; |
1203
|
|
|
|
|
|
|
} |
1204
|
2
|
|
|
|
|
3
|
my $obj; |
1205
|
2
|
50
|
33
|
|
|
9
|
if ( blessed($_[0]) and blessed($_[0]) eq __PACKAGE__ ) { |
1206
|
0
|
|
|
|
|
0
|
$obj=shift; |
1207
|
|
|
|
|
|
|
} |
1208
|
2
|
|
|
|
|
2
|
my @names; |
1209
|
|
|
|
|
|
|
# = map { |
1210
|
|
|
|
|
|
|
# PadWalker::var_name(1,\$_) |
1211
|
|
|
|
|
|
|
# || PadWalker::var_name(1,\$_) |
1212
|
|
|
|
|
|
|
# (ref $_ && PadWalker::var_name(1,$_)); |
1213
|
|
|
|
|
|
|
# $str |
1214
|
|
|
|
|
|
|
# } @_; |
1215
|
|
|
|
|
|
|
#if ( !@names && @_ ) { |
1216
|
|
|
|
|
|
|
|
1217
|
|
|
|
|
|
|
my %pad_vars; |
1218
|
2
|
|
|
|
|
38
|
foreach my $pad ( PadWalker::peek_my(1), |
1219
|
|
|
|
|
|
|
PadWalker::peek_our(1) |
1220
|
|
|
|
|
|
|
){ |
1221
|
4
|
|
|
|
|
12
|
while (my ($var,$ref) = each %$pad) { |
1222
|
19
|
|
33
|
|
|
76
|
$pad_vars{ refaddr $ref } ||= $var; |
1223
|
|
|
|
|
|
|
} |
1224
|
|
|
|
|
|
|
} |
1225
|
2
|
|
|
|
|
6
|
foreach (@_) { |
1226
|
5
|
|
|
|
|
4
|
my $name; |
1227
|
5
|
|
|
|
|
6
|
INNER:foreach ( \$_, $_ ) { |
1228
|
7
|
100
|
|
|
|
16
|
$name=$pad_vars{refaddr $_} |
1229
|
|
|
|
|
|
|
and last INNER; |
1230
|
|
|
|
|
|
|
} |
1231
|
5
|
|
|
|
|
6
|
push @names, $name; |
1232
|
|
|
|
|
|
|
} |
1233
|
2
|
50
|
33
|
|
|
10
|
if ( defined wantarray and !wantarray ) { |
1234
|
2
|
|
33
|
|
|
6
|
$obj ||= __PACKAGE__->new(); |
1235
|
2
|
|
|
|
|
5
|
$obj->_make_args(@_); |
1236
|
2
|
|
|
|
|
4
|
$obj->Names(@names); |
1237
|
2
|
|
|
|
|
8
|
return $obj; |
1238
|
|
|
|
|
|
|
} else { |
1239
|
0
|
|
0
|
|
|
0
|
$obj||=__PACKAGE__; |
1240
|
0
|
|
|
|
|
0
|
return $obj->Names(@names)->Data(@_)->Out(); |
1241
|
|
|
|
|
|
|
} |
1242
|
|
|
|
|
|
|
} |
1243
|
|
|
|
|
|
|
|
1244
|
|
|
|
|
|
|
=item DumpVars PAIRS |
1245
|
|
|
|
|
|
|
|
1246
|
|
|
|
|
|
|
This is wrapper around L which expect to receive |
1247
|
|
|
|
|
|
|
a list of name=>value pairs instead of a list of values. |
1248
|
|
|
|
|
|
|
Otherwise behaves like L. Note that names starting |
1249
|
|
|
|
|
|
|
with a '-' are treated the same as those starting with '*' when |
1250
|
|
|
|
|
|
|
passed to L. |
1251
|
|
|
|
|
|
|
|
1252
|
|
|
|
|
|
|
=cut |
1253
|
|
|
|
|
|
|
|
1254
|
|
|
|
|
|
|
|
1255
|
|
|
|
|
|
|
sub DumpVars { |
1256
|
1
|
|
|
1
|
1
|
2
|
my $obj; |
1257
|
1
|
50
|
33
|
|
|
5
|
if ( blessed($_[0]) and blessed($_[0]) eq __PACKAGE__ ) { |
1258
|
0
|
|
|
|
|
0
|
$obj=shift; |
1259
|
|
|
|
|
|
|
} |
1260
|
1
|
50
|
|
|
|
3
|
if (@_ % 2) { |
1261
|
0
|
|
|
|
|
0
|
warnings::warnif "Odd number of arguments in DumpVars"; |
1262
|
0
|
|
|
|
|
0
|
pop @_; |
1263
|
|
|
|
|
|
|
} |
1264
|
1
|
|
|
|
|
2
|
my @names; |
1265
|
|
|
|
|
|
|
my @args; |
1266
|
1
|
|
|
|
|
4
|
for ( 0 .. $#_/2 ) { |
1267
|
3
|
|
|
|
|
5
|
$names[$_]=$_[$_*2]; |
1268
|
3
|
|
|
|
|
4
|
$args[$_]=$_*2+1; |
1269
|
|
|
|
|
|
|
} |
1270
|
|
|
|
|
|
|
#die "@_:@names|@args"; |
1271
|
1
|
50
|
33
|
|
|
14
|
if ( defined wantarray and !wantarray ) { |
1272
|
1
|
|
33
|
|
|
5
|
$obj ||= __PACKAGE__->new(); |
1273
|
1
|
|
|
|
|
3
|
$obj->_make_args(@_[@args]); |
1274
|
1
|
|
|
|
|
2
|
$obj->Names(@names); |
1275
|
1
|
|
|
|
|
3
|
return $obj; |
1276
|
|
|
|
|
|
|
} else { |
1277
|
0
|
|
0
|
|
|
0
|
$obj||=__PACKAGE__; |
1278
|
0
|
|
|
|
|
0
|
return $obj->Data(@_[@args])->Names(@names)->Out(); |
1279
|
|
|
|
|
|
|
} |
1280
|
|
|
|
|
|
|
} |
1281
|
|
|
|
|
|
|
|
1282
|
|
|
|
|
|
|
|
1283
|
|
|
|
|
|
|
sub _reg_ref { |
1284
|
2277
|
|
|
2277
|
|
2509
|
my ($self,$item,$depth,$name,$cnt,$arg)=@_; |
1285
|
|
|
|
|
|
|
|
1286
|
2277
|
50
|
|
|
|
2851
|
warn "_ref_ref($depth,$name,$cnt)\n" if $DEBUG; |
1287
|
|
|
|
|
|
|
|
1288
|
2277
|
|
|
|
|
2519
|
my $addr=refaddr $item; |
1289
|
2277
|
100
|
|
|
|
3243
|
$arg->{raddr}=$addr if $arg; |
1290
|
2277
|
|
|
|
|
1621
|
my $idx; |
1291
|
2277
|
100
|
|
|
|
4312
|
unless ($idx=$self->{ref}{$addr}) { |
1292
|
1577
|
|
|
|
|
2550
|
$idx=$self->{ref}{$addr}=++$self->{ref_id}; |
1293
|
1577
|
100
|
|
|
|
2801
|
$arg->{ridx}=$idx if $arg; |
1294
|
1577
|
|
|
|
|
2063
|
$self->{refn}[$idx]=$name; |
1295
|
1577
|
|
|
|
|
1632
|
$self->{refd}[$idx]=$depth; |
1296
|
1577
|
|
|
|
|
1809
|
$self->{refa}[$idx]=$addr; |
1297
|
1577
|
|
|
|
|
1479
|
$self->{refc}[$idx]=$cnt; |
1298
|
1577
|
50
|
|
|
|
3692
|
return wantarray ? ($idx,0) : $idx |
1299
|
|
|
|
|
|
|
} |
1300
|
700
|
|
|
|
|
846
|
$self->{reft}[$idx]++; |
1301
|
700
|
100
|
|
|
|
986
|
$arg->{ridx}=$idx if $arg; |
1302
|
700
|
50
|
|
|
|
1242
|
return wantarray ? ($idx,1) : undef; |
1303
|
|
|
|
|
|
|
} |
1304
|
|
|
|
|
|
|
|
1305
|
|
|
|
|
|
|
|
1306
|
|
|
|
|
|
|
sub _reg_scalar { |
1307
|
1548
|
|
|
1548
|
|
1928
|
my ($self,$item,$depth,$cnt,$ro,$name,$arg)=@_; |
1308
|
1548
|
50
|
|
|
|
2631
|
Carp::cluck $name if $name=~/^\$\*/; |
1309
|
1548
|
|
|
|
|
2168
|
my $addr=refaddr \$_[1]; |
1310
|
1548
|
|
|
|
|
1226
|
my $idx; |
1311
|
1548
|
100
|
|
|
|
2549
|
$arg->{addr}=$addr if $arg; |
1312
|
1548
|
100
|
|
|
|
2955
|
unless ($idx=$self->{sv}{$addr}) { |
1313
|
1209
|
|
|
|
|
1971
|
$idx=$self->{sv}{$addr}=++$self->{sv_id}; |
1314
|
1209
|
|
|
|
|
1415
|
$self->{svd}[$idx]=$depth; |
1315
|
1209
|
|
|
|
|
1377
|
$self->{sva}[$idx]=$addr; |
1316
|
1209
|
|
|
|
|
1165
|
$self->{svro}[$idx]=$ro; |
1317
|
1209
|
|
|
|
|
1136
|
$self->{svc}[$idx]=$cnt; |
1318
|
1209
|
100
|
|
|
|
2455
|
$self->{svw}{$addr}=!0 |
1319
|
|
|
|
|
|
|
if isweak($_[1]); |
1320
|
1209
|
|
|
|
|
2384
|
($self->{svn}[$idx]=$name)=~s/^[\@\%\&]/\$/; |
1321
|
1209
|
100
|
|
|
|
2244
|
if ($self->{svn}[$idx] ne $name) { |
1322
|
139
|
|
|
|
|
208
|
$self->{svn}[$idx].="_"; #XXX |
1323
|
|
|
|
|
|
|
#warn "$self->{svn}[$idx] ne $name" |
1324
|
139
|
|
|
|
|
338
|
$self->{svon}{$idx}=$name; |
1325
|
|
|
|
|
|
|
} |
1326
|
|
|
|
|
|
|
|
1327
|
|
|
|
|
|
|
} else{ |
1328
|
339
|
50
|
|
|
|
499
|
if ($DEBUG>9) { |
1329
|
0
|
|
|
|
|
0
|
print $self->diag_sv_idx($idx); |
1330
|
0
|
|
|
|
|
0
|
print "$name is already registered as $self->{svn}[$idx] ". |
1331
|
|
|
|
|
|
|
"Depth ($self->{svd}[$idx]) $depth\n"; |
1332
|
|
|
|
|
|
|
} |
1333
|
339
|
100
|
100
|
|
|
865
|
if ($self->{svn}[$idx]=~/^\$\{?\$/ and $name!~/^\$\{?\$/) { |
1334
|
12
|
|
|
|
|
23
|
$self->{svn}[$idx]=$name; |
1335
|
|
|
|
|
|
|
} |
1336
|
|
|
|
|
|
|
} |
1337
|
1548
|
|
|
|
|
1680
|
$self->{svt}[$idx]++; |
1338
|
1548
|
100
|
|
|
|
2390
|
$arg->{idx}=$idx if $arg; |
1339
|
1548
|
50
|
|
|
|
2414
|
Carp::confess "Dupe name!" if $self->{svrt}{$name}; |
1340
|
1548
|
|
|
|
|
2205
|
$self->{svrt}{$name}=$idx; |
1341
|
1548
|
|
|
|
|
2050
|
return $name; |
1342
|
|
|
|
|
|
|
} |
1343
|
|
|
|
|
|
|
|
1344
|
|
|
|
|
|
|
*Precise=\&Dump; |
1345
|
|
|
|
|
|
|
|
1346
|
|
|
|
|
|
|
# we make an array of hashes containing useful info about the arguments |
1347
|
|
|
|
|
|
|
sub _make_args { |
1348
|
351
|
|
|
351
|
|
370
|
my $self=shift; |
1349
|
|
|
|
|
|
|
$args_insideout{refaddr $self}= [ |
1350
|
|
|
|
|
|
|
map { |
1351
|
351
|
|
|
|
|
819
|
{ |
1352
|
749
|
|
|
|
|
3589
|
item => \$_[$_], |
1353
|
|
|
|
|
|
|
ro => readonly($_[$_]), |
1354
|
|
|
|
|
|
|
refcnt => sv_refcount($_[$_]), |
1355
|
|
|
|
|
|
|
} |
1356
|
|
|
|
|
|
|
} 0..$#_ |
1357
|
|
|
|
|
|
|
]; |
1358
|
351
|
|
|
|
|
1726
|
return $args_insideout{refaddr $self} |
1359
|
|
|
|
|
|
|
} |
1360
|
|
|
|
|
|
|
|
1361
|
|
|
|
|
|
|
=back |
1362
|
|
|
|
|
|
|
|
1363
|
|
|
|
|
|
|
=head2 Methods |
1364
|
|
|
|
|
|
|
|
1365
|
|
|
|
|
|
|
=over 4 |
1366
|
|
|
|
|
|
|
|
1367
|
|
|
|
|
|
|
=item Data |
1368
|
|
|
|
|
|
|
|
1369
|
|
|
|
|
|
|
=item Data LIST |
1370
|
|
|
|
|
|
|
|
1371
|
|
|
|
|
|
|
Analyzes a list of variables in breadth first order. |
1372
|
|
|
|
|
|
|
|
1373
|
|
|
|
|
|
|
If called with arguments then the internal object state is reset before |
1374
|
|
|
|
|
|
|
scanning the list of arguments provided. |
1375
|
|
|
|
|
|
|
|
1376
|
|
|
|
|
|
|
If called with no arguments then whatever arguments were provided to C |
1377
|
|
|
|
|
|
|
will be scanned. |
1378
|
|
|
|
|
|
|
|
1379
|
|
|
|
|
|
|
Returns $self. |
1380
|
|
|
|
|
|
|
|
1381
|
|
|
|
|
|
|
=cut |
1382
|
|
|
|
|
|
|
|
1383
|
|
|
|
|
|
|
|
1384
|
|
|
|
|
|
|
sub _add_queue { |
1385
|
2260
|
|
|
2260
|
|
3211
|
my ($self,$queue,$type,$item,$depth,$name,$rcount,$arg)=@_; |
1386
|
2260
|
100
|
|
|
|
3669
|
if (substr($type,0,1) ne '*') { |
|
|
50
|
|
|
|
|
|
1387
|
2232
|
|
|
|
|
4192
|
push @$queue,[\$item,$depth,$name,$rcount,$arg]; |
1388
|
|
|
|
|
|
|
} elsif($self->{style}{dumpglob}) { |
1389
|
28
|
|
|
|
|
40
|
local @_; |
1390
|
28
|
|
|
|
|
65
|
foreach my $t ($self->_glob_slots('FORMAT')) { |
1391
|
|
|
|
|
|
|
|
1392
|
|
|
|
|
|
|
#warn $type.":$t\n"; |
1393
|
|
|
|
|
|
|
#register? |
1394
|
|
|
|
|
|
|
#$self->_reg_scalar(*$item{$t},$depth+1,sv_refcount(*$item{$t}), |
1395
|
|
|
|
|
|
|
# readonly(*$item{$t}),'*'.$name."{$t}"); |
1396
|
|
|
|
|
|
|
|
1397
|
140
|
|
|
|
|
149
|
my $v=*$item{$t}; |
1398
|
140
|
100
|
|
|
|
249
|
next unless defined $v; |
1399
|
56
|
100
|
100
|
|
|
159
|
next if $t eq 'SCALAR' and !defined($$v); |
1400
|
|
|
|
|
|
|
push @$queue,[ |
1401
|
|
|
|
|
|
|
\*$item{$t}, |
1402
|
|
|
|
|
|
|
$depth+1, |
1403
|
|
|
|
|
|
|
$type."{$t}", |
1404
|
45
|
|
|
|
|
191
|
refcount(\*$item{$t}) |
1405
|
|
|
|
|
|
|
]; |
1406
|
|
|
|
|
|
|
} |
1407
|
|
|
|
|
|
|
} |
1408
|
|
|
|
|
|
|
#use Scalar::Util qw(weaken); |
1409
|
2260
|
|
|
|
|
4783
|
$self; |
1410
|
|
|
|
|
|
|
} |
1411
|
|
|
|
|
|
|
|
1412
|
|
|
|
|
|
|
sub Data { |
1413
|
347
|
|
|
347
|
1
|
149726
|
my $self=shift->_safe_self; |
1414
|
347
|
|
|
|
|
360
|
my $args; |
1415
|
347
|
50
|
|
|
|
694
|
print "Data(".scalar(@_)." vars)\n" |
1416
|
|
|
|
|
|
|
if $DEBUG; |
1417
|
347
|
100
|
|
|
|
686
|
if (@_) { |
|
|
50
|
|
|
|
|
|
1418
|
340
|
|
|
|
|
683
|
$self->_reset; |
1419
|
340
|
|
|
|
|
774
|
$self->_make_args(@_); |
1420
|
|
|
|
|
|
|
} elsif ( $self->{cataloged} ) { |
1421
|
0
|
|
|
|
|
0
|
$self->_reset; |
1422
|
|
|
|
|
|
|
} |
1423
|
347
|
|
33
|
|
|
955
|
$args= $args_insideout{refaddr $self} |
1424
|
|
|
|
|
|
|
|| Carp::carp "No arguments!"; |
1425
|
347
|
|
|
|
|
344
|
my $pass=1; |
1426
|
|
|
|
|
|
|
PASS:{ |
1427
|
347
|
|
|
|
|
340
|
my @queue; |
|
359
|
|
|
|
|
293
|
|
1428
|
359
|
|
|
|
|
320
|
my $idx=0; |
1429
|
359
|
|
|
|
|
569
|
foreach my $arg (@$args) { |
1430
|
|
|
|
|
|
|
#($self,$item,$depth,$cnt,$ro,$name) |
1431
|
790
|
|
|
|
|
642
|
my $make_name=$self->_make_name(${ $arg->{item} },$idx++); |
|
790
|
|
|
|
|
1801
|
|
1432
|
|
|
|
|
|
|
my $name=$self->_reg_scalar( |
1433
|
790
|
|
|
|
|
1880
|
${ $arg->{item} }, |
1434
|
|
|
|
|
|
|
1, |
1435
|
|
|
|
|
|
|
$arg->{refcnt}, |
1436
|
|
|
|
|
|
|
$arg->{ro}, |
1437
|
790
|
|
|
|
|
1121
|
$make_name, |
1438
|
|
|
|
|
|
|
$arg |
1439
|
|
|
|
|
|
|
); |
1440
|
790
|
|
|
|
|
970
|
$arg->{name}=$name; |
1441
|
790
|
100
|
|
|
|
594
|
if (my $type=reftype_or_glob ${ $arg->{item} }) { |
|
790
|
|
|
|
|
2479
|
|
1442
|
682
|
|
|
|
|
751
|
$self->_add_queue(\@queue, $type, ${ $arg->{item} }, 2, |
1443
|
682
|
|
|
|
|
637
|
$name, refcount ${ $arg->{item} },$arg) |
|
682
|
|
|
|
|
1574
|
|
1444
|
|
|
|
|
|
|
} |
1445
|
|
|
|
|
|
|
} |
1446
|
|
|
|
|
|
|
|
1447
|
359
|
|
|
|
|
377
|
my %lex_addr; |
1448
|
|
|
|
|
|
|
my %lex_addr2name; |
1449
|
0
|
|
|
|
|
0
|
my %lex_name; |
1450
|
0
|
|
|
|
|
0
|
my %lex_special; |
1451
|
|
|
|
|
|
|
|
1452
|
359
|
|
|
|
|
710
|
while (@queue) { |
1453
|
|
|
|
|
|
|
# If the scalar (container) is of any interest it is |
1454
|
|
|
|
|
|
|
# already registered by the time we see it here. |
1455
|
|
|
|
|
|
|
# at this point we only care about the contents, not the |
1456
|
|
|
|
|
|
|
# container. |
1457
|
2277
|
50
|
|
|
|
3305
|
print Data::Dumper->new([\@queue],['*queue'])->Maxdepth(3)->Dump |
1458
|
|
|
|
|
|
|
if $DEBUG>=10; |
1459
|
|
|
|
|
|
|
|
1460
|
|
|
|
|
|
|
my ($ritem, |
1461
|
|
|
|
|
|
|
$cdepth, |
1462
|
|
|
|
|
|
|
$cname, |
1463
|
|
|
|
|
|
|
$rcnt, |
1464
|
2277
|
|
|
|
|
1921
|
$arg)=@{shift @queue}; |
|
2277
|
|
|
|
|
3153
|
|
1465
|
|
|
|
|
|
|
|
1466
|
|
|
|
|
|
|
|
1467
|
|
|
|
|
|
|
|
1468
|
2277
|
|
|
|
|
2593
|
my ($frozen,$item,$raddr,$class); |
1469
|
|
|
|
|
|
|
DEQUEUE:{ |
1470
|
2277
|
|
|
|
|
1585
|
$item=$$ritem; |
|
2281
|
|
|
|
|
1833
|
|
1471
|
2281
|
|
|
|
|
2813
|
$raddr=refaddr($item); |
1472
|
2281
|
|
|
|
|
2693
|
$class=blessed($item); |
1473
|
|
|
|
|
|
|
|
1474
|
2281
|
100
|
|
|
|
4020
|
if ($self->{ref_fz}{$raddr}) { |
1475
|
1
|
50
|
|
|
|
3
|
print "Skipping frozen element $raddr\n" if $DEBUG; |
1476
|
1
|
|
|
|
|
1
|
next; |
1477
|
|
|
|
|
|
|
} |
1478
|
|
|
|
|
|
|
|
1479
|
|
|
|
|
|
|
$DEBUG and |
1480
|
2280
|
50
|
|
|
|
3062
|
print "Q-> $item $cdepth $cname $rcnt ($raddr)\n"; |
1481
|
|
|
|
|
|
|
|
1482
|
2280
|
50
|
|
|
|
2965
|
unless ($raddr) { |
1483
|
0
|
0
|
|
|
|
0
|
$DEBUG and |
1484
|
|
|
|
|
|
|
print " Skipping '$cname' as it isn't a reference.\n"; |
1485
|
0
|
|
|
|
|
0
|
next; |
1486
|
|
|
|
|
|
|
} |
1487
|
|
|
|
|
|
|
|
1488
|
2280
|
100
|
|
|
|
2835
|
last DEQUEUE if $frozen; |
1489
|
2276
|
|
|
|
|
1642
|
$frozen=1; |
1490
|
2276
|
100
|
100
|
|
|
11505
|
if ($self->{style}{ignore}{"#$raddr"} || ($class&& $self->{style}{ignore}{".$class"})) { |
|
|
100
|
33
|
|
|
|
|
|
|
|
100
|
|
|
|
|
1491
|
1
|
50
|
|
|
|
4
|
$DEBUG and |
1492
|
|
|
|
|
|
|
print "Ignoring '$cname' as its class ($class) in ". |
1493
|
|
|
|
|
|
|
"our ignore list.\n"; |
1494
|
1
|
|
|
|
|
2
|
next; |
1495
|
|
|
|
|
|
|
} elsif ($class && !$self->{"cache_skip_freeze"}{$class}) { |
1496
|
149
|
|
|
|
|
183
|
my $freezer= $self->{cache_freeze_class}{$class}; |
1497
|
149
|
|
|
|
|
142
|
my ( $proxy, $thaw, $postop ); |
1498
|
149
|
50
|
|
|
|
231
|
if (! defined $freezer ) { |
|
|
0
|
|
|
|
|
|
1499
|
149
|
|
|
|
|
355
|
for ( $self->{style}{freeze_class}{$class}, |
1500
|
|
|
|
|
|
|
$self->{style}{freezer}, |
1501
|
|
|
|
|
|
|
'DDS_freeze' ) |
1502
|
|
|
|
|
|
|
{ |
1503
|
440
|
|
|
|
|
380
|
$freezer= $_; |
1504
|
440
|
100
|
|
|
|
607
|
if ( $freezer ) { |
|
|
100
|
|
|
|
|
|
1505
|
290
|
50
|
|
|
|
1391
|
if (ref $freezer) { |
|
|
100
|
|
|
|
|
|
1506
|
0
|
|
|
|
|
0
|
eval { |
1507
|
0
|
|
|
|
|
0
|
($proxy,$thaw,$postop)= $freezer->($$ritem); |
1508
|
|
|
|
|
|
|
}; |
1509
|
0
|
0
|
|
|
|
0
|
last if !$@; |
1510
|
|
|
|
|
|
|
} elsif ( $class->can($freezer) ) { |
1511
|
6
|
|
|
|
|
8
|
eval { |
1512
|
6
|
|
|
|
|
4
|
($proxy,$thaw,$postop)= ${$ritem}->$freezer(); |
|
6
|
|
|
|
|
22
|
|
1513
|
|
|
|
|
|
|
}; |
1514
|
6
|
50
|
|
|
|
49
|
last if !$@; |
1515
|
|
|
|
|
|
|
} |
1516
|
|
|
|
|
|
|
} elsif ( defined $freezer ) { |
1517
|
1
|
|
|
|
|
3
|
last; |
1518
|
|
|
|
|
|
|
} |
1519
|
|
|
|
|
|
|
} |
1520
|
149
|
100
|
|
|
|
210
|
if (! defined $proxy) { |
1521
|
145
|
|
|
|
|
243
|
$self->{"cache_skip_freeze"}{$class}=1; |
1522
|
|
|
|
|
|
|
} else { |
1523
|
4
|
|
|
|
|
7
|
$self->{cache_freeze_class}{$class}= $freezer; |
1524
|
|
|
|
|
|
|
} |
1525
|
|
|
|
|
|
|
|
1526
|
|
|
|
|
|
|
} elsif (ref $freezer) { |
1527
|
0
|
|
|
|
|
0
|
($proxy,$thaw)= $freezer->($$ritem); |
1528
|
|
|
|
|
|
|
} else { |
1529
|
0
|
|
|
|
|
0
|
($proxy,$thaw)= ${$ritem}->$freezer(); |
|
0
|
|
|
|
|
0
|
|
1530
|
|
|
|
|
|
|
} |
1531
|
149
|
100
|
|
|
|
228
|
if ( $thaw ) { |
1532
|
4
|
|
|
|
|
8
|
$self->{ref_thaw}{$raddr}= $thaw; |
1533
|
|
|
|
|
|
|
} |
1534
|
149
|
50
|
|
|
|
241
|
if ( $postop ) { |
1535
|
0
|
|
|
|
|
0
|
$self->{ref_postop}{$raddr}= $postop; |
1536
|
|
|
|
|
|
|
} |
1537
|
149
|
50
|
|
|
|
325
|
if ( refaddr($proxy) != $raddr ) { |
1538
|
149
|
|
|
|
|
243
|
$self->{ref_fz}{$raddr}= $proxy; |
1539
|
149
|
|
|
|
|
167
|
$ritem= \$proxy; |
1540
|
149
|
100
|
|
|
|
215
|
if (ref $proxy) { |
1541
|
4
|
|
|
|
|
6
|
redo DEQUEUE; |
1542
|
|
|
|
|
|
|
} else { |
1543
|
145
|
|
|
|
|
199
|
next; |
1544
|
|
|
|
|
|
|
} |
1545
|
|
|
|
|
|
|
} |
1546
|
|
|
|
|
|
|
} |
1547
|
|
|
|
|
|
|
|
1548
|
|
|
|
|
|
|
} |
1549
|
|
|
|
|
|
|
|
1550
|
2277
|
|
|
|
|
3502
|
my ($idx,$dupe)=$self->_reg_ref($item,$cdepth,$cname,$rcnt,$arg); |
1551
|
2277
|
100
|
33
|
|
|
3773
|
$DEBUG and print " Skipping '$cname' as it is a dupe of ". |
1552
|
|
|
|
|
|
|
"$self->{refn}[$idx]\n" |
1553
|
|
|
|
|
|
|
if $dupe; |
1554
|
|
|
|
|
|
|
|
1555
|
2277
|
50
|
|
|
|
3079
|
$DEBUG>9 and $self->diag; |
1556
|
2277
|
100
|
|
|
|
3451
|
next if $dupe; |
1557
|
|
|
|
|
|
|
|
1558
|
|
|
|
|
|
|
|
1559
|
1577
|
|
|
|
|
2457
|
my $reftype=reftype $item; |
1560
|
1577
|
|
|
|
|
1826
|
my $cnt=refcount($item); |
1561
|
1577
|
|
|
|
|
1220
|
my $overloaded=undef; |
1562
|
1577
|
|
|
|
|
1148
|
my $isoverloaded=0; |
1563
|
1577
|
100
|
100
|
|
|
3075
|
if (defined $class and overload::Overloaded($item)) { |
1564
|
26
|
|
|
|
|
1609
|
disable_overloading( $item ); |
1565
|
26
|
|
|
|
|
26
|
$overloaded= $class; |
1566
|
26
|
|
|
|
|
17
|
$isoverloaded= 1; |
1567
|
|
|
|
|
|
|
} |
1568
|
|
|
|
|
|
|
|
1569
|
|
|
|
|
|
|
|
1570
|
1577
|
100
|
100
|
|
|
23716
|
if ( $reftype eq 'SCALAR' or |
|
|
100
|
100
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
1571
|
|
|
|
|
|
|
$reftype eq 'REF' or |
1572
|
|
|
|
|
|
|
$reftype eq 'GLOB' ) |
1573
|
|
|
|
|
|
|
{ |
1574
|
548
|
|
|
|
|
882
|
my $name=$self->_build_name($cname,'$'); |
1575
|
548
|
|
|
|
|
843
|
my $cnt=sv_refcount($$item); |
1576
|
548
|
50
|
|
|
|
830
|
if ($cnt>1) { |
1577
|
548
|
|
|
|
|
1197
|
$self->_reg_scalar($$item,$cdepth+1,$cnt, |
1578
|
|
|
|
|
|
|
readonly($$item),$name); |
1579
|
|
|
|
|
|
|
} |
1580
|
548
|
100
|
|
|
|
1518
|
if (my $type=reftype_or_glob $$item) { |
1581
|
368
|
|
|
|
|
710
|
$self->_add_queue(\@queue,$type,$$item, |
1582
|
|
|
|
|
|
|
$cdepth+2,$name,$cnt) |
1583
|
|
|
|
|
|
|
} |
1584
|
|
|
|
|
|
|
|
1585
|
|
|
|
|
|
|
} elsif ($reftype eq 'ARRAY') { |
1586
|
396
|
|
|
|
|
945
|
foreach my $idx (0..$#$item) { |
1587
|
1136
|
|
|
|
|
1692
|
my $name=$self->_build_name($cname,'[',$idx); |
1588
|
1136
|
|
|
|
|
2062
|
my $cnt=sv_refcount($item->[$idx]); |
1589
|
1136
|
100
|
|
|
|
1567
|
if ($cnt>1) { |
1590
|
184
|
50
|
|
|
|
257
|
print "refcount($name)==$cnt\n" |
1591
|
|
|
|
|
|
|
if $DEBUG>9; |
1592
|
184
|
|
|
|
|
484
|
$self->_reg_scalar($item->[$idx],$cdepth+1,$cnt, |
1593
|
|
|
|
|
|
|
readonly($item->[$idx]),$name); |
1594
|
|
|
|
|
|
|
} |
1595
|
1136
|
100
|
|
|
|
2908
|
if (my $type=reftype_or_glob $item->[$idx]) { |
1596
|
680
|
|
|
|
|
1565
|
$self->_add_queue(\@queue,$type,$item->[$idx], |
1597
|
|
|
|
|
|
|
$cdepth+2,$name,$cnt) |
1598
|
|
|
|
|
|
|
} |
1599
|
|
|
|
|
|
|
} |
1600
|
|
|
|
|
|
|
} elsif ($reftype eq 'HASH') { |
1601
|
509
|
|
|
|
|
610
|
my $ik=$self->{style}{indentkeys}; |
1602
|
509
|
|
|
|
|
936
|
my ($keyary, $thaw)= $self->_get_keys($item,0,$raddr,$class); |
1603
|
509
|
50
|
|
|
|
765
|
if ($thaw) { |
1604
|
0
|
|
|
|
|
0
|
$self->{ref_thaw}{$raddr}= $thaw; |
1605
|
|
|
|
|
|
|
} |
1606
|
509
|
|
|
|
|
421
|
my $key_len=0; |
1607
|
509
|
|
|
|
|
409
|
my $key_sum=0; |
1608
|
509
|
|
|
|
|
370
|
my $key_count=0; |
1609
|
509
|
50
|
33
|
|
|
1804
|
die reftype $keyary if $keyary && reftype($keyary) ne 'ARRAY'; |
1610
|
|
|
|
|
|
|
|
1611
|
509
|
50
|
|
|
|
1317
|
while ( defined( my $key = |
1612
|
|
|
|
|
|
|
defined $keyary ? $keyary->[$key_count] : each %$item |
1613
|
|
|
|
|
|
|
)) |
1614
|
|
|
|
|
|
|
{ |
1615
|
1191
|
50
|
|
|
|
1573
|
if ($ik) { |
1616
|
1191
|
|
|
|
|
1491
|
my $qk=_quotekey($key); |
1617
|
1191
|
|
|
|
|
1198
|
$key_sum+=length($qk); |
1618
|
1191
|
100
|
|
|
|
1910
|
$key_len=length($qk) if $key_len
|
1619
|
|
|
|
|
|
|
} |
1620
|
1191
|
|
|
|
|
825
|
$key_count++; |
1621
|
1191
|
|
|
|
|
1806
|
my $name=$self->_build_name($cname,'{',$key); |
1622
|
1191
|
|
|
|
|
2218
|
my $cnt=sv_refcount($item->{$key}); |
1623
|
1191
|
100
|
|
|
|
1615
|
if ($cnt>1) { |
1624
|
|
|
|
|
|
|
$self->_reg_scalar($item->{$key},$cdepth+1,$cnt, |
1625
|
26
|
|
|
|
|
67
|
readonly($item->{$key}),$name); |
1626
|
|
|
|
|
|
|
} |
1627
|
1191
|
100
|
|
|
|
3717
|
if (my $type=reftype_or_glob $item->{$key}) { |
1628
|
500
|
|
|
|
|
1175
|
$self->_add_queue(\@queue,$type,$item->{$key}, |
1629
|
|
|
|
|
|
|
$cdepth+2,$name,$cnt); |
1630
|
|
|
|
|
|
|
} |
1631
|
|
|
|
|
|
|
} |
1632
|
509
|
100
|
|
|
|
1033
|
my $avg=$key_count>0 ? $key_sum/$key_count : 0; |
1633
|
509
|
50
|
66
|
|
|
1419
|
$self->{ref_hklen}{$raddr}=($key_len>8 && (2/3*$key_len)>$avg) |
1634
|
|
|
|
|
|
|
? int(0.5+$avg) : $key_len; |
1635
|
509
|
|
|
|
|
1050
|
$self->{ref_hkcnt}{$raddr}=$key_count; |
1636
|
|
|
|
|
|
|
#warn "$raddr => $key_count"; |
1637
|
|
|
|
|
|
|
|
1638
|
|
|
|
|
|
|
} elsif ($reftype eq 'CODE') { |
1639
|
68
|
100
|
|
|
|
141
|
if ($pass == 1) { |
1640
|
|
|
|
|
|
|
|
1641
|
40
|
|
|
|
|
73
|
my $used=_get_lexicals($item); |
1642
|
|
|
|
|
|
|
|
1643
|
40
|
|
|
|
|
98
|
foreach my $name (keys %$used) { |
1644
|
78
|
100
|
|
|
|
244
|
next unless $name=~/\D/; |
1645
|
39
|
|
|
|
|
73
|
my $addr=refaddr($used->{$name}); |
1646
|
39
|
100
|
|
|
|
84
|
if ( !$lex_addr{$addr} ) { |
1647
|
30
|
|
|
|
|
48
|
$lex_addr{$addr}=$used->{$name}; |
1648
|
30
|
100
|
|
|
|
48
|
if ( $lex_name{$name} ) { |
1649
|
|
|
|
|
|
|
my $tmpname=sprintf "%s".$self->{style}{eclipsename}, |
1650
|
|
|
|
|
|
|
substr($name,0,1), |
1651
|
|
|
|
|
|
|
$self->{style}{eclipsename}=~/^[^%]*%s/ |
1652
|
|
|
|
|
|
|
? ( substr($name,1), |
1653
|
|
|
|
|
|
|
++$lex_special{$name}, ) |
1654
|
7
|
100
|
|
|
|
82
|
: ( ++$lex_special{$name}, |
1655
|
|
|
|
|
|
|
substr($name,1), ); |
1656
|
7
|
|
|
|
|
16
|
$lex_name{$tmpname}=$addr; |
1657
|
7
|
|
|
|
|
9
|
$lex_addr2name{$addr}=$tmpname; |
1658
|
|
|
|
|
|
|
$self->_add_queue(\@queue,reftype_or_glob $used->{$name}, |
1659
|
7
|
|
|
|
|
31
|
$used->{$name},$cdepth+1,$tmpname,2); |
1660
|
|
|
|
|
|
|
} else { |
1661
|
23
|
|
|
|
|
33
|
$lex_name{$name}=$addr; |
1662
|
23
|
|
|
|
|
29
|
$lex_addr2name{$addr}=$name; |
1663
|
|
|
|
|
|
|
$self->_add_queue(\@queue,reftype_or_glob $used->{$name}, |
1664
|
23
|
|
|
|
|
86
|
$used->{$name},$cdepth+1,$name,2); |
1665
|
|
|
|
|
|
|
} |
1666
|
|
|
|
|
|
|
} |
1667
|
|
|
|
|
|
|
} |
1668
|
|
|
|
|
|
|
} |
1669
|
|
|
|
|
|
|
} elsif ($reftype eq 'FORMAT') { |
1670
|
|
|
|
|
|
|
# Code similar to that of CODE should go here I think. |
1671
|
|
|
|
|
|
|
} else { |
1672
|
|
|
|
|
|
|
# IO? |
1673
|
|
|
|
|
|
|
Carp::confess "Data() can't handle '$reftype' objects yet ($item)\n :-(\n" |
1674
|
51
|
50
|
|
|
|
119
|
if $ENV{DDS_STRICT}; |
1675
|
|
|
|
|
|
|
} |
1676
|
1577
|
100
|
|
|
|
4198
|
if ($isoverloaded) { |
1677
|
26
|
|
|
|
|
29
|
restore_overloading( $item, $overloaded ); |
1678
|
|
|
|
|
|
|
} |
1679
|
|
|
|
|
|
|
} |
1680
|
359
|
100
|
|
|
|
719
|
if ( $pass++ == 1 ) { |
1681
|
|
|
|
|
|
|
|
1682
|
347
|
|
|
|
|
347
|
my %items; |
1683
|
347
|
|
|
|
|
322
|
for my $idx ( 0..$#{$args_insideout{refaddr $self}} ) { |
|
347
|
|
|
|
|
1233
|
|
1684
|
744
|
|
|
|
|
1139
|
my $item=$args_insideout{refaddr $self}[$idx]; |
1685
|
744
|
|
|
|
|
1431
|
$items{ refaddr $item->{item} } = $idx; |
1686
|
|
|
|
|
|
|
} |
1687
|
|
|
|
|
|
|
|
1688
|
347
|
|
|
|
|
359
|
my @add; |
1689
|
347
|
|
|
|
|
322
|
my $added=0; |
1690
|
347
|
|
|
|
|
310
|
if (0) { |
1691
|
|
|
|
|
|
|
@add=keys %lex_addr; |
1692
|
|
|
|
|
|
|
} else { |
1693
|
347
|
|
|
|
|
634
|
for my $addr (keys %lex_addr) { |
1694
|
30
|
100
|
|
|
|
40
|
if ( exists $items{$addr} ) { |
1695
|
3
|
|
|
|
|
4
|
my $idx = $items{$addr}; |
1696
|
3
|
100
|
|
|
|
8
|
if ( !$self->{unames}[$idx] ){ |
1697
|
2
|
|
|
|
|
6
|
for ($self->{unames}[$idx] = $lex_addr2name{$addr}) { |
1698
|
2
|
|
|
|
|
6
|
s/^[^\$]/*/; s/^\$//; |
|
2
|
|
|
|
|
8
|
|
1699
|
|
|
|
|
|
|
} |
1700
|
2
|
|
|
|
|
4
|
$added++; |
1701
|
|
|
|
|
|
|
} else { |
1702
|
1
|
|
|
|
|
2
|
my $new=$self->{unames}[$idx]; |
1703
|
1
|
|
|
|
|
2
|
my $old=$lex_addr2name{$addr}; |
1704
|
1
|
|
|
|
|
5
|
$new=~s/^(\*)?/substr($old,0,1)/e; |
|
1
|
|
|
|
|
3
|
|
1705
|
1
|
|
|
|
|
2
|
delete $lex_name{$lex_addr2name{$addr}}; |
1706
|
1
|
|
|
|
|
2
|
$lex_addr2name{$addr}=$new; |
1707
|
1
|
|
|
|
|
3
|
$lex_name{$self->{unames}[$idx]} = $addr; # xxx |
1708
|
|
|
|
|
|
|
} |
1709
|
|
|
|
|
|
|
} else { |
1710
|
27
|
|
|
|
|
37
|
push @add,$addr; |
1711
|
|
|
|
|
|
|
} |
1712
|
|
|
|
|
|
|
} |
1713
|
|
|
|
|
|
|
} |
1714
|
347
|
|
|
|
|
542
|
@add=sort {$lex_addr2name{$a} cmp $lex_addr2name{$b}} @add; |
|
24
|
|
|
|
|
36
|
|
1715
|
|
|
|
|
|
|
|
1716
|
|
|
|
|
|
|
$self->{lexicals}={ |
1717
|
347
|
|
|
|
|
951
|
a2n => \%lex_addr2name, |
1718
|
|
|
|
|
|
|
name => \%lex_name |
1719
|
|
|
|
|
|
|
}; |
1720
|
|
|
|
|
|
|
|
1721
|
347
|
100
|
|
|
|
1704
|
if (@add) { |
|
|
100
|
|
|
|
|
|
1722
|
11
|
|
|
|
|
30
|
unshift @{$args_insideout{refaddr $self}}, |
1723
|
|
|
|
|
|
|
map { |
1724
|
11
|
|
|
|
|
10
|
my $rt=reftype($lex_addr{$_}); |
|
27
|
|
|
|
|
52
|
|
1725
|
27
|
|
|
|
|
14
|
my $item; |
1726
|
27
|
100
|
66
|
|
|
95
|
if ($rt ne 'SCALAR' and $rt ne 'GLOB' and $rt ne 'REF') { |
|
|
|
100
|
|
|
|
|
1727
|
3
|
|
|
|
|
5
|
$item=\$lex_addr{$_}; |
1728
|
|
|
|
|
|
|
} else { |
1729
|
24
|
|
|
|
|
26
|
$item=$lex_addr{$_}; |
1730
|
|
|
|
|
|
|
} |
1731
|
|
|
|
|
|
|
{ |
1732
|
|
|
|
|
|
|
item => $item, |
1733
|
|
|
|
|
|
|
usemy => 1, |
1734
|
|
|
|
|
|
|
ro => 0, |
1735
|
27
|
|
|
|
|
92
|
refcnt => refcount($lex_addr{$_}), |
1736
|
|
|
|
|
|
|
} |
1737
|
|
|
|
|
|
|
} @add; |
1738
|
11
|
|
|
|
|
18
|
$self->{lexicals}{added}={ map { $lex_addr2name{$_} => 1 } @add }; |
|
27
|
|
|
|
|
53
|
|
1739
|
11
|
|
|
|
|
23
|
unshift @{$self->{unames}}, |
1740
|
|
|
|
|
|
|
map { |
1741
|
11
|
|
|
|
|
14
|
(my $n=$lex_addr2name{$_})=~s/^[^\$]/*/; |
|
27
|
|
|
|
|
52
|
|
1742
|
27
|
|
|
|
|
69
|
$n=~s/^\$//; |
1743
|
27
|
|
|
|
|
56
|
$n |
1744
|
|
|
|
|
|
|
} @add; |
1745
|
11
|
|
|
|
|
28
|
$self->_reset; |
1746
|
11
|
|
|
|
|
41
|
redo PASS; |
1747
|
|
|
|
|
|
|
} elsif ($added) { |
1748
|
1
|
|
|
|
|
3
|
$self->_reset; |
1749
|
1
|
|
|
|
|
5
|
redo PASS; |
1750
|
|
|
|
|
|
|
} |
1751
|
|
|
|
|
|
|
} |
1752
|
|
|
|
|
|
|
} |
1753
|
347
|
|
|
|
|
473
|
$self->{cataloged}=1; |
1754
|
347
|
|
|
|
|
981
|
return $self; |
1755
|
|
|
|
|
|
|
} |
1756
|
|
|
|
|
|
|
|
1757
|
|
|
|
|
|
|
sub _add_fix { |
1758
|
519
|
|
|
519
|
|
932
|
my ($self,@args)=@_; |
1759
|
|
|
|
|
|
|
# 'var','glob','method call','lock','ref','sv','#' |
1760
|
|
|
|
|
|
|
# TODO |
1761
|
|
|
|
|
|
|
# add a fix statement to the list of fixes. |
1762
|
519
|
50
|
|
|
|
1165
|
my $fix=@args==1 ? shift @args : [@args]; |
1763
|
519
|
50
|
|
|
|
2031
|
unless ($fix->[0]=~/^(var|glob|thaw|ref|sv|#|sub call|lock|bless)$/) { |
1764
|
0
|
|
|
|
|
0
|
Carp::confess "Unknown variant:".Dumper($fix); |
1765
|
|
|
|
|
|
|
} |
1766
|
519
|
50
|
|
|
|
770
|
if ($args[0] eq 'var') { |
1767
|
0
|
|
|
|
|
0
|
unshift @{$self->{fix}},$fix; |
|
0
|
|
|
|
|
0
|
|
1768
|
|
|
|
|
|
|
} else { |
1769
|
519
|
|
|
|
|
348
|
push @{$self->{fix}},$fix; |
|
519
|
|
|
|
|
1286
|
|
1770
|
|
|
|
|
|
|
} |
1771
|
|
|
|
|
|
|
} |
1772
|
|
|
|
|
|
|
|
1773
|
|
|
|
|
|
|
sub _glob_slots { |
1774
|
56
|
|
|
56
|
|
57
|
my ($self,$inc_format)=@_; |
1775
|
|
|
|
|
|
|
# $inc_format is for a special case. |
1776
|
|
|
|
|
|
|
return ( |
1777
|
|
|
|
|
|
|
qw(SCALAR HASH ARRAY), |
1778
|
|
|
|
|
|
|
(($self->{style}{deparse} && $self->{style}{deparseglob}) |
1779
|
|
|
|
|
|
|
? 'CODE' : ()), |
1780
|
|
|
|
|
|
|
(($inc_format && $self->{style}{deparse} && $self->{style}{deparseglob}) |
1781
|
56
|
50
|
33
|
|
|
392
|
? 'FORMAT' : () ) |
|
|
100
|
33
|
|
|
|
|
1782
|
|
|
|
|
|
|
); |
1783
|
|
|
|
|
|
|
} |
1784
|
|
|
|
|
|
|
|
1785
|
|
|
|
|
|
|
sub _dump_apply_fix { #handle fix statements and GLOB's here. |
1786
|
1120
|
|
|
1120
|
|
1065
|
my ($self,$isfinal)=@_; |
1787
|
|
|
|
|
|
|
# go through the fix statements and out any that are |
1788
|
|
|
|
|
|
|
# now fully dumped. |
1789
|
|
|
|
|
|
|
# currently the following types are grokked: |
1790
|
|
|
|
|
|
|
# 'var','glob','method call','tlock','ref','sv','#' |
1791
|
|
|
|
|
|
|
|
1792
|
1120
|
|
|
|
|
838
|
my @globs; |
1793
|
|
|
|
|
|
|
GLOB:{ |
1794
|
1120
|
|
|
|
|
990
|
@globs=(); |
|
1146
|
|
|
|
|
1092
|
|
1795
|
1146
|
|
|
|
|
1578
|
@{$self->{fix}}=grep { |
1796
|
957
|
|
|
|
|
681
|
my $keep=1; |
1797
|
957
|
|
|
|
|
641
|
my $fix=$_; |
1798
|
957
|
50
|
|
|
|
1340
|
if (ref $fix) { |
1799
|
957
|
|
|
|
|
1064
|
my ($type,$lhs,$rhs,$class)=@$fix; |
1800
|
|
|
|
|
|
|
|
1801
|
957
|
50
|
|
|
|
2513
|
if ($type eq '#') { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
1802
|
0
|
|
|
|
|
0
|
$self->{fh}->print(map "# $_\n",@$fix[0..$#$fix]); |
1803
|
0
|
|
|
|
|
0
|
$keep=0; |
1804
|
|
|
|
|
|
|
} elsif ($type eq 'bless') { |
1805
|
71
|
100
|
|
|
|
95
|
if ($isfinal) { # $self->{"refdu"}[$lhs] |
1806
|
26
|
|
|
|
|
30
|
$lhs=$self->{"refn"}[$lhs]; |
1807
|
|
|
|
|
|
|
$self->{fh}->print( |
1808
|
|
|
|
|
|
|
substr($self->{style}{bless},0,-1)," ",$lhs,", ", |
1809
|
26
|
|
|
|
|
53
|
_quote($rhs)," ",substr($self->{style}{bless},-1), |
1810
|
|
|
|
|
|
|
";\n"); |
1811
|
26
|
|
|
|
|
37
|
$keep=0; |
1812
|
|
|
|
|
|
|
} |
1813
|
|
|
|
|
|
|
} elsif ($type eq 'sv') { |
1814
|
|
|
|
|
|
|
|
1815
|
290
|
|
|
|
|
250
|
my $dref=$_->[-1]; |
1816
|
290
|
100
|
66
|
|
|
666
|
if ($self->{$type."du"}[$rhs] and ${$self->{$type."du"}[$rhs]}) { |
|
110
|
|
|
|
|
322
|
|
1817
|
110
|
|
|
|
|
175
|
$rhs=$self->{$type."n"}[$rhs]; |
1818
|
110
|
|
|
|
|
159
|
my ($sigil,$var)=remove_deref($lhs); |
1819
|
110
|
50
|
|
|
|
196
|
if ($sigil) { |
1820
|
110
|
|
|
|
|
142
|
$rhs="\\".$rhs; |
1821
|
110
|
|
|
|
|
118
|
$lhs=$var; |
1822
|
|
|
|
|
|
|
} |
1823
|
110
|
|
|
|
|
410
|
$self->{fh}->print("$lhs = $rhs;\n"); |
1824
|
110
|
50
|
|
|
|
234
|
$$dref=1 if ref $dref; |
1825
|
110
|
|
|
|
|
180
|
$keep=0 |
1826
|
|
|
|
|
|
|
} |
1827
|
|
|
|
|
|
|
} elsif ($type eq 'ref') { |
1828
|
|
|
|
|
|
|
|
1829
|
436
|
100
|
100
|
|
|
952
|
if ($self->{$type."du"}[$rhs] and ${$self->{$type."du"}[$rhs]}) { |
|
360
|
|
|
|
|
979
|
|
1830
|
|
|
|
|
|
|
|
1831
|
275
|
|
|
|
|
336
|
$rhs=$self->{$type."n"}[$rhs]; |
1832
|
|
|
|
|
|
|
|
1833
|
275
|
100
|
|
|
|
606
|
if ($rhs=~/^[\@\%\&]/) { |
1834
|
36
|
|
|
|
|
49
|
$rhs="\\".$rhs; |
1835
|
36
|
100
|
|
|
|
81
|
$rhs="bless( $rhs, "._quote($class).' )' |
1836
|
|
|
|
|
|
|
if $class; |
1837
|
|
|
|
|
|
|
} # Warn if |
1838
|
275
|
|
|
|
|
738
|
$self->{fh}->print("$lhs = $rhs;\n"); |
1839
|
275
|
|
|
|
|
302
|
$keep=0 |
1840
|
|
|
|
|
|
|
} |
1841
|
|
|
|
|
|
|
} elsif ($type eq 'lock') { |
1842
|
8
|
50
|
33
|
|
|
16
|
if ($self->{refdu}[$lhs] and ${$self->{"refdu"}[$lhs]}) { |
|
8
|
|
|
|
|
24
|
|
1843
|
8
|
|
|
|
|
11
|
$lhs=$self->{"refn"}[$lhs]; |
1844
|
|
|
|
|
|
|
$self->{fh}->print(@$rhs ? "lock_keys_plus( $lhs, " |
1845
|
|
|
|
|
|
|
: "lock_keys( $lhs ", |
1846
|
8
|
100
|
|
|
|
34
|
join(", ",map{ _quote($_) } @$rhs), |
|
8
|
|
|
|
|
9
|
|
1847
|
|
|
|
|
|
|
");\n"); |
1848
|
8
|
|
|
|
|
11
|
$keep=0; |
1849
|
|
|
|
|
|
|
} |
1850
|
|
|
|
|
|
|
} elsif ($type eq 'thaw') { |
1851
|
|
|
|
|
|
|
# these have to happen at the end. |
1852
|
7
|
100
|
|
|
|
12
|
if ($isfinal) { |
1853
|
|
|
|
|
|
|
#if ($self->{refdu}[$lhs] and ${$self->{"refdu"}[$lhs]}) { |
1854
|
3
|
|
|
|
|
3
|
${$self->{refdu}[$lhs]}=1; |
|
3
|
|
|
|
|
6
|
|
1855
|
3
|
|
|
|
|
6
|
$lhs=$self->{"refn"}[$lhs]; |
1856
|
3
|
|
|
|
|
9
|
my @args=@$_[3..$#$_]; |
1857
|
3
|
50
|
|
|
|
21
|
if ($rhs=~/^(->)?((?:\w*::)*\w+)(\(\))?$/) { |
1858
|
3
|
100
|
|
|
|
9
|
if ($3) { |
1859
|
1
|
|
|
|
|
6
|
$self->{fh}->print("$2( ".join(", ",$lhs,@args)." );\n"); |
1860
|
|
|
|
|
|
|
} else { |
1861
|
2
|
|
|
|
|
22
|
$self->{fh}->print("$lhs->$2(".join(", ",@args).");\n"); |
1862
|
|
|
|
|
|
|
} |
1863
|
|
|
|
|
|
|
} else { |
1864
|
0
|
|
|
|
|
0
|
$rhs=~s/^\t//mg; |
1865
|
0
|
|
|
|
|
0
|
$self->{fh}->print("for ($lhs) {\n$rhs\n}\n"); |
1866
|
|
|
|
|
|
|
} |
1867
|
3
|
|
|
|
|
6
|
$keep=0; |
1868
|
|
|
|
|
|
|
} |
1869
|
|
|
|
|
|
|
} elsif ($type eq 'glob') { |
1870
|
28
|
|
|
|
|
32
|
push @globs,$_; |
1871
|
28
|
|
|
|
|
44
|
$keep=0; |
1872
|
|
|
|
|
|
|
} elsif ($type eq 'var') { |
1873
|
0
|
|
|
|
|
0
|
$rhs="\\".$rhs; |
1874
|
0
|
0
|
|
|
|
0
|
$rhs="bless( $rhs, "._quote($class).' )' |
1875
|
|
|
|
|
|
|
if $class; |
1876
|
0
|
0
|
|
|
|
0
|
$self->{fh}->print(($self->{style}{declare} ? 'my ' : ""),"$lhs = $rhs;\n"); |
1877
|
0
|
|
|
|
|
0
|
$keep=0; |
1878
|
|
|
|
|
|
|
} elsif ($type eq 'sub call') { |
1879
|
117
|
100
|
66
|
|
|
115
|
my @r=grep { ref $_ and (!$self->{svdu}[$$_] or !${$self->{svdu}[$$_]}) } @$fix; |
|
551
|
|
|
|
|
844
|
|
1880
|
117
|
100
|
|
|
|
196
|
unless (@r) { |
1881
|
69
|
100
|
|
|
|
72
|
my ($type,$sub,@args)=map { ref $_ ? $self->{svn}[$$_] : $_ } @$fix; |
|
311
|
|
|
|
|
436
|
|
1882
|
69
|
|
|
|
|
265
|
$self->{fh}->print("$sub(",join(", ",@args),");\n"); |
1883
|
69
|
|
|
|
|
111
|
$keep=0; |
1884
|
|
|
|
|
|
|
} |
1885
|
|
|
|
|
|
|
} else { |
1886
|
0
|
|
|
|
|
0
|
die "Bad fix: ",Dumper($fix); |
1887
|
|
|
|
|
|
|
} |
1888
|
|
|
|
|
|
|
|
1889
|
|
|
|
|
|
|
} |
1890
|
957
|
|
|
|
|
1130
|
$keep; |
1891
|
1146
|
|
|
|
|
844
|
} @{$self->{fix}}; |
|
1146
|
|
|
|
|
1714
|
|
1892
|
1146
|
|
|
|
|
1623
|
foreach my $glob (@globs) { |
1893
|
28
|
|
|
|
|
60
|
my ($type,$lhs,$rhs,$depth,$name)=@$glob; |
1894
|
28
|
50
|
33
|
|
|
68
|
print "Symbol: $name\n" if $DEBUG and $name; |
1895
|
28
|
|
|
|
|
34
|
local @_; |
1896
|
28
|
100
|
|
|
|
44
|
$name=$name ? '*'.$name : $rhs; |
1897
|
28
|
|
|
|
|
25
|
my $overloaded=undef; |
1898
|
28
|
|
|
|
|
23
|
my $isoverloaded=0; |
1899
|
28
|
100
|
66
|
|
|
82
|
if (defined( blessed $lhs ) and |
1900
|
|
|
|
|
|
|
overload::Overloaded( $lhs ) ) |
1901
|
|
|
|
|
|
|
{ |
1902
|
3
|
|
|
|
|
62
|
$overloaded=blessed $lhs; |
1903
|
3
|
|
|
|
|
7
|
disable_overloading( $lhs ); |
1904
|
3
|
|
|
|
|
3
|
$isoverloaded=1; |
1905
|
|
|
|
|
|
|
} |
1906
|
28
|
|
|
|
|
59
|
foreach my $t ($self->_glob_slots('')) |
1907
|
|
|
|
|
|
|
{ |
1908
|
112
|
|
|
|
|
148
|
my $v=*$lhs{$t}; |
1909
|
|
|
|
|
|
|
|
1910
|
112
|
100
|
100
|
|
|
324
|
if ( not(defined $v) or |
|
|
|
66
|
|
|
|
|
1911
|
|
|
|
|
|
|
($t eq 'SCALAR' and !defined($$v))) |
1912
|
|
|
|
|
|
|
{ |
1913
|
68
|
|
|
|
|
73
|
next; |
1914
|
|
|
|
|
|
|
} |
1915
|
|
|
|
|
|
|
|
1916
|
|
|
|
|
|
|
|
1917
|
44
|
|
|
|
|
45
|
my $dumped=0; |
1918
|
|
|
|
|
|
|
|
1919
|
|
|
|
|
|
|
|
1920
|
44
|
|
|
|
|
73
|
my $gaddr=refaddr(*$lhs{$t}); |
1921
|
44
|
|
|
|
|
63
|
my $gidx=$self->{ref}{$gaddr}; |
1922
|
44
|
50
|
|
|
|
117
|
unless ($gidx) { |
|
|
100
|
|
|
|
|
|
1923
|
|
|
|
|
|
|
next |
1924
|
0
|
|
|
|
|
0
|
} elsif ($self->{refd}[$gidx]<$depth+1) { |
1925
|
17
|
|
|
|
|
44
|
$self->_add_fix('ref',$name,$gidx,blessed(*$lhs{$t})); |
1926
|
17
|
|
|
|
|
22
|
next; |
1927
|
|
|
|
|
|
|
} |
1928
|
|
|
|
|
|
|
|
1929
|
27
|
|
|
|
|
89
|
$self->{fh}->print("$name = "); |
1930
|
27
|
|
|
|
|
86
|
my $ret=$self->_dump_sv(*$lhs{$t},$depth,\$dumped,$name,length($name)+3); |
1931
|
27
|
50
|
|
|
|
56
|
Carp::confess "\nUnhandled alias value '$ret' returned to _dump_apply_fix()!" |
1932
|
|
|
|
|
|
|
if $ret; |
1933
|
27
|
|
|
|
|
59
|
$self->{fh}->print(";\n"); |
1934
|
27
|
|
|
|
|
33
|
$dumped=1; |
1935
|
|
|
|
|
|
|
} |
1936
|
|
|
|
|
|
|
|
1937
|
28
|
50
|
33
|
|
|
101
|
if ($self->{style}{deparse} && $self->{style}{deparseglob} |
1938
|
|
|
|
|
|
|
#and defined *$lhs{FORMAT} |
1939
|
|
|
|
|
|
|
) { |
1940
|
|
|
|
|
|
|
# from link from [ysth]: http://groups.google.com/groups?selm=laUs8gzkgOlT092yn%40efn.org |
1941
|
|
|
|
|
|
|
# translate arg (or reference to it) into a B::* object |
1942
|
|
|
|
|
|
|
|
1943
|
|
|
|
|
|
|
# To work-around perl commit |
1944
|
|
|
|
|
|
|
# 2acc3314e31a9342e325f35c5b592967c9850c9b, keep the |
1945
|
|
|
|
|
|
|
# value \*$lhs alive while we inspect it as a B object |
1946
|
|
|
|
|
|
|
# or else it'll be reaped while we're using it. |
1947
|
28
|
|
|
|
|
47
|
my $lhs_glob = \*$lhs; |
1948
|
28
|
|
|
|
|
110
|
my $Bobj = B::svref_2object($lhs_glob); |
1949
|
|
|
|
|
|
|
|
1950
|
|
|
|
|
|
|
# if passed a glob or globref, get the format |
1951
|
28
|
50
|
|
|
|
127
|
$Bobj = B::GV::FORM($Bobj) if ref $Bobj eq 'B::GV'; |
1952
|
|
|
|
|
|
|
|
1953
|
28
|
100
|
|
|
|
81
|
if (ref $Bobj eq 'B::FM') { |
1954
|
1
|
|
|
|
|
5
|
(my $cleaned=$name)=~s/^\*(::)?//; |
1955
|
1
|
|
|
|
|
4
|
$self->{fh}->print("format $cleaned =\n"); |
1956
|
1
|
|
|
|
|
79
|
my $deparser = Data::Dump::Streamer::Deparser->new(); |
1957
|
|
|
|
|
|
|
$self->{fh}->print( |
1958
|
1
|
|
|
|
|
1800
|
$deparser->indent($deparser->deparse_format($Bobj)) |
1959
|
|
|
|
|
|
|
); |
1960
|
1
|
|
|
|
|
3
|
$self->{fh}->print("\n"); |
1961
|
|
|
|
|
|
|
} |
1962
|
|
|
|
|
|
|
} |
1963
|
28
|
100
|
|
|
|
77
|
if ($isoverloaded) { |
1964
|
3
|
|
|
|
|
5
|
restore_overloading( $lhs, $overloaded ); |
1965
|
|
|
|
|
|
|
} |
1966
|
|
|
|
|
|
|
|
1967
|
|
|
|
|
|
|
|
1968
|
|
|
|
|
|
|
} |
1969
|
1146
|
100
|
|
|
|
2573
|
redo GLOB if @globs; |
1970
|
|
|
|
|
|
|
} |
1971
|
|
|
|
|
|
|
} |
1972
|
|
|
|
|
|
|
|
1973
|
|
|
|
|
|
|
=item Out |
1974
|
|
|
|
|
|
|
|
1975
|
|
|
|
|
|
|
=item Out VALUES |
1976
|
|
|
|
|
|
|
|
1977
|
|
|
|
|
|
|
Prints out a set of values to the appropriate location. If provided a list |
1978
|
|
|
|
|
|
|
of values then the values are first scanned with C and then |
1979
|
|
|
|
|
|
|
printed, if called with no values then whatever was scanned last with |
1980
|
|
|
|
|
|
|
C or C is printed. |
1981
|
|
|
|
|
|
|
|
1982
|
|
|
|
|
|
|
If the C attribute was provided then will dump to whatever object |
1983
|
|
|
|
|
|
|
was specified there (any object, including filehandles that accept the |
1984
|
|
|
|
|
|
|
print() method), and will always return $self. |
1985
|
|
|
|
|
|
|
|
1986
|
|
|
|
|
|
|
If the C attribute was not provided then will use an internal |
1987
|
|
|
|
|
|
|
printing object, returning either a list or scalar or printing to STDOUT |
1988
|
|
|
|
|
|
|
in void context. |
1989
|
|
|
|
|
|
|
|
1990
|
|
|
|
|
|
|
This routine is virtually always called without arguments as the last |
1991
|
|
|
|
|
|
|
method in the method chain. |
1992
|
|
|
|
|
|
|
|
1993
|
|
|
|
|
|
|
Dump->Arguments(1)->Out(@vars); |
1994
|
|
|
|
|
|
|
$obj->Data(@vars)->Out(); |
1995
|
|
|
|
|
|
|
Dump(@vars)->Out; |
1996
|
|
|
|
|
|
|
Data::Dump::Streamer->Out(@vars); |
1997
|
|
|
|
|
|
|
|
1998
|
|
|
|
|
|
|
All should DWIM. |
1999
|
|
|
|
|
|
|
|
2000
|
|
|
|
|
|
|
=cut |
2001
|
|
|
|
|
|
|
|
2002
|
|
|
|
|
|
|
# |
2003
|
|
|
|
|
|
|
# Out is just a wrapper. The overall dumping process works like this: |
2004
|
|
|
|
|
|
|
# |
2005
|
|
|
|
|
|
|
# Out |
2006
|
|
|
|
|
|
|
# foreach root value |
2007
|
|
|
|
|
|
|
# _dump_sv |
2008
|
|
|
|
|
|
|
# _dump_rv if ref |
2009
|
|
|
|
|
|
|
# (optionally one of) |
2010
|
|
|
|
|
|
|
# _dump_array |
2011
|
|
|
|
|
|
|
# _dump_hash |
2012
|
|
|
|
|
|
|
# _dump_code |
2013
|
|
|
|
|
|
|
# _dump_qr |
2014
|
|
|
|
|
|
|
# _dump_apply_fix |
2015
|
|
|
|
|
|
|
# (which may call) |
2016
|
|
|
|
|
|
|
# _dump_sv |
2017
|
|
|
|
|
|
|
# |
2018
|
|
|
|
|
|
|
# _dump_array, _dump_hash, _dump_rv if needed may also call _dump_sv |
2019
|
|
|
|
|
|
|
# |
2020
|
|
|
|
|
|
|
# essentially _dump_sv and _dump_rv handle uniqueness checks for scalars, |
2021
|
|
|
|
|
|
|
# and refs. _dump_sv handles the SV's containers and _dump_rv |
2022
|
|
|
|
|
|
|
# handles the things that the SV contains a reference to. _dump_sv also |
2023
|
|
|
|
|
|
|
# handles simple values and globs, and works with _dump_rv to handle |
2024
|
|
|
|
|
|
|
# references to scalars correctly. If "fix" statements are required |
2025
|
|
|
|
|
|
|
# to complete the definition of the structure (self referential structures) |
2026
|
|
|
|
|
|
|
# then _add_fix adds them to the list, and _dump_apply_fix pulls them off. |
2027
|
|
|
|
|
|
|
# note that _dump_apply_fix can also call _dump_sv if needed (to handle globs), |
2028
|
|
|
|
|
|
|
# and will also emit fix statements as early as possible. no require/use |
2029
|
|
|
|
|
|
|
# logic is currently in place. its the evalers responsibility to use the mod |
2030
|
|
|
|
|
|
|
# w/the right tags for now... |
2031
|
|
|
|
|
|
|
|
2032
|
|
|
|
|
|
|
sub Out { |
2033
|
348
|
|
|
348
|
1
|
1413
|
local($\,$",$,)=("","",""); # prevent globals from messing with our output via print |
2034
|
348
|
|
|
|
|
651
|
my $self = shift->_safe_self; |
2035
|
348
|
50
|
|
|
|
672
|
print "Out(".scalar(@_)." vars)\n" |
2036
|
|
|
|
|
|
|
if $DEBUG; |
2037
|
348
|
100
|
66
|
|
|
2056
|
if ( !$self->{in_printit} and (@_ or !$self->{cataloged} )) { |
|
|
|
33
|
|
|
|
|
2038
|
7
|
|
|
|
|
42
|
$self->Data(@_); |
2039
|
|
|
|
|
|
|
} |
2040
|
|
|
|
|
|
|
|
2041
|
348
|
|
|
|
|
322
|
my $fh; |
2042
|
348
|
50
|
|
|
|
599
|
unless ( $self->{fh} ) { |
2043
|
348
|
50
|
|
|
|
526
|
print " no filehandle using " |
2044
|
|
|
|
|
|
|
if $DEBUG; |
2045
|
348
|
50
|
|
|
|
558
|
if (defined wantarray) { |
2046
|
348
|
100
|
|
|
|
749
|
my $class= __PACKAGE__ . (wantarray ? "::_::ListPrinter" : "::_::StringPrinter"); |
2047
|
348
|
50
|
|
|
|
502
|
print $class,"\n" |
2048
|
|
|
|
|
|
|
if $DEBUG; |
2049
|
348
|
50
|
|
|
|
1423
|
$fh = $class->new() |
2050
|
|
|
|
|
|
|
or Carp::confess "$class failed to build!"; |
2051
|
348
|
|
|
|
|
578
|
$self->{'return'} = $fh; |
2052
|
|
|
|
|
|
|
} else { |
2053
|
0
|
0
|
|
|
|
0
|
print "STDOUT\n" if $DEBUG; |
2054
|
0
|
|
|
|
|
0
|
$fh = \*STDOUT; |
2055
|
|
|
|
|
|
|
} |
2056
|
348
|
|
|
|
|
428
|
$self->{fh} = $fh; |
2057
|
|
|
|
|
|
|
} |
2058
|
|
|
|
|
|
|
# loop over the list |
2059
|
|
|
|
|
|
|
# and dump out each one in turn |
2060
|
|
|
|
|
|
|
# handling any potential fixes after |
2061
|
|
|
|
|
|
|
# each definition is complete |
2062
|
348
|
|
|
|
|
438
|
$self->{out_names}=[]; |
2063
|
348
|
|
|
|
|
545
|
$self->{declare}=[]; |
2064
|
348
|
|
|
|
|
522
|
$self->{special}={}; |
2065
|
348
|
50
|
|
|
|
686
|
$DEBUG>9 and $self->diag; |
2066
|
|
|
|
|
|
|
|
2067
|
348
|
|
|
|
|
300
|
my @items=@{$args_insideout{refaddr $self}}; |
|
348
|
|
|
|
|
1005
|
|
2068
|
|
|
|
|
|
|
|
2069
|
348
|
|
|
|
|
362
|
my $namestr=""; |
2070
|
|
|
|
|
|
|
|
2071
|
348
|
|
|
|
|
271
|
push @{$self->{out_names}},map{$_->{name}}@items; #must |
|
348
|
|
|
|
|
623
|
|
|
772
|
|
|
|
|
1229
|
|
2072
|
348
|
|
|
|
|
333
|
push @{$self->{declare}},map{$_->{name}}@items; |
|
348
|
|
|
|
|
480
|
|
|
772
|
|
|
|
|
959
|
|
2073
|
|
|
|
|
|
|
|
2074
|
348
|
50
|
|
|
|
837
|
if ($self->{style}{special}) { |
2075
|
|
|
|
|
|
|
|
2076
|
0
|
0
|
|
|
|
0
|
warn DDumper(\@items) if $DEBUG; |
2077
|
|
|
|
|
|
|
|
2078
|
0
|
|
|
|
|
0
|
$namestr="# (".join (", ",@{$self->{out_names}}).")\n"; |
|
0
|
|
|
|
|
0
|
|
2079
|
|
|
|
|
|
|
|
2080
|
0
|
|
|
|
|
0
|
@items=sort { $self->{svc}[$b->{idx}] <=> $self->{svc}[$a->{idx}]|| |
2081
|
|
|
|
|
|
|
($b->{raddr} ? $self->{refc}[$b->{ridx}] : 0) |
2082
|
|
|
|
|
|
|
<=> |
2083
|
0
|
0
|
|
|
|
0
|
($a->{raddr} ? $self->{refc}[$a->{ridx}] : 0) |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
2084
|
|
|
|
|
|
|
} @items; |
2085
|
|
|
|
|
|
|
|
2086
|
|
|
|
|
|
|
|
2087
|
|
|
|
|
|
|
|
2088
|
|
|
|
|
|
|
|
2089
|
0
|
0
|
|
|
|
0
|
warn DDumper(\@items) if $DEBUG; |
2090
|
|
|
|
|
|
|
} |
2091
|
|
|
|
|
|
|
|
2092
|
348
|
50
|
66
|
|
|
650
|
if ($self->{style}{compress} && $self->{style}{compressor}) { |
2093
|
2
|
|
|
|
|
9
|
my $prelude=$self->{style}{compressor}->(); |
2094
|
2
|
50
|
|
|
|
9
|
$self->{fh}->print($prelude) if $prelude; |
2095
|
|
|
|
|
|
|
} |
2096
|
|
|
|
|
|
|
|
2097
|
11
|
|
|
|
|
72
|
$self->{fh}->print("my (",join(",",sort keys %{$self->{lexicals}{added}}),");\n") |
2098
|
348
|
100
|
|
|
|
634
|
if $self->{lexicals}{added}; |
2099
|
|
|
|
|
|
|
|
2100
|
348
|
|
|
|
|
458
|
foreach my $item (@items) { |
2101
|
772
|
|
|
|
|
601
|
my $dumped=0; |
2102
|
772
|
|
|
|
|
580
|
my $ret=$self->_dump_sv(${$item->{item}},1,\$dumped,$item->{name}); |
|
772
|
|
|
|
|
1881
|
|
2103
|
772
|
50
|
|
|
|
1176
|
Carp::confess "\nUnhandled alias value '$ret' returned to Out()!" |
2104
|
|
|
|
|
|
|
if $ret; |
2105
|
772
|
|
|
|
|
1650
|
$self->{fh}->print(";\n"); |
2106
|
772
|
|
|
|
|
645
|
$dumped=1; |
2107
|
772
|
|
|
|
|
1202
|
$self->_dump_apply_fix(); |
2108
|
|
|
|
|
|
|
} |
2109
|
348
|
|
|
|
|
551
|
$self->_dump_apply_fix('final'); |
2110
|
348
|
50
|
|
|
|
535
|
$self->{fh}->print($namestr) if $namestr; |
2111
|
|
|
|
|
|
|
|
2112
|
348
|
50
|
|
|
|
580
|
$self->diag if $DEBUG; |
2113
|
|
|
|
|
|
|
#warn "@{$self->{out_names}}"; |
2114
|
348
|
50
|
33
|
|
|
1414
|
if ( $self->{return} and defined wantarray) { |
2115
|
348
|
|
|
|
|
537
|
my $r = delete $self->{return}; |
2116
|
348
|
|
|
|
|
402
|
delete $self->{fh}; |
2117
|
348
|
|
|
|
|
900
|
return $r->value; |
2118
|
|
|
|
|
|
|
} else { |
2119
|
0
|
|
|
|
|
0
|
return $self; |
2120
|
|
|
|
|
|
|
} |
2121
|
|
|
|
|
|
|
|
2122
|
|
|
|
|
|
|
} |
2123
|
|
|
|
|
|
|
|
2124
|
|
|
|
|
|
|
|
2125
|
|
|
|
|
|
|
sub print_token { |
2126
|
0
|
|
|
0
|
0
|
0
|
my ($self, $str)=@_; |
2127
|
0
|
|
|
|
|
0
|
$self->{fh}->print($str); |
2128
|
|
|
|
|
|
|
} |
2129
|
|
|
|
|
|
|
sub print_quoted { |
2130
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $str )=@_; |
2131
|
0
|
|
|
|
|
0
|
$self->{fh}->print($str); |
2132
|
|
|
|
|
|
|
} |
2133
|
|
|
|
|
|
|
|
2134
|
|
|
|
|
|
|
# sqz(str,begin,end) |
2135
|
|
|
|
|
|
|
sub sqz { |
2136
|
2
|
|
|
2
|
0
|
12
|
require Compress::Zlib; |
2137
|
2
|
|
|
|
|
5
|
require MIME::Base64; |
2138
|
2
|
|
|
|
|
5
|
my $res= Compress::Zlib::compress($_[0],9); |
2139
|
2
|
50
|
|
|
|
315
|
return $_[1] |
2140
|
|
|
|
|
|
|
? $_[1] |
2141
|
|
|
|
|
|
|
. MIME::Base64::encode($res,"") |
2142
|
|
|
|
|
|
|
. $_[2] |
2143
|
|
|
|
|
|
|
: MIME::Base64::encode($res,""); |
2144
|
|
|
|
|
|
|
} |
2145
|
|
|
|
|
|
|
|
2146
|
|
|
|
|
|
|
# usqz(str) |
2147
|
|
|
|
|
|
|
sub usqz { |
2148
|
0
|
|
|
0
|
0
|
0
|
return Compress::Zlib::uncompress( |
2149
|
|
|
|
|
|
|
MIME::Base64::decode($_[0]) |
2150
|
|
|
|
|
|
|
); |
2151
|
|
|
|
|
|
|
} |
2152
|
|
|
|
|
|
|
|
2153
|
|
|
|
|
|
|
|
2154
|
|
|
|
|
|
|
|
2155
|
|
|
|
|
|
|
sub _dump_sv { |
2156
|
3564
|
|
|
3564
|
|
4274
|
my ($self,$item,$depth,$dumped,$name,$indent,$is_ref)=@_; |
2157
|
|
|
|
|
|
|
|
2158
|
3564
|
|
|
|
|
3326
|
$self->{do_nl}=0; |
2159
|
|
|
|
|
|
|
|
2160
|
3564
|
|
|
|
|
5390
|
my $addr=refaddr(\$_[1]); |
2161
|
3564
|
|
|
|
|
4240
|
my $idx=$self->{sv}{$addr}; |
2162
|
3564
|
|
|
|
|
2506
|
my $ro; |
2163
|
3564
|
50
|
0
|
|
|
4911
|
$DEBUG and printf "_dump_sv %d %s %#x - %d\n",$depth, $name,$addr,$idx||0; |
2164
|
|
|
|
|
|
|
|
2165
|
|
|
|
|
|
|
|
2166
|
3564
|
|
66
|
|
|
4601
|
$name||=$self->{svn}[$idx]; |
2167
|
3564
|
|
|
|
|
5987
|
(my $clean_name=$name)=~s/^[\@\%\&](\w+)/\$${1}_/; # XXX |
2168
|
3564
|
|
|
|
|
3719
|
my $optspace=$self->{style}{optspace}; |
2169
|
3564
|
100
|
|
|
|
4087
|
if ($idx) { |
2170
|
|
|
|
|
|
|
|
2171
|
|
|
|
|
|
|
# Its a monitored scalar. |
2172
|
|
|
|
|
|
|
|
2173
|
1491
|
|
|
|
|
1678
|
my $pre_dumped=$self->{svdu}[$idx]; |
2174
|
|
|
|
|
|
|
my $name_diff=( |
2175
|
|
|
|
|
|
|
$self->{svd}[$idx]==$depth |
2176
|
1491
|
|
66
|
|
|
6140
|
and $self->{svn}[$idx] ne $clean_name |
2177
|
|
|
|
|
|
|
and $clean_name!~/\*/ |
2178
|
|
|
|
|
|
|
and $name!~/^\&/ |
2179
|
|
|
|
|
|
|
); |
2180
|
|
|
|
|
|
|
|
2181
|
|
|
|
|
|
|
#print "Idx: $idx Special keys:",join("-",keys %{$self->{special}}),"\n" |
2182
|
|
|
|
|
|
|
# if $DEBUG and keys %{$self->{special}}; |
2183
|
|
|
|
|
|
|
|
2184
|
1491
|
50
|
|
|
|
1969
|
print "sv_dump Monitored:\n",$self->diag_sv_idx($idx," ") if $DEBUG; |
2185
|
|
|
|
|
|
|
|
2186
|
|
|
|
|
|
|
|
2187
|
1491
|
100
|
100
|
|
|
7372
|
if (( $pre_dumped and !$self->{svon}{$idx}) |
|
|
100
|
100
|
|
|
|
|
|
|
|
66
|
|
|
|
|
2188
|
|
|
|
|
|
|
or (!$self->{svon}{$idx} ? ($self->{svd}[$idx]<$depth or $name_diff) : undef) ) |
2189
|
|
|
|
|
|
|
{ |
2190
|
|
|
|
|
|
|
|
2191
|
|
|
|
|
|
|
print "PREDUMPED: $self->{svon}{$idx}\n" |
2192
|
316
|
0
|
33
|
|
|
457
|
if $DEBUG and $self->{svon}{$idx} and $pre_dumped and $$pre_dumped; |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
2193
|
|
|
|
|
|
|
|
2194
|
|
|
|
|
|
|
# We've seen it before. |
2195
|
|
|
|
|
|
|
# Unless its a ref it must be an alias |
2196
|
316
|
0
|
|
|
|
416
|
print(($name_diff ? "Name diff" : "No name diff"), " $name, $clean_name","\n") |
|
|
50
|
|
|
|
|
|
2197
|
|
|
|
|
|
|
if $DEBUG; |
2198
|
|
|
|
|
|
|
|
2199
|
316
|
|
|
|
|
366
|
my ($str,$ret)=('',undef); |
2200
|
|
|
|
|
|
|
|
2201
|
316
|
100
|
|
|
|
385
|
if ($is_ref) { |
2202
|
220
|
100
|
100
|
|
|
1018
|
if ($self->{svd}[$idx]==1 && !$self->{style}{declare} |
|
|
|
100
|
|
|
|
|
|
|
|
66
|
|
|
|
|
2203
|
|
|
|
|
|
|
|| ($pre_dumped && $$pre_dumped) |
2204
|
|
|
|
|
|
|
) { |
2205
|
104
|
|
|
|
|
153
|
$str="\\$self->{svn}[$idx]"; |
2206
|
|
|
|
|
|
|
} else { |
2207
|
|
|
|
|
|
|
#see the 'Many refs' tests in t\dump.t for |
2208
|
|
|
|
|
|
|
#why this is here. basically we need to |
2209
|
|
|
|
|
|
|
#ensure the ref is modifiable. If its two $'s |
2210
|
|
|
|
|
|
|
#then its modifiable anyway, more and it wont be. |
2211
|
|
|
|
|
|
|
# $ref=\\$x; $ref=RW $$ref=RO $$$ref=$x=RW |
2212
|
116
|
100
|
|
|
|
184
|
unless ($self->{style}{purity}) { |
2213
|
6
|
|
|
|
|
10
|
$str="\\$self->{svn}[$idx]"; |
2214
|
|
|
|
|
|
|
} else { |
2215
|
110
|
|
|
|
|
164
|
my $need_do=($name=~/^\$\$\$+/); |
2216
|
110
|
100
|
|
|
|
159
|
if ($need_do) { |
2217
|
4
|
|
|
|
|
11
|
$str.=join($optspace,qw( do { my $f = ),''); |
2218
|
|
|
|
|
|
|
} |
2219
|
|
|
|
|
|
|
|
2220
|
|
|
|
|
|
|
$str.=!$self->{style}{verbose} |
2221
|
110
|
50
|
|
|
|
424
|
? "'R'" : _quote($DEBUG ? 'SR: ' : 'R: ', |
|
|
50
|
|
|
|
|
|
2222
|
|
|
|
|
|
|
"$self->{svn}[$idx]"); |
2223
|
110
|
|
|
|
|
118
|
$ret=\do{my $nope=0}; |
|
110
|
|
|
|
|
173
|
|
2224
|
110
|
|
|
|
|
220
|
$self->_add_fix('sv',$name,$idx,$ret); |
2225
|
|
|
|
|
|
|
|
2226
|
110
|
100
|
|
|
|
205
|
$str.="$optspace}" if ($need_do) |
2227
|
|
|
|
|
|
|
} |
2228
|
|
|
|
|
|
|
} |
2229
|
|
|
|
|
|
|
} else { |
2230
|
96
|
100
|
|
|
|
177
|
if ($depth==1) { |
|
|
100
|
|
|
|
|
|
2231
|
36
|
50
|
|
|
|
78
|
if ($self->{style}{declare}) { |
2232
|
0
|
|
|
|
|
0
|
$str.="my $name;\n"; |
2233
|
|
|
|
|
|
|
} |
2234
|
|
|
|
|
|
|
#push @{$self->{out_names}},$name; |
2235
|
|
|
|
|
|
|
#push @{$self->{declare}},$name; |
2236
|
36
|
|
|
|
|
68
|
$str.="alias_ref(\\$name,\\$self->{svn}[$idx])"; |
2237
|
|
|
|
|
|
|
} elsif ($self->{style}{purity}) { |
2238
|
52
|
50
|
|
|
|
129
|
$str.=!$self->{style}{verbose} ? "'A'" : _quote("A: ",$self->{svn}[$idx]); |
2239
|
52
|
|
|
|
|
68
|
$ret=\$idx; |
2240
|
|
|
|
|
|
|
} else { |
2241
|
8
|
|
|
|
|
13
|
$str.="alias_to($self->{svn}[$idx])"; |
2242
|
8
|
|
|
|
|
8
|
$ret=''; |
2243
|
|
|
|
|
|
|
} |
2244
|
|
|
|
|
|
|
} |
2245
|
316
|
|
|
|
|
642
|
$self->{buf}+=length($str); |
2246
|
316
|
50
|
|
|
|
598
|
$self->{buf}=length($1) if $str=~/\n([^\n]*)\s*\z/; |
2247
|
316
|
|
|
|
|
832
|
$self->{fh}->print($str); |
2248
|
316
|
100
|
|
|
|
716
|
return $ret ? $ret : () |
2249
|
|
|
|
|
|
|
} else { |
2250
|
|
|
|
|
|
|
# we've never seen it before and we need to dump it. |
2251
|
1175
|
|
66
|
|
|
3138
|
$self->{svdu}[$idx]||=$dumped; |
2252
|
|
|
|
|
|
|
|
2253
|
|
|
|
|
|
|
print "Defining Special:".$self->diag_sv_idx($idx) |
2254
|
1175
|
0
|
33
|
|
|
1638
|
if $DEBUG and $self->{special}{$idx}; |
2255
|
|
|
|
|
|
|
|
2256
|
1175
|
50
|
|
|
|
1779
|
$self->{svn}[$idx]=$name if $self->{special}{$idx}; |
2257
|
1175
|
50
|
|
|
|
1740
|
$self->{svd}[$idx]=$depth if $self->{special}{$idx}; |
2258
|
|
|
|
|
|
|
|
2259
|
|
|
|
|
|
|
} |
2260
|
1175
|
|
|
|
|
1263
|
$ro=$self->{svro}[$idx]; |
2261
|
|
|
|
|
|
|
} else { |
2262
|
2073
|
50
|
|
|
|
4787
|
$ro=readonly $_[1] unless defined $ro; |
2263
|
|
|
|
|
|
|
} |
2264
|
3248
|
50
|
|
|
|
4111
|
print "sv_dump: Postindexed\n" if $DEBUG; |
2265
|
3248
|
100
|
|
|
|
4623
|
if ($depth==1) { |
2266
|
|
|
|
|
|
|
# root level object. declare it |
2267
|
736
|
50
|
66
|
|
|
1980
|
if ($name ne $clean_name and $name!~/^\*/ and $self->{svc}[$idx]>1) { |
|
|
|
66
|
|
|
|
|
2268
|
|
|
|
|
|
|
|
2269
|
139
|
50
|
|
|
|
227
|
print "Special $name\n" if $DEBUG; |
2270
|
139
|
|
|
|
|
256
|
my $oidx=$self->{ref}{$self->{sva}[$idx]}; |
2271
|
139
|
100
|
|
|
|
236
|
if ($oidx) { |
2272
|
|
|
|
|
|
|
#theres a ref to us out there |
2273
|
19
|
|
|
|
|
63
|
my $name=$self->_build_name($self->{refn}[$oidx],'$'); |
2274
|
19
|
|
|
|
|
30
|
$self->{svn}[$idx]=$name; |
2275
|
19
|
50
|
|
|
|
43
|
print "Oindex! $oidx $name\n" if $DEBUG; |
2276
|
|
|
|
|
|
|
#$self->{svd}[$idx]=$self->{refd}[$idx]+1; |
2277
|
|
|
|
|
|
|
} |
2278
|
|
|
|
|
|
|
|
2279
|
|
|
|
|
|
|
#$self->{special}{$idx}++; |
2280
|
139
|
|
|
|
|
154
|
$self->{svdu}[$idx]=undef; |
2281
|
|
|
|
|
|
|
|
2282
|
139
|
50
|
|
|
|
244
|
print $self->diag_sv_idx($idx,1) if $DEBUG; |
2283
|
|
|
|
|
|
|
} |
2284
|
|
|
|
|
|
|
#push @{$self->{out_names}},$name; #must |
2285
|
|
|
|
|
|
|
#push @{$self->{declare}},$name; |
2286
|
736
|
100
|
|
|
|
1220
|
unless ($name=~/^\&/) { # XXX |
2287
|
|
|
|
|
|
|
my $str=(($self->{style}{declare} && $name!~/^\*/ |
2288
|
732
|
100
|
66
|
|
|
3074
|
&& !$self->{lexicals}{added}{$name} |
2289
|
|
|
|
|
|
|
) ? "my$optspace" : "" |
2290
|
|
|
|
|
|
|
)."$name$optspace=$optspace"; |
2291
|
732
|
|
|
|
|
1835
|
$self->{fh}->print($str); |
2292
|
732
|
|
|
|
|
572
|
$indent=length($str); |
2293
|
732
|
|
|
|
|
847
|
$self->{buf}=0; |
2294
|
|
|
|
|
|
|
} else { |
2295
|
4
|
|
|
|
|
5
|
$indent=0; |
2296
|
|
|
|
|
|
|
} |
2297
|
736
|
50
|
|
|
|
1140
|
print "toplevel\n" if $DEBUG; |
2298
|
|
|
|
|
|
|
} |
2299
|
|
|
|
|
|
|
|
2300
|
3248
|
|
|
|
|
3872
|
my $iaddr=refaddr $item; |
2301
|
|
|
|
|
|
|
|
2302
|
3248
|
100
|
|
|
|
4618
|
$self->{fh}->print("\\") |
2303
|
|
|
|
|
|
|
if $is_ref; |
2304
|
|
|
|
|
|
|
|
2305
|
3248
|
|
|
|
|
4043
|
my $glob=globname $item; |
2306
|
|
|
|
|
|
|
my $add_do=$self->{style}{purity} |
2307
|
|
|
|
|
|
|
&& !$ro |
2308
|
|
|
|
|
|
|
&& $is_ref |
2309
|
|
|
|
|
|
|
&& !blessed($_[1]) |
2310
|
|
|
|
|
|
|
&& !$glob |
2311
|
3248
|
|
66
|
|
|
17213
|
&& do { |
2312
|
|
|
|
|
|
|
my $rtype= reftype($_[1]); |
2313
|
|
|
|
|
|
|
$rtype eq "" or |
2314
|
|
|
|
|
|
|
($rtype eq "SCALAR" and ( $] < 5.020 or !readonly(${ $_[1] }) ) ) |
2315
|
|
|
|
|
|
|
} |
2316
|
|
|
|
|
|
|
; |
2317
|
|
|
|
|
|
|
|
2318
|
|
|
|
|
|
|
|
2319
|
3248
|
100
|
|
|
|
4429
|
if ($add_do) { |
2320
|
|
|
|
|
|
|
#warn "\n!$ro && $is_ref && !blessed($_[1]) && !$glob"; |
2321
|
35
|
|
|
|
|
130
|
$self->{fh}->print(join $optspace,qw(do { my $v = ),''); |
2322
|
35
|
|
|
|
|
44
|
$self->{buf}+=13; |
2323
|
|
|
|
|
|
|
} |
2324
|
|
|
|
|
|
|
|
2325
|
3248
|
100
|
|
|
|
3751
|
unless ($iaddr) { |
2326
|
1250
|
50
|
|
|
|
1574
|
print "iaddr $glob\n" if $DEBUG; |
2327
|
1250
|
100
|
|
|
|
1479
|
unless (defined $item) { |
2328
|
116
|
|
|
|
|
411
|
$self->{fh}->print('undef'); |
2329
|
116
|
|
|
|
|
175
|
$self->{buf}+=5; |
2330
|
|
|
|
|
|
|
} else { |
2331
|
1134
|
|
100
|
|
|
3387
|
my $is_ro=($self->{style}{ro} && $ro && !$is_ref); |
2332
|
1134
|
100
|
100
|
|
|
1760
|
if ($is_ro and !$self->{style}{purity}) { |
2333
|
1
|
|
|
|
|
5
|
$self->{fh}->print("make_ro($optspace"); |
2334
|
|
|
|
|
|
|
} |
2335
|
1134
|
100
|
|
|
|
1192
|
if ($glob) { |
2336
|
20
|
100
|
|
|
|
39
|
if ($glob=~/^\*Symbol::GEN/) { |
2337
|
1
|
|
|
|
|
4
|
$self->_dump_symbol($_[1],$name,$glob,'deref',$depth); |
2338
|
|
|
|
|
|
|
} else |
2339
|
|
|
|
|
|
|
{ |
2340
|
19
|
|
|
|
|
25
|
$self->{buf}+=length($glob); |
2341
|
19
|
|
|
|
|
49
|
$self->{fh}->print($glob); |
2342
|
19
|
50
|
33
|
|
|
112
|
if ($self->{style}{dumpglob} and |
2343
|
|
|
|
|
|
|
!$self->{sv_glob_du}{$glob}++) { |
2344
|
19
|
|
|
|
|
56
|
$self->_add_fix('glob',$_[1],$glob,$depth+1); |
2345
|
|
|
|
|
|
|
} |
2346
|
|
|
|
|
|
|
} |
2347
|
|
|
|
|
|
|
} else { |
2348
|
1114
|
|
|
|
|
770
|
my $quoted; |
2349
|
1114
|
100
|
|
|
|
1676
|
if ($self->{style}{dualvars}) { |
2350
|
24
|
|
|
24
|
|
211
|
no warnings 'numeric'; # XXX: is this required? |
|
24
|
|
|
|
|
36
|
|
|
24
|
|
|
|
|
16930
|
|
2351
|
1112
|
100
|
100
|
|
|
2576
|
if (_could_be_dualvar($item) && 0+$item ne $item && "$item" != $item ) { |
|
|
|
66
|
|
|
|
|
2352
|
2
|
|
|
|
|
7
|
$quoted="dualvar( ".join(",$optspace",0+$item,_quote("$item"))."$optspace)"; |
2353
|
|
|
|
|
|
|
} |
2354
|
|
|
|
|
|
|
} |
2355
|
|
|
|
|
|
|
# XXX main scalar output here! |
2356
|
1114
|
100
|
|
|
|
1489
|
if ( ! $quoted ) { |
2357
|
1112
|
|
|
|
|
974
|
my $style= $self->{style}; |
2358
|
|
|
|
|
|
|
|
2359
|
1112
|
100
|
66
|
|
|
2086
|
if ( $style->{compress} && |
|
|
|
33
|
|
|
|
|
2360
|
|
|
|
|
|
|
$style->{compressor} && |
2361
|
|
|
|
|
|
|
length($_[1]) > $style->{compress} |
2362
|
|
|
|
|
|
|
){ |
2363
|
2
|
|
|
|
|
5
|
$quoted= $style->{compressor}->($_[1],$self); |
2364
|
|
|
|
|
|
|
} else { |
2365
|
1110
|
|
|
|
|
1308
|
$quoted=_quote($item); |
2366
|
|
|
|
|
|
|
} |
2367
|
|
|
|
|
|
|
|
2368
|
|
|
|
|
|
|
} |
2369
|
1114
|
|
|
|
|
1378
|
$self->{buf}+=length($quoted); |
2370
|
1114
|
50
|
|
|
|
1684
|
$self->{buf}=length($1) if $quoted=~/\n([^\n]*)\s*\z/; |
2371
|
1114
|
|
|
|
|
2616
|
$self->{fh}->print($quoted); #; |
2372
|
|
|
|
|
|
|
} |
2373
|
1134
|
100
|
66
|
|
|
2769
|
if ($is_ro && $self->{style}{purity}) { |
|
|
100
|
|
|
|
|
|
2374
|
9
|
|
|
|
|
22
|
$self->_add_fix('sub call','make_ro',$name); |
2375
|
|
|
|
|
|
|
} elsif ($is_ro) { |
2376
|
1
|
|
|
|
|
4
|
$self->{fh}->print("$optspace)"); |
2377
|
|
|
|
|
|
|
} |
2378
|
|
|
|
|
|
|
#return |
2379
|
|
|
|
|
|
|
} |
2380
|
1250
|
|
|
|
|
1164
|
$self->{do_nl}=0; |
2381
|
|
|
|
|
|
|
} else { |
2382
|
1998
|
|
|
|
|
1808
|
$self->{do_nl}=1; |
2383
|
1998
|
|
100
|
|
|
5921
|
$self->_dump_rv($item,$depth+1,$dumped,$name,$indent,$is_ref && !$add_do); |
2384
|
|
|
|
|
|
|
} |
2385
|
3248
|
100
|
|
|
|
4355
|
$self->{fh}->print("$optspace}") |
2386
|
|
|
|
|
|
|
if $add_do; |
2387
|
|
|
|
|
|
|
$self->_add_fix('sub call','weaken',$name) |
2388
|
3248
|
100
|
|
|
|
4694
|
if $self->{svw}{$addr}; |
2389
|
|
|
|
|
|
|
return |
2390
|
3248
|
|
|
|
|
4148
|
} |
2391
|
|
|
|
|
|
|
|
2392
|
|
|
|
|
|
|
sub _brace { |
2393
|
1796
|
|
|
1796
|
|
2411
|
my ($self,$name,$type,$cond,$indent,$child)=@_; |
2394
|
1796
|
|
|
|
|
3003
|
my $open=$type=~/[\{\[\(]/; |
2395
|
|
|
|
|
|
|
|
2396
|
1796
|
100
|
|
|
|
3294
|
my $brace= $name !~ /^[%@]/ |
|
|
100
|
|
|
|
|
|
2397
|
|
|
|
|
|
|
? $type |
2398
|
|
|
|
|
|
|
: $type =~ /[\{\[\(]/ |
2399
|
|
|
|
|
|
|
? '(' |
2400
|
|
|
|
|
|
|
: ')'; |
2401
|
1796
|
100
|
|
|
|
2593
|
$child= $child ? $self->{style}{optspace} : ""; |
2402
|
1796
|
100
|
|
|
|
2054
|
if ( $cond ) { |
2403
|
|
|
|
|
|
|
$_[-2] += $open ? $self->{style}{indentcols} |
2404
|
982
|
100
|
|
|
|
1843
|
: -$self->{style}{indentcols}; |
2405
|
982
|
100
|
|
|
|
4223
|
$self->{fh}->print($open ? "" : "\n".(" " x $_[-2]), |
|
|
100
|
|
|
|
|
|
2406
|
|
|
|
|
|
|
$brace, |
2407
|
|
|
|
|
|
|
$open ? "\n".(" " x $_[-2]) : ""); |
2408
|
|
|
|
|
|
|
} else { |
2409
|
814
|
100
|
|
|
|
2710
|
$self->{fh}->print($open ? "" : $child , |
|
|
100
|
|
|
|
|
|
2410
|
|
|
|
|
|
|
$brace, |
2411
|
|
|
|
|
|
|
$open ? $child : ""); |
2412
|
|
|
|
|
|
|
} |
2413
|
|
|
|
|
|
|
return |
2414
|
1796
|
|
|
|
|
2232
|
} |
2415
|
|
|
|
|
|
|
|
2416
|
|
|
|
|
|
|
sub _dump_qr { |
2417
|
49
|
|
|
49
|
|
51
|
my ($self,$pat,$mod)=@_; |
2418
|
49
|
|
|
|
|
49
|
my %counts; |
2419
|
49
|
|
|
|
|
369
|
$counts{$_}++ foreach split //,$pat; |
2420
|
49
|
|
|
|
|
112
|
my ($quotes,$best)=('',length($pat)+1); |
2421
|
49
|
|
|
|
|
80
|
foreach my $char (qw( / ! % & <> {} " ),'#') { #" |
2422
|
51
|
|
|
|
|
46
|
my $bad=0; |
2423
|
51
|
|
100
|
|
|
202
|
$bad+=$counts{$_}||0 for split //,$char; |
2424
|
51
|
50
|
|
|
|
115
|
($quotes,$best)=($char,$bad) if $bad<$best; |
2425
|
51
|
100
|
|
|
|
106
|
last unless $best; |
2426
|
|
|
|
|
|
|
} |
2427
|
49
|
50
|
|
|
|
90
|
$pat=~s/(?!\\)([$quotes])/\\$1/g |
2428
|
|
|
|
|
|
|
if $best; |
2429
|
|
|
|
|
|
|
{ |
2430
|
24
|
|
|
24
|
|
137
|
use utf8; |
|
24
|
|
|
|
|
36
|
|
|
24
|
|
|
|
|
128
|
|
|
49
|
|
|
|
|
38
|
|
2431
|
|
|
|
|
|
|
#$pat=~s/([^\x00-\x7f])/sprintf '\\x{%x}',ord $1/ge; |
2432
|
49
|
|
|
|
|
98
|
$pat=~s/([^\040-\176])/sprintf "\\x{%x}", ord($1)/ge; |
|
1
|
|
|
|
|
7
|
|
2433
|
|
|
|
|
|
|
} |
2434
|
49
|
|
|
|
|
181
|
$self->{fh}->print('qr',substr($quotes,0,1),$pat,substr($quotes,-1),$mod); |
2435
|
|
|
|
|
|
|
return |
2436
|
49
|
|
|
|
|
123
|
} |
2437
|
|
|
|
|
|
|
|
2438
|
|
|
|
|
|
|
=for uedit32 |
2439
|
|
|
|
|
|
|
sub _default_key_sorters{} |
2440
|
|
|
|
|
|
|
|
2441
|
|
|
|
|
|
|
=cut |
2442
|
|
|
|
|
|
|
|
2443
|
|
|
|
|
|
|
my %default_key_sorters= ( |
2444
|
|
|
|
|
|
|
numeric => sub { [ sort {$a <=> $b} keys %{$_[0]} ] }, |
2445
|
|
|
|
|
|
|
lexical => sub { [ sort keys %{$_[0]} ] }, |
2446
|
|
|
|
|
|
|
smart => sub { |
2447
|
|
|
|
|
|
|
[ |
2448
|
|
|
|
|
|
|
map { $_->[-1] } |
2449
|
|
|
|
|
|
|
sort { |
2450
|
|
|
|
|
|
|
( $a->[2] <=> $b->[2] ) |
2451
|
|
|
|
|
|
|
|| |
2452
|
|
|
|
|
|
|
( defined($a->[0]) |
2453
|
|
|
|
|
|
|
? $a->[0] <=> $b->[0] || ($a->[1] cmp $b->[1]) |
2454
|
|
|
|
|
|
|
: $a->[1] cmp $b->[1] ) |
2455
|
|
|
|
|
|
|
|| |
2456
|
|
|
|
|
|
|
( $a->[-1] cmp $b->[-1] ) |
2457
|
|
|
|
|
|
|
} |
2458
|
|
|
|
|
|
|
map { |
2459
|
|
|
|
|
|
|
my $chars=lc($_); |
2460
|
|
|
|
|
|
|
my $num; |
2461
|
|
|
|
|
|
|
$num=$1 if $chars=~ |
2462
|
|
|
|
|
|
|
s/\A(-?(?:0|[1-9]\d{0,8})(?:\.\d{0,15})?)(?!\d)//; |
2463
|
|
|
|
|
|
|
$chars=~s/\W//g; |
2464
|
|
|
|
|
|
|
[ $num, $chars, !defined $num ? 2 : |
2465
|
|
|
|
|
|
|
# length($chars) ? 1 : |
2466
|
|
|
|
|
|
|
0, $_ ] |
2467
|
|
|
|
|
|
|
} keys %{$_[0]} |
2468
|
|
|
|
|
|
|
] |
2469
|
|
|
|
|
|
|
}, |
2470
|
|
|
|
|
|
|
'each'=>sub { undef }, |
2471
|
|
|
|
|
|
|
); |
2472
|
|
|
|
|
|
|
$default_key_sorters{alphabetical}=$default_key_sorters{lexical}; |
2473
|
|
|
|
|
|
|
$default_key_sorters{intelligent}=$default_key_sorters{smart}; |
2474
|
|
|
|
|
|
|
for my $h (\%default_key_sorters) { |
2475
|
|
|
|
|
|
|
my $abr=Text::Abbrev::abbrev(keys %$h); |
2476
|
|
|
|
|
|
|
foreach my $short (keys %$abr) { |
2477
|
|
|
|
|
|
|
$h->{$short}=$h->{$abr->{$short}}; |
2478
|
|
|
|
|
|
|
} |
2479
|
|
|
|
|
|
|
} |
2480
|
|
|
|
|
|
|
|
2481
|
|
|
|
|
|
|
|
2482
|
|
|
|
|
|
|
sub _get_keys { |
2483
|
1017
|
|
|
1017
|
|
1172
|
my ($self,$item,$pass,$addr,$class)=@_; |
2484
|
|
|
|
|
|
|
|
2485
|
1017
|
|
|
|
|
797
|
my $sorter; |
2486
|
1017
|
100
|
|
|
|
1640
|
$class= "" if ! defined $class; |
2487
|
|
|
|
|
|
|
|
2488
|
|
|
|
|
|
|
$sorter= $self->{style}{sortkeys}{"#$addr"} |
2489
|
1017
|
|
66
|
|
|
2780
|
|| $self->{cache_sorter}{$class}; |
2490
|
1017
|
100
|
|
|
|
1570
|
if ( ! $sorter ) { |
2491
|
|
|
|
|
|
|
$sorter= $self->{style}{sortkeys}{".$class"} |
2492
|
|
|
|
|
|
|
|| ($class && $class->can("DDS_sortkeys") ) |
2493
|
238
|
|
33
|
|
|
1313
|
|| $self->{style}{sortkeys}{"."}; |
2494
|
|
|
|
|
|
|
; |
2495
|
|
|
|
|
|
|
$self->{cache_sorter}{$class}= |
2496
|
238
|
|
66
|
|
|
1058
|
($sorter ||= $default_key_sorters{smart}); |
2497
|
|
|
|
|
|
|
} |
2498
|
1017
|
|
|
|
|
1515
|
my ($ary,$thaw)=$sorter->( $item, $pass, $addr, $class ); |
2499
|
1017
|
50
|
33
|
|
|
5420
|
die "$item:$pass:$addr:$class:$ary:$thaw" |
2500
|
|
|
|
|
|
|
if $ary and reftype($ary) ne "ARRAY"; |
2501
|
1017
|
|
|
|
|
1711
|
return ($ary,$thaw); |
2502
|
|
|
|
|
|
|
} |
2503
|
|
|
|
|
|
|
|
2504
|
|
|
|
|
|
|
|
2505
|
|
|
|
|
|
|
sub _dump_hash { |
2506
|
508
|
|
|
508
|
|
789
|
my ($self,$item,$depth,$dumped,$name,$indent,$addr,$class)=@_; |
2507
|
|
|
|
|
|
|
|
2508
|
|
|
|
|
|
|
#Carp::confess "$name" unless defined $self->{ref_hkcnt}{$addr}; |
2509
|
|
|
|
|
|
|
|
2510
|
508
|
|
|
|
|
825
|
my ($keyary)= $self->_get_keys($item,1,$addr,$class); |
2511
|
508
|
50
|
33
|
|
|
1416
|
if ($keyary and $DEBUG) { |
2512
|
0
|
|
|
|
|
0
|
warn "Keys: $keyary : @$keyary" |
2513
|
|
|
|
|
|
|
} |
2514
|
|
|
|
|
|
|
|
2515
|
508
|
|
|
|
|
738
|
my $full_indent=$self->{style}{indent}>1; |
2516
|
|
|
|
|
|
|
my $ind=($self->{style}{indent}) && |
2517
|
508
|
|
66
|
|
|
2192
|
(!defined($self->{ref_hkcnt}{$addr}) or $self->{ref_hkcnt}{$addr}>1); |
2518
|
|
|
|
|
|
|
|
2519
|
508
|
|
|
|
|
1068
|
$self->_brace($name,'{',$ind,$indent,$self->{ref_hkcnt}{$addr}) ; |
2520
|
|
|
|
|
|
|
|
2521
|
508
|
100
|
66
|
|
|
1321
|
my $indkey=($ind && $self->{style}{indentkeys}) ? $self->{ref_hklen}{$addr} : 0; |
2522
|
|
|
|
|
|
|
|
2523
|
508
|
|
|
|
|
404
|
my $cindent= $indent; |
2524
|
508
|
|
|
|
|
466
|
my $style= $self->{style}; |
2525
|
508
|
|
|
|
|
465
|
my $optspace= $style->{optspace}; |
2526
|
508
|
|
|
|
|
750
|
my $sep= $optspace . $self->{style}{hashsep} . $optspace; |
2527
|
508
|
|
|
|
|
559
|
my $pairsep= $self->{style}{pairsep}; |
2528
|
508
|
100
|
|
|
|
719
|
if ($indkey) { |
2529
|
149
|
|
|
|
|
175
|
$cindent+= $indkey + length($sep); |
2530
|
|
|
|
|
|
|
} |
2531
|
508
|
50
|
|
|
|
809
|
$DEBUG==10 and print "Indent $ind $indkey $cindent\n"; |
2532
|
508
|
|
|
|
|
565
|
my ($kc,$ix)=(0,0); |
2533
|
508
|
|
|
|
|
445
|
my $last_n=0; |
2534
|
508
|
|
|
|
|
689
|
my $ind_str=" " x $indent; |
2535
|
|
|
|
|
|
|
|
2536
|
508
|
50
|
|
|
|
1414
|
while (defined(my $k=defined $keyary ? $keyary->[$ix++] : each %$item)) { |
2537
|
1191
|
100
|
|
|
|
2054
|
$last_n=0 if ref $item->{$k}; |
2538
|
1191
|
100
|
|
|
|
1332
|
if ( $kc ) { |
2539
|
696
|
|
66
|
|
|
1651
|
my $do_ind=$ind && !$last_n ; |
2540
|
696
|
100
|
|
|
|
1794
|
$self->{fh}->print($pairsep, $do_ind ? "\n$ind_str" : $optspace); |
2541
|
696
|
|
|
|
|
616
|
$self->{buf}++; |
2542
|
696
|
100
|
33
|
|
|
791
|
if ($do_ind) { |
|
|
50
|
33
|
|
|
|
|
2543
|
686
|
|
|
|
|
653
|
$self->{buf}=0; |
2544
|
|
|
|
|
|
|
} elsif (!$do_ind && !$optspace && $self->{buf} > 1024 ) { |
2545
|
0
|
|
|
|
|
0
|
$self->{fh}->print("\n"); |
2546
|
0
|
|
|
|
|
0
|
$self->{buf}=0; |
2547
|
|
|
|
|
|
|
} |
2548
|
|
|
|
|
|
|
} else { |
2549
|
|
|
|
|
|
|
#$self->{fh}->print("\n$ind_str") if !$last_n; |
2550
|
495
|
|
|
|
|
458
|
$kc=1; |
2551
|
|
|
|
|
|
|
} |
2552
|
1191
|
100
|
|
|
|
1274
|
if ($indkey) { |
2553
|
835
|
|
|
|
|
957
|
my $qk=_quotekey($k); |
2554
|
835
|
50
|
|
|
|
1931
|
my $str=$indkey>=length($qk) |
2555
|
|
|
|
|
|
|
? join "",$qk," " x ($indkey-length($qk)), $sep |
2556
|
|
|
|
|
|
|
: join "",$qk,"\n$ind_str"," " x $indkey, $sep |
2557
|
|
|
|
|
|
|
; |
2558
|
|
|
|
|
|
|
|
2559
|
835
|
|
|
|
|
837
|
$self->{buf}+=length($str); |
2560
|
835
|
|
|
|
|
1823
|
$self->{fh}->print($str); |
2561
|
|
|
|
|
|
|
} else { |
2562
|
356
|
|
|
|
|
544
|
my $str=_quotekey($k).$sep; |
2563
|
356
|
|
|
|
|
578
|
$self->{buf}+=length($str); |
2564
|
356
|
|
|
|
|
860
|
$self->{fh}->print($str); |
2565
|
|
|
|
|
|
|
} |
2566
|
1191
|
|
|
|
|
2256
|
my $alias=$self->_dump_sv($item->{$k},$depth+1,$dumped, |
2567
|
|
|
|
|
|
|
$self->_build_name($name,'{',$k), |
2568
|
|
|
|
|
|
|
$cindent |
2569
|
|
|
|
|
|
|
); |
2570
|
1191
|
100
|
100
|
|
|
3223
|
if (!$full_indent and !$self->{do_nl} and $self->{buf}<60) { |
|
|
|
66
|
|
|
|
|
2571
|
|
|
|
|
|
|
#warn "$self->{buf}\n"; |
2572
|
6
|
|
|
|
|
7
|
$last_n++; |
2573
|
|
|
|
|
|
|
} else { |
2574
|
|
|
|
|
|
|
#warn "$self->{buf}\n"; |
2575
|
1185
|
|
|
|
|
1007
|
$last_n=0; |
2576
|
|
|
|
|
|
|
} |
2577
|
1191
|
100
|
|
|
|
3793
|
if ($alias) { |
2578
|
6
|
|
|
|
|
17
|
$self->_add_fix('sub call','alias_hv', |
2579
|
|
|
|
|
|
|
$self->_build_name($name,'%'), |
2580
|
|
|
|
|
|
|
_quote($k), |
2581
|
|
|
|
|
|
|
$alias |
2582
|
|
|
|
|
|
|
); |
2583
|
|
|
|
|
|
|
} |
2584
|
|
|
|
|
|
|
} |
2585
|
508
|
|
|
|
|
1114
|
$self->_brace($name,'}',$ind,$indent,$self->{ref_hkcnt}{$addr}); |
2586
|
|
|
|
|
|
|
return |
2587
|
508
|
|
|
|
|
986
|
} |
2588
|
|
|
|
|
|
|
|
2589
|
|
|
|
|
|
|
sub _dump_array { |
2590
|
390
|
|
|
390
|
|
491
|
my ($self,$item,$depth,$dumped,$name,$indent)=@_; |
2591
|
390
|
|
|
|
|
497
|
my $full_indent=$self->{style}{indent}>1; |
2592
|
390
|
|
100
|
|
|
1150
|
my $ind=$self->{style}{indent} && @$item>1; |
2593
|
|
|
|
|
|
|
|
2594
|
390
|
|
|
|
|
766
|
$self->_brace($name,'[',$ind,$indent,scalar @$item); |
2595
|
390
|
|
|
|
|
415
|
my $last_n=0; |
2596
|
390
|
|
|
|
|
517
|
my $ind_str=(" " x $indent); |
2597
|
390
|
|
|
|
|
376
|
my ($optspace,$sep)=@{$self->{style}}{qw(optspace arysep)}; |
|
390
|
|
|
|
|
806
|
|
2598
|
390
|
100
|
|
|
|
655
|
unless ($self->{style}{rle} ) { |
2599
|
2
|
|
|
|
|
6
|
foreach my $k (0..$#$item) { |
2600
|
18
|
|
33
|
|
|
44
|
my $do_ind=$ind && (!$last_n || ref $item->[$k]); |
2601
|
18
|
100
|
|
|
|
27
|
if ($k) { |
2602
|
16
|
50
|
|
|
|
43
|
$self->{fh}->print($sep, $do_ind ? "\n$ind_str" : $optspace); |
2603
|
16
|
50
|
0
|
|
|
21
|
if ($do_ind) { |
|
|
0
|
0
|
|
|
|
|
2604
|
16
|
|
|
|
|
18
|
$self->{buf}=0; |
2605
|
|
|
|
|
|
|
} elsif (!$do_ind && !$optspace && $self->{buf} > 1024 ) { |
2606
|
0
|
|
|
|
|
0
|
$self->{fh}->print("\n"); |
2607
|
0
|
|
|
|
|
0
|
$self->{buf}=0; |
2608
|
|
|
|
|
|
|
} |
2609
|
|
|
|
|
|
|
} |
2610
|
|
|
|
|
|
|
|
2611
|
|
|
|
|
|
|
|
2612
|
18
|
|
|
|
|
35
|
my $alias=$self->_dump_sv($item->[$k],$depth+1,$dumped, |
2613
|
|
|
|
|
|
|
$self->_build_name($name,'[',$k), |
2614
|
|
|
|
|
|
|
$indent |
2615
|
|
|
|
|
|
|
); |
2616
|
|
|
|
|
|
|
|
2617
|
18
|
50
|
33
|
|
|
55
|
if (!$full_indent and !$self->{do_nl} and $self->{buf}<60) { |
|
|
|
33
|
|
|
|
|
2618
|
|
|
|
|
|
|
#warn "$last_n\n"; |
2619
|
0
|
|
|
|
|
0
|
$last_n++; |
2620
|
|
|
|
|
|
|
} else { |
2621
|
18
|
|
|
|
|
16
|
$last_n=0; |
2622
|
|
|
|
|
|
|
} |
2623
|
18
|
50
|
|
|
|
32
|
if ($alias) { |
2624
|
0
|
|
|
|
|
0
|
$self->_add_fix('sub call','alias_av', |
2625
|
|
|
|
|
|
|
$self->_build_name($name,'@'), |
2626
|
|
|
|
|
|
|
$k, |
2627
|
|
|
|
|
|
|
$alias |
2628
|
|
|
|
|
|
|
); |
2629
|
|
|
|
|
|
|
} |
2630
|
|
|
|
|
|
|
} |
2631
|
|
|
|
|
|
|
} else { |
2632
|
|
|
|
|
|
|
# this is evil and must be changed. |
2633
|
|
|
|
|
|
|
# ... evil ... totally evil... blech |
2634
|
388
|
|
|
|
|
890
|
for ( my $k = 0 ; $k <= $#$item ; ) { |
2635
|
1043
|
|
|
|
|
1145
|
my $v = $item->[$k]; |
2636
|
1043
|
|
|
|
|
766
|
my $count = 1; |
2637
|
1043
|
100
|
100
|
|
|
4812
|
if (!refaddr($item->[$k]) and !readonly($item->[$k]) |
|
|
|
100
|
|
|
|
|
|
|
|
66
|
|
|
|
|
2638
|
|
|
|
|
|
|
and (!$self->{sv}{refaddr(\$item->[$k])} or |
2639
|
|
|
|
|
|
|
$self->{svt}[$self->{sv}{refaddr(\$item->[$k])}]==1) |
2640
|
|
|
|
|
|
|
) |
2641
|
|
|
|
|
|
|
{ |
2642
|
293
|
|
100
|
|
|
2944
|
COUNT:while ( |
|
|
|
66
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
66
|
|
|
|
|
2643
|
|
|
|
|
|
|
$k + $count <= $#$item |
2644
|
|
|
|
|
|
|
|
2645
|
|
|
|
|
|
|
and !refaddr($item->[ $k + $count ]) |
2646
|
|
|
|
|
|
|
|
2647
|
|
|
|
|
|
|
and !readonly($item->[ $k + $count ]) |
2648
|
|
|
|
|
|
|
|
2649
|
|
|
|
|
|
|
and (!$self->{sv}{refaddr(\$item->[$k + $count])} or |
2650
|
|
|
|
|
|
|
$self->{svt}[$self->{sv}{refaddr(\$item->[$k + $count])}]==1) |
2651
|
|
|
|
|
|
|
|
2652
|
|
|
|
|
|
|
and !$v == !$item->[ $k + $count ] |
2653
|
|
|
|
|
|
|
|
2654
|
|
|
|
|
|
|
and defined($v) == defined($item->[ $k + $count ]) |
2655
|
|
|
|
|
|
|
) |
2656
|
|
|
|
|
|
|
|
2657
|
|
|
|
|
|
|
{ |
2658
|
224
|
50
|
|
|
|
338
|
if (!defined( $item->[ $k + $count ] )) { |
2659
|
0
|
0
|
|
|
|
0
|
last COUNT if defined($v); |
2660
|
|
|
|
|
|
|
} else { |
2661
|
|
|
|
|
|
|
last COUNT if |
2662
|
224
|
100
|
|
|
|
496
|
$v ne overload::StrVal( $item->[ $k + $count ] ) |
2663
|
|
|
|
|
|
|
} |
2664
|
55
|
|
|
|
|
539
|
$count++; |
2665
|
|
|
|
|
|
|
} |
2666
|
|
|
|
|
|
|
} |
2667
|
|
|
|
|
|
|
|
2668
|
1043
|
|
66
|
|
|
3243
|
my $do_ind=$ind && (!$last_n || ref $item->[$k]); |
2669
|
1043
|
100
|
|
|
|
3058
|
$self->{fh}->print($sep, $do_ind ? "\n$ind_str" : $optspace) |
|
|
100
|
|
|
|
|
|
2670
|
|
|
|
|
|
|
if $k; |
2671
|
1043
|
100
|
100
|
|
|
3294
|
$self->{buf}=0 if $do_ind and $k; |
2672
|
1043
|
100
|
|
|
|
1472
|
if ($count>1){ |
2673
|
19
|
|
|
|
|
49
|
$self->{fh}->print("($optspace"); |
2674
|
19
|
|
|
|
|
23
|
$self->{buf}+=2; |
2675
|
|
|
|
|
|
|
} |
2676
|
1043
|
|
|
|
|
2009
|
my $alias=$self->_dump_sv($item->[$k],$depth+1,$dumped, |
2677
|
|
|
|
|
|
|
$self->_build_name($name,'[',$k), |
2678
|
|
|
|
|
|
|
$indent |
2679
|
|
|
|
|
|
|
); |
2680
|
1043
|
100
|
66
|
|
|
2983
|
if (!$full_indent and !$self->{do_nl} and $self->{buf}<60) { |
|
|
|
66
|
|
|
|
|
2681
|
18
|
|
|
|
|
18
|
$last_n++; |
2682
|
|
|
|
|
|
|
} else { |
2683
|
1025
|
|
|
|
|
826
|
$last_n=0; |
2684
|
|
|
|
|
|
|
} |
2685
|
1043
|
100
|
|
|
|
1413
|
if ($alias) { |
2686
|
46
|
|
|
|
|
72
|
$self->_add_fix('sub call','alias_av', |
2687
|
|
|
|
|
|
|
$self->_build_name($name,'@'), |
2688
|
|
|
|
|
|
|
$k, |
2689
|
|
|
|
|
|
|
$alias |
2690
|
|
|
|
|
|
|
); |
2691
|
|
|
|
|
|
|
} |
2692
|
1043
|
100
|
|
|
|
1474
|
if ($count>1) { |
2693
|
19
|
|
|
|
|
34
|
my $str=join $optspace,'',')','x',$count; |
2694
|
19
|
|
|
|
|
21
|
$self->{buf}+=length($str); |
2695
|
19
|
|
|
|
|
40
|
$self->{fh}->print($str); |
2696
|
|
|
|
|
|
|
} |
2697
|
1043
|
|
|
|
|
2154
|
$k += $count; |
2698
|
|
|
|
|
|
|
|
2699
|
|
|
|
|
|
|
} |
2700
|
|
|
|
|
|
|
} |
2701
|
390
|
|
|
|
|
811
|
$self->_brace($name,']',$ind,$indent,scalar @$item); |
2702
|
|
|
|
|
|
|
return |
2703
|
390
|
|
|
|
|
483
|
} |
2704
|
|
|
|
|
|
|
|
2705
|
|
|
|
|
|
|
sub __vstr { |
2706
|
0
|
|
|
0
|
|
0
|
my ($v,@v); |
2707
|
0
|
0
|
|
|
|
0
|
unless (@_) { |
|
|
0
|
|
|
|
|
|
2708
|
0
|
|
|
|
|
0
|
$v=$]; |
2709
|
|
|
|
|
|
|
} elsif (@_==1) { |
2710
|
0
|
|
|
|
|
0
|
$v=shift; |
2711
|
|
|
|
|
|
|
} else { |
2712
|
0
|
|
|
|
|
0
|
@v=@_; |
2713
|
|
|
|
|
|
|
} |
2714
|
|
|
|
|
|
|
return join ".", @v ? (@v,(0) x 3)[0..2] |
2715
|
0
|
0
|
|
|
|
0
|
: map { $v * 1000**$_ % 1000 } 0..2 |
|
0
|
|
|
|
|
0
|
|
2716
|
|
|
|
|
|
|
} |
2717
|
|
|
|
|
|
|
|
2718
|
|
|
|
|
|
|
sub _dump_code { |
2719
|
40
|
|
|
40
|
|
61
|
my ($self,$item,$name,$indent,$class)=@_; |
2720
|
40
|
50
|
|
|
|
82
|
unless ($self->{style}{deparse}) { |
2721
|
0
|
|
|
|
|
0
|
$self->{fh}->print($self->{style}{codestub}); |
2722
|
|
|
|
|
|
|
} else { #deparseopts |
2723
|
40
|
|
|
|
|
142
|
my $cv=B::svref_2object($item); |
2724
|
|
|
|
|
|
|
|
2725
|
40
|
100
|
|
|
|
220
|
if (ref($cv->ROOT)=~/NULL/) { |
2726
|
1
|
|
|
|
|
5
|
my $gv=$cv->GV; |
2727
|
1
|
|
|
|
|
36
|
$self->{fh}->print("\\&",$gv->STASH->NAME,"::",$gv->SAFENAME); |
2728
|
1
|
|
|
|
|
4
|
return; |
2729
|
|
|
|
|
|
|
} |
2730
|
|
|
|
|
|
|
|
2731
|
39
|
|
|
|
|
52
|
my $deparser=Data::Dump::Streamer::Deparser->new(@{$self->{style}{deparseopts}}); |
|
39
|
|
|
|
|
1839
|
|
2732
|
|
|
|
|
|
|
|
2733
|
39
|
|
|
|
|
85
|
my $used= _get_lexicals($item); |
2734
|
39
|
|
|
|
|
44
|
my %targ; |
2735
|
39
|
|
|
|
|
88
|
foreach my $targ (keys %$used) { |
2736
|
78
|
100
|
|
|
|
208
|
next if $targ=~/\D/; |
2737
|
39
|
|
|
|
|
76
|
my $addr=refaddr($used->{$targ}); |
2738
|
|
|
|
|
|
|
$targ{$targ}=$self->{lexicals}{a2n}{$addr} |
2739
|
39
|
50
|
|
|
|
149
|
if $self->{lexicals}{a2n}{$addr}; |
2740
|
|
|
|
|
|
|
} |
2741
|
|
|
|
|
|
|
|
2742
|
|
|
|
|
|
|
# we added this method, its not a normal method. see bottom of file. |
2743
|
39
|
|
|
|
|
145
|
$deparser->dds_usenames(\%targ); |
2744
|
|
|
|
|
|
|
|
2745
|
39
|
|
|
|
|
37
|
my $bless=undef; |
2746
|
39
|
|
|
|
|
28
|
my $code; |
2747
|
|
|
|
|
|
|
DEPARSE:{ |
2748
|
39
|
50
|
|
|
|
38
|
$bless=($class,bless($item,$bless))[0] if defined $bless; |
|
39
|
|
|
|
|
73
|
|
2749
|
39
|
|
|
|
|
48
|
eval { $code=$deparser->coderef2text($item) }; |
|
39
|
|
|
|
|
42235
|
|
2750
|
39
|
50
|
|
|
|
123
|
bless $item,$bless if defined $bless; |
2751
|
39
|
50
|
33
|
|
|
214
|
if (!defined $bless and $@ and |
|
|
50
|
33
|
|
|
|
|
2752
|
|
|
|
|
|
|
$@ =~ /^\QUsage: ->coderef2text(CODEREF)\E/) |
2753
|
|
|
|
|
|
|
{ |
2754
|
0
|
|
|
|
|
0
|
$bless='CODE'; |
2755
|
0
|
|
|
|
|
0
|
redo DEPARSE; |
2756
|
|
|
|
|
|
|
} elsif ($@) { |
2757
|
0
|
|
|
|
|
0
|
warnings::warnif "Using CODE stub for $name as ". |
2758
|
|
|
|
|
|
|
"B::Deparse->coderef2text (v$B::Deparse::VERSION". |
2759
|
0
|
|
|
|
|
0
|
" on v@{[__vstr]}) failed. Message was:\n $@"; |
2760
|
0
|
|
|
|
|
0
|
$self->{fh}->print($self->{style}{codestub}); |
2761
|
0
|
|
|
|
|
0
|
return; |
2762
|
|
|
|
|
|
|
} |
2763
|
|
|
|
|
|
|
} |
2764
|
|
|
|
|
|
|
|
2765
|
|
|
|
|
|
|
#$self->{fh}->print("\n#",join " ",keys %$used,"\n"); |
2766
|
|
|
|
|
|
|
|
2767
|
|
|
|
|
|
|
#$code=~s/^\s*(\([^)]+\)|)\s*/sub$1\n/; |
2768
|
|
|
|
|
|
|
|
2769
|
39
|
|
|
|
|
68
|
$code=~s/(\%\{)(\s*\{\}\s*)/$1;$2/g; |
2770
|
|
|
|
|
|
|
|
2771
|
39
|
50
|
|
|
|
154
|
$code="sub".($code=~/^\s*\(/ ? "" : " ").$code; |
2772
|
39
|
50
|
|
|
|
106
|
if ($self->{style}{indent}) { |
2773
|
39
|
|
|
|
|
127
|
$code=~s/\n/"\n"." " x $indent/meg; |
|
161
|
|
|
|
|
314
|
|
2774
|
|
|
|
|
|
|
} |
2775
|
|
|
|
|
|
|
#warn $name; |
2776
|
39
|
100
|
|
|
|
94
|
if ($name=~s/^\&//) { |
2777
|
4
|
|
|
|
|
30
|
$code=~s/sub(\s)?/sub $name$1/; |
2778
|
|
|
|
|
|
|
} |
2779
|
39
|
|
|
|
|
179
|
$self->{fh}->print("$code"); |
2780
|
|
|
|
|
|
|
} |
2781
|
|
|
|
|
|
|
return |
2782
|
39
|
|
|
|
|
73
|
} |
2783
|
|
|
|
|
|
|
|
2784
|
|
|
|
|
|
|
sub _dump_format { |
2785
|
|
|
|
|
|
|
# from link from [ysth]: http://groups.google.com/groups?selm=laUs8gzkgOlT092yn%40efn.org |
2786
|
|
|
|
|
|
|
# translate arg (or reference to it) into a B::* object |
2787
|
4
|
|
|
4
|
|
6
|
my ($self,$item,$name,$indent)=@_; |
2788
|
|
|
|
|
|
|
|
2789
|
|
|
|
|
|
|
|
2790
|
4
|
50
|
|
|
|
14
|
if ($self->{style}{deparse}) { |
2791
|
4
|
|
|
|
|
17
|
my $Bobj = B::svref_2object($item); |
2792
|
|
|
|
|
|
|
# if passed a glob or globref, get the format |
2793
|
4
|
50
|
|
|
|
14
|
$Bobj = B::GV::FORM($Bobj) if ref $Bobj eq 'B::GV'; |
2794
|
4
|
50
|
|
|
|
9
|
if (ref $Bobj eq 'B::FM') { |
2795
|
4
|
|
|
|
|
5
|
my $format; |
2796
|
4
|
|
|
|
|
6
|
eval { |
2797
|
4
|
|
|
|
|
64
|
my $deparser = Data::Dump::Streamer::Deparser->new(); |
2798
|
4
|
|
|
|
|
3642
|
$format=$deparser->indent($deparser->deparse_format($Bobj)); |
2799
|
|
|
|
|
|
|
}; |
2800
|
4
|
50
|
|
|
|
13
|
if ($@) { |
2801
|
0
|
|
|
|
|
0
|
warnings::warnif "B::Deparse (v$B::Deparse::VERSION on v@{[__vstr]}) failed FORMAT ref deparse.\n"; |
|
0
|
|
|
|
|
0
|
|
2802
|
0
|
|
|
|
|
0
|
$format="B::Deparse (v$B::Deparse::VERSION on v@{[__vstr]}) failed FORMAT ref deparse.\n.\n"; |
|
0
|
|
|
|
|
0
|
|
2803
|
|
|
|
|
|
|
} |
2804
|
4
|
50
|
|
|
|
18
|
my $ind=$self->{style}{indent} ? ' ' x $indent : ''; |
2805
|
4
|
|
|
|
|
9
|
$format="format F =\n$format"; |
2806
|
4
|
|
|
|
|
38
|
$format=~s/^/${ind}# /gm; |
2807
|
|
|
|
|
|
|
|
2808
|
4
|
|
|
|
|
5
|
my $end='_EOF_FORMAT_'; |
2809
|
4
|
|
0
|
|
|
41
|
$end=~s/T(\d*)_/sprintf "T%02d_",($1||0)+1/e |
|
0
|
|
|
|
|
0
|
|
2810
|
|
|
|
|
|
|
while $format=~/$end/; |
2811
|
|
|
|
|
|
|
|
2812
|
4
|
|
|
|
|
25
|
$self->{fh}->print("do{ local *F; my \$F=<<'$end'; \$F=~s/^\\s+# //mg; eval \$F; die \$F.\$@ if \$@; *F{FORMAT};\n$format\n$end\n$ind}"); |
2813
|
|
|
|
|
|
|
return |
2814
|
4
|
|
|
|
|
32
|
} |
2815
|
|
|
|
|
|
|
} |
2816
|
|
|
|
|
|
|
|
2817
|
0
|
|
|
|
|
0
|
$self->{fh}->print($self->{style}{formatstub}); |
2818
|
|
|
|
|
|
|
|
2819
|
|
|
|
|
|
|
|
2820
|
|
|
|
|
|
|
} |
2821
|
|
|
|
|
|
|
|
2822
|
|
|
|
|
|
|
sub _dump_symbol { |
2823
|
9
|
|
|
9
|
|
14
|
my ($self,$item,$name,$glob,$deref,$depth)=@_; |
2824
|
|
|
|
|
|
|
|
2825
|
9
|
|
|
|
|
10
|
my $ret="Symbol::gensym"; |
2826
|
|
|
|
|
|
|
$ret="do{ require Symbol; $ret }" |
2827
|
9
|
100
|
|
|
|
63
|
unless $self->{reqs}{Symbol}++; |
2828
|
9
|
100
|
|
|
|
18
|
$ret="*{ $ret }" |
2829
|
|
|
|
|
|
|
if $deref; |
2830
|
9
|
|
|
|
|
21
|
$self->{fh}->print( $ret ); |
2831
|
9
|
50
|
33
|
|
|
52
|
if ($self->{style}{dumpglob} and !$self->{sv_glob_du}{$glob}++) { |
2832
|
9
|
|
|
|
|
25
|
$self->_add_fix('glob',$_[1],$glob,$depth+1,$name); |
2833
|
|
|
|
|
|
|
} |
2834
|
|
|
|
|
|
|
} |
2835
|
|
|
|
|
|
|
|
2836
|
|
|
|
|
|
|
sub _dump_rv { |
2837
|
1998
|
|
|
1998
|
|
2429
|
my ($self,$item,$depth,$dumped,$name,$indent,$add_do)=@_; |
2838
|
|
|
|
|
|
|
|
2839
|
1998
|
|
|
|
|
1481
|
my ($addr,$idx,$type,$class,$is_frozen_replacement,$overloaded, |
2840
|
|
|
|
|
|
|
$raddr); |
2841
|
|
|
|
|
|
|
GETITEM: { |
2842
|
1998
|
50
|
|
|
|
1506
|
$addr=refaddr($item) or Carp::confess "$name : $item"; |
|
2003
|
|
|
|
|
3793
|
|
2843
|
2003
|
|
|
|
|
2474
|
$idx=$self->{ref}{$addr}; |
2844
|
2003
|
|
|
|
|
3051
|
$type=reftype($item); |
2845
|
2003
|
|
|
|
|
2370
|
$class=blessed($item); |
2846
|
2003
|
100
|
100
|
|
|
3879
|
$class=undef if $class and $class eq 'Regexp' and is_regexp $item; |
|
|
|
66
|
|
|
|
|
2847
|
|
|
|
|
|
|
|
2848
|
2003
|
50
|
|
|
|
2649
|
$DEBUG and |
2849
|
|
|
|
|
|
|
printf "_dump_rv %d %s %#x\n",$depth,$name,$addr; |
2850
|
|
|
|
|
|
|
|
2851
|
2003
|
|
|
|
|
1519
|
my $ignore=0; |
2852
|
2003
|
100
|
|
|
|
3164
|
if ($self->{ref_fz}{$addr}) { |
2853
|
5
|
|
|
|
|
6
|
$item= $self->{ref_fz}{$addr}; |
2854
|
5
|
50
|
|
|
|
13
|
if ( ! $item ) { |
|
|
50
|
|
|
|
|
|
2855
|
0
|
|
|
|
|
0
|
$ignore=1; |
2856
|
|
|
|
|
|
|
} elsif (ref $item) { |
2857
|
5
|
|
|
|
|
4
|
$is_frozen_replacement=1; |
2858
|
5
|
|
|
|
|
4
|
$dumped= \do{my $d}; |
|
5
|
|
|
|
|
6
|
|
2859
|
5
|
|
|
|
|
6
|
$raddr=$addr; |
2860
|
5
|
|
|
|
|
5
|
redo GETITEM; |
2861
|
|
|
|
|
|
|
} else { |
2862
|
0
|
|
|
|
|
0
|
$self->{buf}+=length($item); |
2863
|
0
|
|
|
|
|
0
|
$self->{fh}->print($item); |
2864
|
|
|
|
|
|
|
return |
2865
|
0
|
|
|
|
|
0
|
} |
2866
|
|
|
|
|
|
|
} |
2867
|
1998
|
100
|
66
|
|
|
13168
|
if ($ignore or $self->{style}{ignore}{"#".($raddr||$addr)} or |
|
|
|
33
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
33
|
|
|
|
|
2868
|
|
|
|
|
|
|
(defined $class and $self->{style}{ignore}{".$class"} ) |
2869
|
|
|
|
|
|
|
){ |
2870
|
1
|
|
|
|
|
7
|
my $str= _quote("Ignored Obj [".overload::StrVal($item)."]"); |
2871
|
1
|
|
|
|
|
2
|
$self->{buf} += length($str); |
2872
|
1
|
|
|
|
|
4
|
$self->{fh}->print($str); |
2873
|
|
|
|
|
|
|
return |
2874
|
1
|
|
|
|
|
2
|
} |
2875
|
|
|
|
|
|
|
} |
2876
|
|
|
|
|
|
|
|
2877
|
|
|
|
|
|
|
|
2878
|
1997
|
50
|
|
|
|
2615
|
unless ($idx) { |
2879
|
|
|
|
|
|
|
#Carp::confess "Unhandled address $addr $name\n"; |
2880
|
|
|
|
|
|
|
# this should only happen for localized globs. |
2881
|
0
|
|
|
|
|
0
|
($idx)=$self->_reg_ref($item,$depth,$name,refcount($item)); |
2882
|
|
|
|
|
|
|
} |
2883
|
1997
|
|
|
|
|
2101
|
my $optspace=$self->{style}{optspace}; |
2884
|
1997
|
50
|
|
|
|
2644
|
if ($idx) { |
2885
|
1997
|
|
|
|
|
2094
|
my $pre_dumped=$self->{refdu}[$idx]; |
2886
|
1997
|
|
|
|
|
1678
|
my $str=""; |
2887
|
1997
|
100
|
100
|
|
|
8431
|
if ($pre_dumped and $$pre_dumped) { |
|
|
100
|
100
|
|
|
|
|
2888
|
|
|
|
|
|
|
# its been dumped totally |
2889
|
182
|
50
|
|
|
|
306
|
$DEBUG and print " predumped $self->{refn}[$idx]\n"; |
2890
|
182
|
100
|
|
|
|
529
|
if ($self->{refn}[$idx]=~/^[\@\%\&]/) { |
2891
|
58
|
100
|
|
|
|
156
|
if (SvREADONLY_ref($item)) { |
2892
|
4
|
|
|
|
|
15
|
my @hidden_keys=sort(hidden_keys(%$item)); |
2893
|
4
|
|
|
|
|
10
|
$self->_add_fix('lock',$idx,\@hidden_keys); |
2894
|
|
|
|
|
|
|
} |
2895
|
|
|
|
|
|
|
$str=join "",($class ? "bless($optspace" : ''), |
2896
|
58
|
100
|
|
|
|
275
|
'\\'.$self->{refn}[$idx], |
|
|
100
|
|
|
|
|
|
2897
|
|
|
|
|
|
|
($class ? ",$optspace"._quote($class)."$optspace)" : ''); |
2898
|
|
|
|
|
|
|
} else { |
2899
|
124
|
|
|
|
|
159
|
$str=$self->{refn}[$idx]; |
2900
|
|
|
|
|
|
|
} |
2901
|
182
|
|
|
|
|
261
|
$self->{buf}+=length($str); |
2902
|
182
|
|
|
|
|
512
|
$self->{fh}->print($str); |
2903
|
|
|
|
|
|
|
return |
2904
|
182
|
|
|
|
|
271
|
} elsif ($pre_dumped or $self->{refd}[$idx] < $depth) { |
2905
|
301
|
50
|
|
|
|
472
|
$DEBUG and print " inprocess or depth violation: $self->{refd}[$idx] < $depth\n"; |
2906
|
|
|
|
|
|
|
# we are in the process of dumping it |
2907
|
|
|
|
|
|
|
# output a place holder and add a fix statement |
2908
|
|
|
|
|
|
|
# XXX is this sigil test correct? why not $? |
2909
|
301
|
100
|
100
|
|
|
1057
|
if ($self->{refn}[$idx]=~/^[\@\%\&]/ and (!$self->{style}{declare})) { |
2910
|
|
|
|
|
|
|
$str=join"",( $class ? "bless($optspace" : '' ), |
2911
|
38
|
100
|
|
|
|
151
|
'\\'.$self->{refn}[$idx], |
|
|
100
|
|
|
|
|
|
2912
|
|
|
|
|
|
|
( $class ? ",$optspace"._quote($class)."$optspace)" : '' ); |
2913
|
|
|
|
|
|
|
} else { |
2914
|
263
|
100
|
|
|
|
405
|
if ($self->{style}{purity}) { |
2915
|
|
|
|
|
|
|
$str=join"",$add_do ? join($optspace,qw(do { my $v = ),'') : '', |
2916
|
258
|
100
|
|
|
|
841
|
!$self->{style}{verbose} ? "'V'" : _quote("V: ",$self->{refn}[$idx]), |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
2917
|
|
|
|
|
|
|
$add_do ? $optspace."}" : ''; |
2918
|
|
|
|
|
|
|
|
2919
|
|
|
|
|
|
|
#Carp::cluck "$name $self->{refd}[$idx] < $depth" if $name=~/\*/; |
2920
|
258
|
|
|
|
|
574
|
$self->_add_fix('ref',$name,$idx,$class); |
2921
|
|
|
|
|
|
|
} else { |
2922
|
5
|
|
|
|
|
6
|
$str=$self->{refn}[$idx]; |
2923
|
|
|
|
|
|
|
} |
2924
|
|
|
|
|
|
|
} |
2925
|
301
|
|
|
|
|
416
|
$self->{buf}+=length($str); |
2926
|
301
|
|
|
|
|
784
|
$self->{fh}->print($str); |
2927
|
|
|
|
|
|
|
return |
2928
|
301
|
|
|
|
|
434
|
} |
2929
|
1514
|
|
33
|
|
|
4486
|
$self->{refdu}[$idx]||=$dumped; |
2930
|
|
|
|
|
|
|
#$name=$self->{refn}[$idx]; # override inherited names. ??? maybe not needed |
2931
|
|
|
|
|
|
|
} else { |
2932
|
0
|
|
|
|
|
0
|
Carp::confess "Unhandled object '$item'\n"; |
2933
|
|
|
|
|
|
|
} |
2934
|
1514
|
|
|
|
|
1240
|
my $isoverloaded=0; |
2935
|
1514
|
100
|
100
|
|
|
2826
|
if (defined $class and overload::Overloaded($item)) { |
2936
|
26
|
|
|
|
|
542
|
disable_overloading( $item ); |
2937
|
26
|
|
|
|
|
18
|
$overloaded= $class; |
2938
|
26
|
|
|
|
|
27
|
$isoverloaded= 1; |
2939
|
|
|
|
|
|
|
} |
2940
|
1514
|
|
66
|
|
|
7475
|
my $thaw= $self->{ref_thaw}{$raddr||$addr}; |
2941
|
1514
|
|
|
|
|
1273
|
my ($inline,$thawtype); |
2942
|
1514
|
100
|
|
|
|
2100
|
if ( $thaw ) { |
2943
|
4
|
50
|
|
|
|
10
|
if ($thaw =~ /[^\w:>()-]/) { |
2944
|
0
|
|
|
|
|
0
|
$thawtype= "code"; |
2945
|
|
|
|
|
|
|
} else{ |
2946
|
4
|
|
|
|
|
10
|
$inline= $thaw=~s/^->//; |
2947
|
4
|
100
|
|
|
|
12
|
$thawtype= $thaw=~s/\(\)$// ? "sub" : "method"; |
2948
|
|
|
|
|
|
|
} |
2949
|
4
|
50
|
66
|
|
|
14
|
if ($inline && $thawtype eq 'sub') { |
2950
|
0
|
|
|
|
|
0
|
$self->{buf}+=length($thaw)+1; |
2951
|
0
|
|
|
|
|
0
|
$self->{fh}->print($thaw."(${optspace}"); |
2952
|
|
|
|
|
|
|
} |
2953
|
|
|
|
|
|
|
} |
2954
|
1514
|
|
|
|
|
1347
|
$self->{do_nl}=1; |
2955
|
1514
|
|
100
|
|
|
3366
|
my $add_lock=($type eq 'HASH') && SvREADONLY_ref($item); |
2956
|
1514
|
|
|
|
|
1110
|
my $fix_lock=0; |
2957
|
1514
|
100
|
|
|
|
2473
|
my @hidden_keys=$add_lock ? sort(hidden_keys(%$item)) : (); |
2958
|
1514
|
100
|
|
|
|
2090
|
if ($add_lock) { |
2959
|
|
|
|
|
|
|
#warn "$name\n"; |
2960
|
38
|
100
|
|
|
|
90
|
if ($name!~/^\$/) { |
2961
|
8
|
|
|
|
|
9
|
$fix_lock=1; |
2962
|
8
|
|
|
|
|
9
|
$add_lock=0; |
2963
|
|
|
|
|
|
|
} else { |
2964
|
30
|
100
|
|
|
|
118
|
$self->{fh}->print("lock_ref_keys", |
2965
|
|
|
|
|
|
|
@hidden_keys ? '_plus' : '', |
2966
|
|
|
|
|
|
|
"(${optspace}" |
2967
|
|
|
|
|
|
|
); |
2968
|
|
|
|
|
|
|
} |
2969
|
|
|
|
|
|
|
} |
2970
|
|
|
|
|
|
|
|
2971
|
|
|
|
|
|
|
|
2972
|
1514
|
|
100
|
|
|
2618
|
my $add_bless=defined($class) && ($name!~/^[\@\%\&]/); |
2973
|
1514
|
100
|
100
|
|
|
2581
|
if ($add_bless && !$overloaded) { |
2974
|
84
|
|
|
|
|
318
|
$self->{fh}->print(substr($self->{style}{bless},0,-1),$optspace); |
2975
|
|
|
|
|
|
|
} |
2976
|
|
|
|
|
|
|
|
2977
|
1514
|
50
|
|
|
|
2340
|
$DEBUG and print " $type : Start typecheck\n"; |
2978
|
1514
|
100
|
100
|
|
|
7344
|
if ($type eq 'SCALAR' or $type eq 'REF' or $type eq 'GLOB') { |
|
|
100
|
100
|
|
|
|
|
|
|
100
|
33
|
|
|
|
|
|
|
100
|
33
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
2979
|
521
|
100
|
|
|
|
962
|
my ($pat,$mod)=$type eq 'SCALAR' ? regex($item) : (); |
2980
|
521
|
100
|
|
|
|
804
|
my $glob=$type eq 'GLOB' ? globname $$item : ''; |
2981
|
521
|
100
|
|
|
|
966
|
if ($glob=~/^\*Symbol::GEN/) { |
|
|
50
|
|
|
|
|
|
2982
|
8
|
|
|
|
|
22
|
$self->_dump_symbol($_[1],$name,$glob,0,$depth); |
2983
|
|
|
|
|
|
|
} elsif (defined $pat) { |
2984
|
|
|
|
|
|
|
# its a regex |
2985
|
0
|
|
|
|
|
0
|
$self->_dump_qr($pat,$mod); |
2986
|
|
|
|
|
|
|
} else { |
2987
|
513
|
|
|
|
|
978
|
my $ret=$self->_dump_sv($$item,$depth+1,$dumped, |
2988
|
|
|
|
|
|
|
$self->_build_name($name,'$'), |
2989
|
|
|
|
|
|
|
$indent,'is_ref' |
2990
|
|
|
|
|
|
|
); |
2991
|
513
|
100
|
|
|
|
1038
|
$self->{refdu}[$idx]=$ret if $ret; |
2992
|
|
|
|
|
|
|
} |
2993
|
|
|
|
|
|
|
} elsif ($type eq 'ARRAY') { |
2994
|
390
|
|
|
|
|
892
|
$self->_dump_array($item,$depth,$dumped,$name,$indent); |
2995
|
|
|
|
|
|
|
} elsif ($type eq 'HASH') { |
2996
|
508
|
|
|
|
|
1036
|
$self->_dump_hash($item,$depth,$dumped,$name,$indent,$addr,$class); |
2997
|
|
|
|
|
|
|
} elsif ($type eq 'CODE') { |
2998
|
40
|
|
|
|
|
97
|
$self->_dump_code($item,$name,$indent,$class); |
2999
|
|
|
|
|
|
|
} elsif ($type eq 'FORMAT') { |
3000
|
|
|
|
|
|
|
#$self->_dump_code($item,$name,$indent,$class); #muwhahahah |
3001
|
4
|
|
|
|
|
16
|
$self->_dump_format($item,$name,$indent); |
3002
|
|
|
|
|
|
|
} elsif ($type eq 'IO') { |
3003
|
2
|
|
|
|
|
6
|
$self->{fh}->print("*{Symbol::gensym()}{IO}"); |
3004
|
|
|
|
|
|
|
} elsif ($type eq 'ORANGE' || $type eq 'Regexp' || $type eq 'REGEXP') { |
3005
|
49
|
|
|
|
|
150
|
my ($pat,$mod)=regex($item); |
3006
|
49
|
|
|
|
|
111
|
$self->_dump_qr($pat,$mod); |
3007
|
|
|
|
|
|
|
} else { |
3008
|
0
|
|
|
|
|
0
|
Carp::confess "_dump_rv() can't handle '$type' objects yet\n :-(\n"; |
3009
|
|
|
|
|
|
|
} |
3010
|
1514
|
100
|
|
|
|
2196
|
if ($add_bless) { |
3011
|
110
|
100
|
|
|
|
176
|
unless ( defined $overloaded ) { |
3012
|
84
|
|
|
|
|
185
|
$self->{fh}->print(",${optspace}",_quote($class),$optspace,substr($self->{style}{bless},-1)) |
3013
|
|
|
|
|
|
|
} else { |
3014
|
26
|
|
|
|
|
40
|
$self->_add_fix('bless',$idx,$overloaded); |
3015
|
|
|
|
|
|
|
} |
3016
|
110
|
100
|
|
|
|
226
|
if ($isoverloaded) { |
3017
|
26
|
|
|
|
|
34
|
restore_overloading( $item, $overloaded ); |
3018
|
|
|
|
|
|
|
} |
3019
|
|
|
|
|
|
|
} |
3020
|
1514
|
100
|
100
|
|
|
2401
|
if ($fix_lock && !defined($class)) { |
3021
|
4
|
|
|
|
|
11
|
$self->_add_fix('lock',$idx,\@hidden_keys); |
3022
|
|
|
|
|
|
|
} |
3023
|
1514
|
100
|
|
|
|
1973
|
if ($add_lock) { |
3024
|
30
|
100
|
|
|
|
44
|
if (@hidden_keys) { |
3025
|
26
|
|
|
|
|
50
|
$self->{fh}->print(",${optspace}",join(",${optspace}",map {_quote($_)} @hidden_keys)); |
|
46
|
|
|
|
|
53
|
|
3026
|
|
|
|
|
|
|
} |
3027
|
30
|
|
|
|
|
84
|
$self->{fh}->print("${optspace})"); |
3028
|
|
|
|
|
|
|
} |
3029
|
1514
|
100
|
|
|
|
1949
|
if ( $thaw ) { |
3030
|
4
|
100
|
|
|
|
6
|
if ($inline) { |
3031
|
1
|
50
|
|
|
|
6
|
if ($thawtype eq 'sub') { |
|
|
50
|
|
|
|
|
|
3032
|
0
|
|
|
|
|
0
|
$self->{fh}->print("${optspace})"); |
3033
|
|
|
|
|
|
|
} elsif ($thawtype eq 'method') { |
3034
|
1
|
|
|
|
|
4
|
$self->{fh}->print("->$thaw()"); |
3035
|
|
|
|
|
|
|
} |
3036
|
|
|
|
|
|
|
#$$dumped=1; |
3037
|
|
|
|
|
|
|
} else { |
3038
|
3
|
100
|
|
|
|
11
|
$self->_add_fix('thaw', $idx, $thaw.($thawtype eq 'sub' ? "()" :"" )); |
3039
|
|
|
|
|
|
|
} |
3040
|
|
|
|
|
|
|
} |
3041
|
1514
|
50
|
66
|
|
|
5329
|
if ( my $postop=$self->{ref_postop}{$raddr||$addr} ) { |
3042
|
0
|
0
|
|
|
|
0
|
if (ref $postop) { |
3043
|
0
|
|
|
|
|
0
|
$postop->($_[1]); |
3044
|
|
|
|
|
|
|
} else { |
3045
|
0
|
|
|
|
|
0
|
$_[1]->$postop(); |
3046
|
|
|
|
|
|
|
} |
3047
|
|
|
|
|
|
|
} |
3048
|
1514
|
|
|
|
|
1343
|
$self->{do_nl}=1; |
3049
|
|
|
|
|
|
|
|
3050
|
|
|
|
|
|
|
return |
3051
|
1514
|
|
|
|
|
2163
|
} |
3052
|
|
|
|
|
|
|
|
3053
|
|
|
|
|
|
|
=item Names |
3054
|
|
|
|
|
|
|
|
3055
|
|
|
|
|
|
|
=item Names LIST |
3056
|
|
|
|
|
|
|
|
3057
|
|
|
|
|
|
|
=item Names ARRAYREF |
3058
|
|
|
|
|
|
|
|
3059
|
|
|
|
|
|
|
Takes a list of strings or a reference to an array of strings to use for |
3060
|
|
|
|
|
|
|
var names for the objects dumped. The names may be prefixed by a * |
3061
|
|
|
|
|
|
|
indicating the variable is to be dumped as its dereferenced type if it is |
3062
|
|
|
|
|
|
|
an array, hash or code ref. Otherwise the star is ignored. Other sigils |
3063
|
|
|
|
|
|
|
may be prefixed but they will be silently converted to *'s. |
3064
|
|
|
|
|
|
|
|
3065
|
|
|
|
|
|
|
If no names are provided then names are generated automatically based on |
3066
|
|
|
|
|
|
|
the type of object being dumped, with abbreviations applied to compound |
3067
|
|
|
|
|
|
|
class names. |
3068
|
|
|
|
|
|
|
|
3069
|
|
|
|
|
|
|
If called with arguments then returns the object itself, otherwise in list |
3070
|
|
|
|
|
|
|
context returns the list of names in use, or in scalar context a reference |
3071
|
|
|
|
|
|
|
or undef. In void context with no arguments the names are cleared. |
3072
|
|
|
|
|
|
|
|
3073
|
|
|
|
|
|
|
B |
3074
|
|
|
|
|
|
|
Must be called before C is called. |
3075
|
|
|
|
|
|
|
|
3076
|
|
|
|
|
|
|
=cut |
3077
|
|
|
|
|
|
|
|
3078
|
|
|
|
|
|
|
sub Names { |
3079
|
65
|
|
|
65
|
1
|
10282
|
my $self = shift->_safe_self; |
3080
|
65
|
100
|
|
|
|
171
|
if (@_) { |
|
|
100
|
|
|
|
|
|
3081
|
60
|
50
|
66
|
|
|
289
|
my $v=(@_==1 and reftype $_[0] eq 'ARRAY') ? shift @_ : \@_; |
3082
|
|
|
|
|
|
|
$self->{unames} = [ |
3083
|
|
|
|
|
|
|
map { |
3084
|
133
|
|
|
|
|
410
|
( my $s = $_ ) =~ s/^[\@\%\&-]/*/; |
3085
|
133
|
|
|
|
|
164
|
$s=~s/^\$//; |
3086
|
133
|
50
|
33
|
|
|
713
|
Carp::confess "Bad name '$_'" |
3087
|
|
|
|
|
|
|
if $s && $s!~/^\*?\w+$/; |
3088
|
133
|
|
|
|
|
309
|
$s |
3089
|
60
|
|
|
|
|
152
|
} grep {defined} @$v ]; |
|
133
|
|
|
|
|
189
|
|
3090
|
60
|
|
|
|
|
376
|
return $self; |
3091
|
|
|
|
|
|
|
} elsif (! defined wantarray ) { |
3092
|
3
|
|
|
|
|
9
|
$self->{unames}=[]; |
3093
|
|
|
|
|
|
|
} |
3094
|
|
|
|
|
|
|
#elsif ( eval { require PadWalker; 1 } ) { |
3095
|
|
|
|
|
|
|
# print DDumper(PadWalker::peek_my(1)); |
3096
|
|
|
|
|
|
|
# return $self; |
3097
|
|
|
|
|
|
|
#} |
3098
|
|
|
|
|
|
|
|
3099
|
1
|
50
|
|
|
|
15
|
return wantarray ? @{$self->{unames}||[]} : $self->{unames} |
3100
|
5
|
100
|
|
|
|
17
|
} |
3101
|
|
|
|
|
|
|
|
3102
|
|
|
|
|
|
|
=for UEDIT |
3103
|
|
|
|
|
|
|
sub Purity {} |
3104
|
|
|
|
|
|
|
|
3105
|
|
|
|
|
|
|
=item Purity |
3106
|
|
|
|
|
|
|
|
3107
|
|
|
|
|
|
|
=item Purity BOOL |
3108
|
|
|
|
|
|
|
|
3109
|
|
|
|
|
|
|
This option can be used to set the level of purity in the output. It |
3110
|
|
|
|
|
|
|
defaults to TRUE, which results in the module doing its best to ensure |
3111
|
|
|
|
|
|
|
that the resulting dump when eval()ed is precisely the same as the input. |
3112
|
|
|
|
|
|
|
However, at times such as debugging this can be tedious, resulting in |
3113
|
|
|
|
|
|
|
extremely long dumps with many "fix" statements involved. By setting |
3114
|
|
|
|
|
|
|
Purity to FALSE the resulting output won't necessarily be legal Perl, but |
3115
|
|
|
|
|
|
|
it will be more legible. In this mode the output is broadly similar to |
3116
|
|
|
|
|
|
|
that of the default setting of Data::Dumper (Purity(0)). When set to TRUE |
3117
|
|
|
|
|
|
|
the behaviour is likewise similar to Data::Dumper in Purity(1) but more |
3118
|
|
|
|
|
|
|
accurate. |
3119
|
|
|
|
|
|
|
|
3120
|
|
|
|
|
|
|
When Purity() is set to FALSE aliases will be output with a function call |
3121
|
|
|
|
|
|
|
wrapper of 'alias_to' whose argument will be the value the item is an |
3122
|
|
|
|
|
|
|
alias to. This wrapper does nothing, and is only there as a visual cue. |
3123
|
|
|
|
|
|
|
Likewise, 'make_ro' will be output when the value was readonly, and again |
3124
|
|
|
|
|
|
|
the effect is cosmetic only. |
3125
|
|
|
|
|
|
|
|
3126
|
|
|
|
|
|
|
=item To |
3127
|
|
|
|
|
|
|
|
3128
|
|
|
|
|
|
|
=item To STREAMER |
3129
|
|
|
|
|
|
|
|
3130
|
|
|
|
|
|
|
Specifies the object to print to. Data::Dump::Streamer can stream its |
3131
|
|
|
|
|
|
|
output to any object supporting the print method. This is primarily meant |
3132
|
|
|
|
|
|
|
for streaming to a filehandle, however any object that supports the method |
3133
|
|
|
|
|
|
|
will do. |
3134
|
|
|
|
|
|
|
|
3135
|
|
|
|
|
|
|
If a filehandle is specified then it is used until it is explicitly |
3136
|
|
|
|
|
|
|
changed, or the object is destroyed. |
3137
|
|
|
|
|
|
|
|
3138
|
|
|
|
|
|
|
=cut |
3139
|
|
|
|
|
|
|
|
3140
|
|
|
|
|
|
|
sub To { |
3141
|
0
|
|
|
0
|
1
|
0
|
my $self = shift->_safe_self; |
3142
|
0
|
0
|
|
|
|
0
|
if (@_) { |
3143
|
0
|
|
|
|
|
0
|
$self->{fh} = shift; |
3144
|
0
|
|
|
|
|
0
|
return $self; |
3145
|
|
|
|
|
|
|
} |
3146
|
0
|
|
|
|
|
0
|
return $self->{fh}; |
3147
|
|
|
|
|
|
|
} |
3148
|
|
|
|
|
|
|
|
3149
|
|
|
|
|
|
|
=for UEDIT |
3150
|
|
|
|
|
|
|
sub Declare {} |
3151
|
|
|
|
|
|
|
|
3152
|
|
|
|
|
|
|
=item Declare |
3153
|
|
|
|
|
|
|
|
3154
|
|
|
|
|
|
|
=item Declare BOOL |
3155
|
|
|
|
|
|
|
|
3156
|
|
|
|
|
|
|
If Declare is True then each object is dumped with 'my' declarations |
3157
|
|
|
|
|
|
|
included, and all rules that follow are obeyed. (Ie, not referencing an |
3158
|
|
|
|
|
|
|
undeclared variable). If Declare is False then all objects are expected to |
3159
|
|
|
|
|
|
|
be previously defined and references to top level objects can be made at |
3160
|
|
|
|
|
|
|
any time. |
3161
|
|
|
|
|
|
|
|
3162
|
|
|
|
|
|
|
Defaults to False. |
3163
|
|
|
|
|
|
|
|
3164
|
|
|
|
|
|
|
=cut |
3165
|
|
|
|
|
|
|
|
3166
|
|
|
|
|
|
|
sub Indent { |
3167
|
8
|
|
|
8
|
1
|
413
|
my $self=shift->_safe_self(); |
3168
|
8
|
50
|
|
|
|
19
|
if (@_) { |
3169
|
8
|
|
|
|
|
10
|
my $val=shift; |
3170
|
|
|
|
|
|
|
|
3171
|
8
|
100
|
66
|
|
|
61
|
if ( $val == 0 && length $self->{style}{optspace} ) { |
|
|
100
|
66
|
|
|
|
|
3172
|
3
|
|
|
|
|
8
|
$self->{style}{last_optspace}= $self->{style}{optspace}; |
3173
|
3
|
|
|
|
|
5
|
$self->{style}{optspace}= ""; |
3174
|
|
|
|
|
|
|
} elsif( !$self->{style}{indent} && ! length $self->{style}{optspace} ) |
3175
|
|
|
|
|
|
|
{ |
3176
|
2
|
|
|
|
|
4
|
$self->{style}{optspace}= $self->{style}{last_optspace}; |
3177
|
|
|
|
|
|
|
} |
3178
|
8
|
|
|
|
|
10
|
$self->{style}{indent}= $val; |
3179
|
8
|
|
|
|
|
121
|
return $self |
3180
|
|
|
|
|
|
|
} else { |
3181
|
|
|
|
|
|
|
return $self->{style}{indent} |
3182
|
0
|
|
|
|
|
0
|
} |
3183
|
|
|
|
|
|
|
} |
3184
|
|
|
|
|
|
|
|
3185
|
|
|
|
|
|
|
=item Indent |
3186
|
|
|
|
|
|
|
|
3187
|
|
|
|
|
|
|
=item Indent INT |
3188
|
|
|
|
|
|
|
|
3189
|
|
|
|
|
|
|
If Indent is True then data is output in an indented and fairly neat |
3190
|
|
|
|
|
|
|
fashion. If the value is 2 then hash key/value pairs and array values each |
3191
|
|
|
|
|
|
|
on their own line. If the value is 1 then a "smart" indenting mode is |
3192
|
|
|
|
|
|
|
activated where multiple key/value or values may be printed to the same |
3193
|
|
|
|
|
|
|
line. The heuristics for this mode are still experimental so it may |
3194
|
|
|
|
|
|
|
occasional not indent very nicely. |
3195
|
|
|
|
|
|
|
|
3196
|
|
|
|
|
|
|
Default is Indent(2) |
3197
|
|
|
|
|
|
|
|
3198
|
|
|
|
|
|
|
If indent is False then no indentation is done, and all optional whitespace. |
3199
|
|
|
|
|
|
|
is omitted. See for more details. |
3200
|
|
|
|
|
|
|
|
3201
|
|
|
|
|
|
|
Defaults to True. |
3202
|
|
|
|
|
|
|
|
3203
|
|
|
|
|
|
|
Newlines are appended to each statement regardless of this value. |
3204
|
|
|
|
|
|
|
|
3205
|
|
|
|
|
|
|
=for UEDIT |
3206
|
|
|
|
|
|
|
sub IndentKeys {} |
3207
|
|
|
|
|
|
|
|
3208
|
|
|
|
|
|
|
=item Indentkeys |
3209
|
|
|
|
|
|
|
|
3210
|
|
|
|
|
|
|
=item Indentkeys BOOL |
3211
|
|
|
|
|
|
|
|
3212
|
|
|
|
|
|
|
If Indent() and Indentkeys are True then hashes with more than one key |
3213
|
|
|
|
|
|
|
value pair are dumped such that the keys and values line up. Note however |
3214
|
|
|
|
|
|
|
this means each key has to be quoted twice. Not advised for very large |
3215
|
|
|
|
|
|
|
data structures. Additional logic may enhance this feature soon. |
3216
|
|
|
|
|
|
|
|
3217
|
|
|
|
|
|
|
Defaults to True. |
3218
|
|
|
|
|
|
|
|
3219
|
|
|
|
|
|
|
B |
3220
|
|
|
|
|
|
|
Must be set before C is called. |
3221
|
|
|
|
|
|
|
|
3222
|
|
|
|
|
|
|
=for UEDIT |
3223
|
|
|
|
|
|
|
sub OptSpace {} |
3224
|
|
|
|
|
|
|
|
3225
|
|
|
|
|
|
|
=item OptSpace |
3226
|
|
|
|
|
|
|
|
3227
|
|
|
|
|
|
|
=item OptSpace STR |
3228
|
|
|
|
|
|
|
|
3229
|
|
|
|
|
|
|
Normally DDS emits a lot of whitespace in between tokens that it |
3230
|
|
|
|
|
|
|
emits. Using this method you can control how much whitespace it |
3231
|
|
|
|
|
|
|
will emit, or even if some other string should be used. |
3232
|
|
|
|
|
|
|
|
3233
|
|
|
|
|
|
|
If Indent is set to 0 then this value is automatically set to |
3234
|
|
|
|
|
|
|
the empty string. When Indent is set back to a non zero value |
3235
|
|
|
|
|
|
|
the old value will be restored if it has not been changed from |
3236
|
|
|
|
|
|
|
the empty string in the intervening time. |
3237
|
|
|
|
|
|
|
|
3238
|
|
|
|
|
|
|
=for UEDIT |
3239
|
|
|
|
|
|
|
sub Keyorder {} |
3240
|
|
|
|
|
|
|
|
3241
|
|
|
|
|
|
|
=item KeyOrder TYPE_OR_OBJ |
3242
|
|
|
|
|
|
|
|
3243
|
|
|
|
|
|
|
=item KeyOrder TYPE_OR_OBJ, VALUE |
3244
|
|
|
|
|
|
|
|
3245
|
|
|
|
|
|
|
Sets or returns the key order to for use for a given type or object. |
3246
|
|
|
|
|
|
|
|
3247
|
|
|
|
|
|
|
TYPE_OR_OBJ may be a string representing a class, or "" for representing |
3248
|
|
|
|
|
|
|
unblessed objects, or it maybe a reference to a hash. |
3249
|
|
|
|
|
|
|
|
3250
|
|
|
|
|
|
|
VALUE may be a string representing one of built in sort mechanisms, or |
3251
|
|
|
|
|
|
|
it may be a reference to a subroutine, or a method name if TYPE_OR_OBJ |
3252
|
|
|
|
|
|
|
is not an object. |
3253
|
|
|
|
|
|
|
|
3254
|
|
|
|
|
|
|
The built in sort mechanisms are 'aphabetical'/'lexical', 'numeric', |
3255
|
|
|
|
|
|
|
'smart'/'intelligent' and 'each'. |
3256
|
|
|
|
|
|
|
|
3257
|
|
|
|
|
|
|
If VALUE is omitted returns the current value for the given type. |
3258
|
|
|
|
|
|
|
|
3259
|
|
|
|
|
|
|
If TYPE_OR_OBJ is omitted or FALSE it defaults to "" which represents |
3260
|
|
|
|
|
|
|
unblessed hashes. |
3261
|
|
|
|
|
|
|
|
3262
|
|
|
|
|
|
|
See L<"Controlling Hash Traversal and Display Order"> for more details. |
3263
|
|
|
|
|
|
|
|
3264
|
|
|
|
|
|
|
=item SortKeys |
3265
|
|
|
|
|
|
|
|
3266
|
|
|
|
|
|
|
=item SortKeys VALUE |
3267
|
|
|
|
|
|
|
|
3268
|
|
|
|
|
|
|
This is a wrapper for KeyOrder. It allows only the generic hash |
3269
|
|
|
|
|
|
|
sort order to be specified a little more elegantly than via KeyOrder(). |
3270
|
|
|
|
|
|
|
It is syntactically equivalent to |
3271
|
|
|
|
|
|
|
|
3272
|
|
|
|
|
|
|
$self->KeyOrder( "", @_ ); |
3273
|
|
|
|
|
|
|
|
3274
|
|
|
|
|
|
|
=for UEDIT |
3275
|
|
|
|
|
|
|
sub Verbose {} |
3276
|
|
|
|
|
|
|
|
3277
|
|
|
|
|
|
|
=item Verbose |
3278
|
|
|
|
|
|
|
|
3279
|
|
|
|
|
|
|
=item Verbose BOOL |
3280
|
|
|
|
|
|
|
|
3281
|
|
|
|
|
|
|
If Verbose is True then when references that cannot be resolved in a |
3282
|
|
|
|
|
|
|
single statement are encountered the reference is substituted for a |
3283
|
|
|
|
|
|
|
descriptive tag saying what type of forward reference it is, and to what |
3284
|
|
|
|
|
|
|
is being referenced. The type is provided through a prefix, "R:" for |
3285
|
|
|
|
|
|
|
reference, and "A:" for alias, "V:" for a value and then the name of the |
3286
|
|
|
|
|
|
|
var in a string. Automatically generated var names are also reduced to |
3287
|
|
|
|
|
|
|
the shortest possible unique abbreviation, with some tricks thrown in |
3288
|
|
|
|
|
|
|
for Long::Class::Names::Like::This (which would abbreviate most likely |
3289
|
|
|
|
|
|
|
to LCNLT1) |
3290
|
|
|
|
|
|
|
|
3291
|
|
|
|
|
|
|
If Verbose if False then a simple placeholder saying 'A' or 'R' is |
3292
|
|
|
|
|
|
|
provided. (In most situations perl requires a placeholder, and as such |
3293
|
|
|
|
|
|
|
one is always provided, even if technically it could be omitted.) |
3294
|
|
|
|
|
|
|
|
3295
|
|
|
|
|
|
|
This setting does not change the followup statements that fix up the |
3296
|
|
|
|
|
|
|
structure, and does not result in a loss of accuracy, it just makes it a |
3297
|
|
|
|
|
|
|
little harder to read. OTOH, it means dumps can be quite a bit smaller |
3298
|
|
|
|
|
|
|
and less noisy. |
3299
|
|
|
|
|
|
|
|
3300
|
|
|
|
|
|
|
Defaults to True. |
3301
|
|
|
|
|
|
|
|
3302
|
|
|
|
|
|
|
B |
3303
|
|
|
|
|
|
|
Must be set before C is called. |
3304
|
|
|
|
|
|
|
|
3305
|
|
|
|
|
|
|
=for UEDIT |
3306
|
|
|
|
|
|
|
sub DumpGlob {} |
3307
|
|
|
|
|
|
|
|
3308
|
|
|
|
|
|
|
=item DumpGlob |
3309
|
|
|
|
|
|
|
|
3310
|
|
|
|
|
|
|
=item DumpGlob BOOL |
3311
|
|
|
|
|
|
|
|
3312
|
|
|
|
|
|
|
If True then globs will be followed and fully defined, otherwise the globs |
3313
|
|
|
|
|
|
|
will still be referenced but their current value will not be set. |
3314
|
|
|
|
|
|
|
|
3315
|
|
|
|
|
|
|
Defaults to True |
3316
|
|
|
|
|
|
|
|
3317
|
|
|
|
|
|
|
B |
3318
|
|
|
|
|
|
|
Must be set before C is called. |
3319
|
|
|
|
|
|
|
|
3320
|
|
|
|
|
|
|
=for UEDIT |
3321
|
|
|
|
|
|
|
sub Deparse {} |
3322
|
|
|
|
|
|
|
|
3323
|
|
|
|
|
|
|
=item Deparse |
3324
|
|
|
|
|
|
|
|
3325
|
|
|
|
|
|
|
=item Deparse BOOL |
3326
|
|
|
|
|
|
|
|
3327
|
|
|
|
|
|
|
If True then CODE refs will be deparsed use L and |
3328
|
|
|
|
|
|
|
included in the dump. If it is False the a stub subroutine reference will |
3329
|
|
|
|
|
|
|
be output as per the setting of C. |
3330
|
|
|
|
|
|
|
|
3331
|
|
|
|
|
|
|
Caveat Emptor, dumping subroutine references is hardly a secure act, and |
3332
|
|
|
|
|
|
|
it is provided here only for convenience. |
3333
|
|
|
|
|
|
|
|
3334
|
|
|
|
|
|
|
Note using this routine is at your own risk as of DDS 1.11, how it |
3335
|
|
|
|
|
|
|
interacts with the newer advanced closure dumping process is undefined. |
3336
|
|
|
|
|
|
|
|
3337
|
|
|
|
|
|
|
=for UEDIT |
3338
|
|
|
|
|
|
|
sub EclipseName {} |
3339
|
|
|
|
|
|
|
|
3340
|
|
|
|
|
|
|
=item EclipseName |
3341
|
|
|
|
|
|
|
|
3342
|
|
|
|
|
|
|
=item EclipseName SPRINTF_FORMAT |
3343
|
|
|
|
|
|
|
|
3344
|
|
|
|
|
|
|
When necessary DDS will rename vars output during deparsing with this |
3345
|
|
|
|
|
|
|
value. It is a sprintf format string that should contain only and both of |
3346
|
|
|
|
|
|
|
the "%s" and a "%d" formats in any order along with whatever other literal |
3347
|
|
|
|
|
|
|
text you want in the name. No checks are performed on the validity of this |
3348
|
|
|
|
|
|
|
value so be careful. It defaults to |
3349
|
|
|
|
|
|
|
|
3350
|
|
|
|
|
|
|
"%s_eclipse_%d" |
3351
|
|
|
|
|
|
|
|
3352
|
|
|
|
|
|
|
where the "%s" represents the name of the var being eclipsed, and the "%d" |
3353
|
|
|
|
|
|
|
a counter to ensure all such mappings are unique. |
3354
|
|
|
|
|
|
|
|
3355
|
|
|
|
|
|
|
=for UEDIT |
3356
|
|
|
|
|
|
|
sub DeparseOpts {} |
3357
|
|
|
|
|
|
|
|
3358
|
|
|
|
|
|
|
=item DeparseOpts |
3359
|
|
|
|
|
|
|
|
3360
|
|
|
|
|
|
|
=item DeparseOpts LIST |
3361
|
|
|
|
|
|
|
|
3362
|
|
|
|
|
|
|
=item DeparseOpts ARRAY |
3363
|
|
|
|
|
|
|
|
3364
|
|
|
|
|
|
|
If Deparse is True then these options will be passed to B::Deparse->new() |
3365
|
|
|
|
|
|
|
when dumping a CODE ref. If passed a list of scalars the list is used as |
3366
|
|
|
|
|
|
|
the arguments. If passed an array reference then this array is assumed to |
3367
|
|
|
|
|
|
|
contain a list of arguments. If no arguments are provided returns a an |
3368
|
|
|
|
|
|
|
array ref of arguments in scalar context, and a list of arguments in list |
3369
|
|
|
|
|
|
|
context. |
3370
|
|
|
|
|
|
|
|
3371
|
|
|
|
|
|
|
Note using this routine is at your own risk as of DDS 1.11, how it |
3372
|
|
|
|
|
|
|
interacts with the newer advanced closure dumping process is undefined. |
3373
|
|
|
|
|
|
|
|
3374
|
|
|
|
|
|
|
=for UEDIT |
3375
|
|
|
|
|
|
|
sub CodeStub {} |
3376
|
|
|
|
|
|
|
|
3377
|
|
|
|
|
|
|
=item CodeStub |
3378
|
|
|
|
|
|
|
|
3379
|
|
|
|
|
|
|
=item CodeStub STRING |
3380
|
|
|
|
|
|
|
|
3381
|
|
|
|
|
|
|
If Deparse is False then this string will be used in place of CODE |
3382
|
|
|
|
|
|
|
references. Its the users responsibility to make sure its compilable and |
3383
|
|
|
|
|
|
|
blessable. |
3384
|
|
|
|
|
|
|
|
3385
|
|
|
|
|
|
|
Defaults to 'sub { Carp::confess "Dumped code stub!" }' |
3386
|
|
|
|
|
|
|
|
3387
|
|
|
|
|
|
|
=for UEDIT |
3388
|
|
|
|
|
|
|
sub FormatStub {} |
3389
|
|
|
|
|
|
|
|
3390
|
|
|
|
|
|
|
=item FormatStub |
3391
|
|
|
|
|
|
|
|
3392
|
|
|
|
|
|
|
=item FormatStub STRING |
3393
|
|
|
|
|
|
|
|
3394
|
|
|
|
|
|
|
If Deparse is False then this string will be used in place of FORMAT |
3395
|
|
|
|
|
|
|
references. Its the users responsibility to make sure its compilable and |
3396
|
|
|
|
|
|
|
blessable. |
3397
|
|
|
|
|
|
|
|
3398
|
|
|
|
|
|
|
Defaults to 'do{ local *F; eval "format F =\nFormat Stub\n.\n"; *F{FORMAT} }' |
3399
|
|
|
|
|
|
|
|
3400
|
|
|
|
|
|
|
=for UEDIT |
3401
|
|
|
|
|
|
|
sub DeparseGlob {} |
3402
|
|
|
|
|
|
|
|
3403
|
|
|
|
|
|
|
=item DeparseGlob |
3404
|
|
|
|
|
|
|
|
3405
|
|
|
|
|
|
|
=item DeparseGlob BOOL |
3406
|
|
|
|
|
|
|
|
3407
|
|
|
|
|
|
|
If Deparse is TRUE then this style attribute will determine if subroutines |
3408
|
|
|
|
|
|
|
and FORMAT's contained in globs that are dumped will be deparsed or not. |
3409
|
|
|
|
|
|
|
|
3410
|
|
|
|
|
|
|
Defaults to True. |
3411
|
|
|
|
|
|
|
|
3412
|
|
|
|
|
|
|
=for UEDIT |
3413
|
|
|
|
|
|
|
sub DualVars {} |
3414
|
|
|
|
|
|
|
sub Dualvars {} |
3415
|
|
|
|
|
|
|
|
3416
|
|
|
|
|
|
|
=item Dualvars |
3417
|
|
|
|
|
|
|
|
3418
|
|
|
|
|
|
|
=item Dualvars BOOL |
3419
|
|
|
|
|
|
|
|
3420
|
|
|
|
|
|
|
=item Dualvars |
3421
|
|
|
|
|
|
|
|
3422
|
|
|
|
|
|
|
=item Dualvars BOOL |
3423
|
|
|
|
|
|
|
|
3424
|
|
|
|
|
|
|
If TRUE then dualvar checking will occur and the required statements |
3425
|
|
|
|
|
|
|
emitted to recreate dualvars when they are encountered, otherwise items |
3426
|
|
|
|
|
|
|
will be dumped in their stringified form always. It defaults to TRUE. |
3427
|
|
|
|
|
|
|
|
3428
|
|
|
|
|
|
|
=for UEDIT |
3429
|
|
|
|
|
|
|
sub Rle {} |
3430
|
|
|
|
|
|
|
sub RLE {} |
3431
|
|
|
|
|
|
|
|
3432
|
|
|
|
|
|
|
=item Rle |
3433
|
|
|
|
|
|
|
|
3434
|
|
|
|
|
|
|
=item Rle BOOL |
3435
|
|
|
|
|
|
|
|
3436
|
|
|
|
|
|
|
=item RLE |
3437
|
|
|
|
|
|
|
|
3438
|
|
|
|
|
|
|
=item RLE BOOL |
3439
|
|
|
|
|
|
|
|
3440
|
|
|
|
|
|
|
If True then arrays will be run length encoded using the C operator. |
3441
|
|
|
|
|
|
|
What this means is that if an array contains repeated elements then |
3442
|
|
|
|
|
|
|
instead of outputting each and every one a list multiplier will be output. |
3443
|
|
|
|
|
|
|
This means that considerably less space is taken to dump redundant data. |
3444
|
|
|
|
|
|
|
|
3445
|
|
|
|
|
|
|
=item Freezer |
3446
|
|
|
|
|
|
|
|
3447
|
|
|
|
|
|
|
=item Freezer ACTION |
3448
|
|
|
|
|
|
|
|
3449
|
|
|
|
|
|
|
=item Freezer CLASS, ACTION |
3450
|
|
|
|
|
|
|
|
3451
|
|
|
|
|
|
|
This method can be used to override the DDS_freeze hook for a |
3452
|
|
|
|
|
|
|
specific class. If CLASS is omitted then the ACTION applies to |
3453
|
|
|
|
|
|
|
all blessed object. |
3454
|
|
|
|
|
|
|
|
3455
|
|
|
|
|
|
|
If ACTION is false it indicates that the given CLASS should not |
3456
|
|
|
|
|
|
|
have any serilization hooks called. |
3457
|
|
|
|
|
|
|
|
3458
|
|
|
|
|
|
|
If ACTION is a string then it is taken to be the method name that |
3459
|
|
|
|
|
|
|
will be executed to freeze the object. CLASS->can(METHOD) must return |
3460
|
|
|
|
|
|
|
true or the setting will be ignored. |
3461
|
|
|
|
|
|
|
|
3462
|
|
|
|
|
|
|
If ACTION is a code ref it is executed with the object as the argument. |
3463
|
|
|
|
|
|
|
|
3464
|
|
|
|
|
|
|
When called with no arguments returns in scalar context the generic |
3465
|
|
|
|
|
|
|
serialization method (defaults to 'DDS_freeze'), in list context |
3466
|
|
|
|
|
|
|
returns the generic serialization method followed by a list of pairs |
3467
|
|
|
|
|
|
|
of Classname=>ACTION. |
3468
|
|
|
|
|
|
|
|
3469
|
|
|
|
|
|
|
If the action executes a sub or method it is expected to return |
3470
|
|
|
|
|
|
|
a list of three values: |
3471
|
|
|
|
|
|
|
|
3472
|
|
|
|
|
|
|
( $proxy, $thaw, $postdump )=$obj->DDS_Freeze(); |
3473
|
|
|
|
|
|
|
|
3474
|
|
|
|
|
|
|
See L for more details. |
3475
|
|
|
|
|
|
|
|
3476
|
|
|
|
|
|
|
B |
3477
|
|
|
|
|
|
|
Must be set before C is called. |
3478
|
|
|
|
|
|
|
|
3479
|
|
|
|
|
|
|
=cut |
3480
|
|
|
|
|
|
|
|
3481
|
|
|
|
|
|
|
sub Freezer { |
3482
|
2
|
|
|
2
|
1
|
728
|
my $self= shift; |
3483
|
2
|
50
|
|
|
|
7
|
if ( @_==1 ) { |
|
|
0
|
|
|
|
|
|
3484
|
2
|
|
|
|
|
3
|
$self->{style}{freezer}= shift; |
3485
|
2
|
|
|
|
|
7
|
return $self; |
3486
|
|
|
|
|
|
|
} elsif ( @_==2 ) { |
3487
|
0
|
|
|
|
|
0
|
my ( $class, $action )= @_; |
3488
|
0
|
|
|
|
|
0
|
$self->{style}{freeze_class}{$class}= $action; |
3489
|
0
|
|
|
|
|
0
|
return $self; |
3490
|
|
|
|
|
|
|
} |
3491
|
|
|
|
|
|
|
return wantarray ? ($self->{style}{freezer}, |
3492
|
0
|
|
|
|
|
0
|
map { $_ => $self->{style}{freeze_class}{$_} } |
3493
|
0
|
|
|
|
|
0
|
keys %{$self->{style}{freeze_class}} ) |
3494
|
0
|
0
|
|
|
|
0
|
: $self->{style}{freezer}; |
3495
|
|
|
|
|
|
|
} |
3496
|
|
|
|
|
|
|
|
3497
|
|
|
|
|
|
|
sub ResetFreezer { |
3498
|
1
|
|
|
1
|
0
|
365
|
my $self=shift; |
3499
|
1
|
|
|
|
|
3
|
$self->{style}{freezer}='DDS_freeze'; |
3500
|
1
|
|
|
|
|
2
|
$self->{style}{freeze_class}={}; |
3501
|
1
|
|
|
|
|
4
|
return $self; |
3502
|
|
|
|
|
|
|
} |
3503
|
|
|
|
|
|
|
|
3504
|
|
|
|
|
|
|
=item Ignore |
3505
|
|
|
|
|
|
|
|
3506
|
|
|
|
|
|
|
=item Ignore OBJ_OR_CLASS |
3507
|
|
|
|
|
|
|
|
3508
|
|
|
|
|
|
|
=item Ignore OBJ_OR_CLASS, BOOL |
3509
|
|
|
|
|
|
|
|
3510
|
|
|
|
|
|
|
Allows a given object or class to be ignored, and replaced with |
3511
|
|
|
|
|
|
|
a string containing the name of the item ignored. |
3512
|
|
|
|
|
|
|
|
3513
|
|
|
|
|
|
|
If called with no args returns a list of items ignored (using the refaddr |
3514
|
|
|
|
|
|
|
to represent objects). If called with a single argument returns whether |
3515
|
|
|
|
|
|
|
that argument is ignored. If called with more than one arguments then |
3516
|
|
|
|
|
|
|
expects a list of pairs of object => is_ignored. |
3517
|
|
|
|
|
|
|
|
3518
|
|
|
|
|
|
|
Returns $self when setting. |
3519
|
|
|
|
|
|
|
|
3520
|
|
|
|
|
|
|
B |
3521
|
|
|
|
|
|
|
Must be set before C is called. |
3522
|
|
|
|
|
|
|
|
3523
|
|
|
|
|
|
|
=cut |
3524
|
|
|
|
|
|
|
|
3525
|
|
|
|
|
|
|
sub Ignore { |
3526
|
2
|
|
|
2
|
1
|
669
|
my $self=shift; |
3527
|
2
|
50
|
|
|
|
8
|
if (@_==0) { |
3528
|
0
|
|
|
|
|
0
|
return map { s/^.//; $_ } keys %{$self->{style}{ignore}}; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
3529
|
|
|
|
|
|
|
} |
3530
|
2
|
50
|
33
|
|
|
15
|
Carp::confess("Must have an even number of arguments in Ignore()") |
3531
|
|
|
|
|
|
|
if @_>1 && @_ %2; |
3532
|
2
|
|
|
|
|
4
|
while (@_) { |
3533
|
2
|
|
|
|
|
3
|
my $item=shift; |
3534
|
2
|
50
|
|
|
|
5
|
if ( ref $item ) { |
3535
|
0
|
|
|
|
|
0
|
$item="#".refaddr($item); |
3536
|
|
|
|
|
|
|
} else { |
3537
|
2
|
|
|
|
|
5
|
$item=".$item"; |
3538
|
|
|
|
|
|
|
} |
3539
|
2
|
50
|
|
|
|
5
|
if ( ! @_ ) { |
3540
|
0
|
|
|
|
|
0
|
return $self->{style}{ignore}{$item}; |
3541
|
|
|
|
|
|
|
} |
3542
|
2
|
100
|
|
|
|
4
|
if ( shift ) { |
3543
|
1
|
|
|
|
|
7
|
$self->{style}{ignore}{$item}= 1; |
3544
|
|
|
|
|
|
|
} else { |
3545
|
1
|
|
|
|
|
4
|
delete $self->{style}{ignore}{$item}; |
3546
|
|
|
|
|
|
|
} |
3547
|
|
|
|
|
|
|
} |
3548
|
2
|
|
|
|
|
8
|
return $self; |
3549
|
|
|
|
|
|
|
} |
3550
|
|
|
|
|
|
|
|
3551
|
|
|
|
|
|
|
=for UEDIT |
3552
|
|
|
|
|
|
|
sub Compress {} |
3553
|
|
|
|
|
|
|
|
3554
|
|
|
|
|
|
|
=item Compress |
3555
|
|
|
|
|
|
|
|
3556
|
|
|
|
|
|
|
=item Compress SIZE |
3557
|
|
|
|
|
|
|
|
3558
|
|
|
|
|
|
|
Controls compression of string values (not keys). If this value |
3559
|
|
|
|
|
|
|
is nonzero and a string to be dumped is longer than its value then |
3560
|
|
|
|
|
|
|
the L if defined is used to compress |
3561
|
|
|
|
|
|
|
the string. Setting size to -1 will cause all strings to be |
3562
|
|
|
|
|
|
|
processed, setting size to 0 will cause no strings to be processed. |
3563
|
|
|
|
|
|
|
|
3564
|
|
|
|
|
|
|
=for UEDIT |
3565
|
|
|
|
|
|
|
sub Compressor {} |
3566
|
|
|
|
|
|
|
|
3567
|
|
|
|
|
|
|
=item Compressor |
3568
|
|
|
|
|
|
|
|
3569
|
|
|
|
|
|
|
=item Compressor CODE |
3570
|
|
|
|
|
|
|
|
3571
|
|
|
|
|
|
|
This attribute is used to control the compression of strings. |
3572
|
|
|
|
|
|
|
It is expected to be a reference to a subroutine with the following |
3573
|
|
|
|
|
|
|
interface: |
3574
|
|
|
|
|
|
|
|
3575
|
|
|
|
|
|
|
my $prelude_code=$compressor->(); # no arguments. |
3576
|
|
|
|
|
|
|
my $code=$compressor->('string'); # string argument |
3577
|
|
|
|
|
|
|
|
3578
|
|
|
|
|
|
|
The sub will be called with no arguments at the beginning of the |
3579
|
|
|
|
|
|
|
dump to allow any require statements or similar to be added. During |
3580
|
|
|
|
|
|
|
the dump the sub will be called with a single argument when |
3581
|
|
|
|
|
|
|
compression is required. The code returned in this case is expected |
3582
|
|
|
|
|
|
|
to be an EXPR that will evaluate back to the original string. |
3583
|
|
|
|
|
|
|
|
3584
|
|
|
|
|
|
|
By default DDS will use L in conjunction with |
3585
|
|
|
|
|
|
|
L to do compression and encoding, and exposes the |
3586
|
|
|
|
|
|
|
'usqz' subroutine for handling the decoding and decompression. |
3587
|
|
|
|
|
|
|
|
3588
|
|
|
|
|
|
|
The abbreviated name was chosen as when using the default compressor |
3589
|
|
|
|
|
|
|
every string will be represented by a string like |
3590
|
|
|
|
|
|
|
|
3591
|
|
|
|
|
|
|
usqz('....') |
3592
|
|
|
|
|
|
|
|
3593
|
|
|
|
|
|
|
Meaning that eight characters are required without considering the |
3594
|
|
|
|
|
|
|
data itself. Likewise Base64 was chosen because it is a representation |
3595
|
|
|
|
|
|
|
that is high-bit safe, compact and easy to quote. Escaped strings are |
3596
|
|
|
|
|
|
|
much less efficient for storing binary data. |
3597
|
|
|
|
|
|
|
|
3598
|
|
|
|
|
|
|
=cut |
3599
|
|
|
|
|
|
|
|
3600
|
|
|
|
|
|
|
# weird styling here deliberate. |
3601
|
|
|
|
|
|
|
sub |
3602
|
|
|
|
|
|
|
DeparseOpts |
3603
|
|
|
|
|
|
|
{ |
3604
|
0
|
|
|
0
|
1
|
0
|
my $self=shift; |
3605
|
0
|
0
|
|
|
|
0
|
if (@_) { |
3606
|
0
|
0
|
|
|
|
0
|
if (ref $_[0]) { |
3607
|
0
|
|
|
|
|
0
|
$self->{style}{deparseopts}=shift; |
3608
|
|
|
|
|
|
|
} else { |
3609
|
0
|
|
|
|
|
0
|
$self->{style}{deparseopts}=[@_]; |
3610
|
|
|
|
|
|
|
} |
3611
|
0
|
|
|
|
|
0
|
return $self; |
3612
|
|
|
|
|
|
|
} else { |
3613
|
0
|
|
|
|
|
0
|
return wantarray ? @{$self->{style}{deparseopts}} |
3614
|
0
|
0
|
|
|
|
0
|
: $self->{style}{deparseopts}; |
3615
|
|
|
|
|
|
|
} |
3616
|
|
|
|
|
|
|
} |
3617
|
|
|
|
|
|
|
|
3618
|
|
|
|
|
|
|
sub KeyOrder { |
3619
|
9
|
|
|
9
|
1
|
29
|
my $self= shift; |
3620
|
9
|
50
|
66
|
|
|
29
|
Carp::croak("KeyOrder() Must have an even number of arguments if doing a multiple set.") |
3621
|
|
|
|
|
|
|
if @_>2 and @_ % 2; |
3622
|
|
|
|
|
|
|
|
3623
|
9
|
|
|
|
|
17
|
while (@_) { |
3624
|
9
|
|
|
|
|
13
|
my $obj= shift; |
3625
|
9
|
|
|
|
|
6
|
my $name; |
3626
|
9
|
100
|
|
|
|
16
|
if (ref $obj) { |
3627
|
2
|
|
|
|
|
5
|
$name= "#" .refaddr($obj) |
3628
|
|
|
|
|
|
|
} else { |
3629
|
7
|
50
|
|
|
|
13
|
$name= "" if ! defined $obj; |
3630
|
7
|
|
|
|
|
11
|
$name= ".$obj"; |
3631
|
|
|
|
|
|
|
} |
3632
|
9
|
50
|
|
|
|
16
|
if ( ! @_ ) { |
3633
|
|
|
|
|
|
|
return $self->{style}{sortkeys_string}{$name}|| |
3634
|
0
|
|
0
|
|
|
0
|
$self->{style}{sortkeys}{$name}; |
3635
|
|
|
|
|
|
|
} |
3636
|
9
|
|
|
|
|
9
|
my $val= shift; |
3637
|
9
|
50
|
|
|
|
16
|
if ( ! defined $val ) { |
3638
|
0
|
|
|
|
|
0
|
delete $self->{style}{sortkeys}{$name}; |
3639
|
0
|
|
|
|
|
0
|
delete $self->{style}{sortkeys_string}{$name}; |
3640
|
|
|
|
|
|
|
} else { |
3641
|
9
|
100
|
|
|
|
35
|
if ( ! ref $val ) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
3642
|
5
|
|
|
|
|
9
|
my $subref= $default_key_sorters{$val}; |
3643
|
5
|
50
|
33
|
|
|
45
|
Carp::confess("Unblessed or per object Sortkeys() must be coderefs:'$val'\n") |
|
|
|
33
|
|
|
|
|
3644
|
|
|
|
|
|
|
if (!$subref or $name eq "." ) |
3645
|
|
|
|
|
|
|
and reftype($subref) ne "CODE"; |
3646
|
5
|
|
33
|
|
|
7
|
$subref ||= $obj->can($val); |
3647
|
5
|
50
|
0
|
|
|
10
|
die "Unknown sortkeys '$val', and " |
3648
|
|
|
|
|
|
|
. (ref($obj)||$obj)." doesn't know how to do it.\n" |
3649
|
|
|
|
|
|
|
if !$subref; |
3650
|
5
|
|
|
|
|
11
|
$self->{style}{sortkeys_string}{$name}=$val; |
3651
|
5
|
|
|
|
|
7
|
$val= $subref; |
3652
|
|
|
|
|
|
|
} elsif ( reftype($val) eq 'ARRAY' ) { |
3653
|
2
|
|
|
|
|
2
|
my $aryref= $val; |
3654
|
2
|
|
|
8
|
|
6
|
$val= sub{ return $aryref; }; |
|
8
|
|
|
|
|
9
|
|
3655
|
|
|
|
|
|
|
} elsif ( reftype($val) ne 'CODE' ) { |
3656
|
0
|
|
|
|
|
0
|
Carp::confess("Can't use '$val' as KeyOrder() value"); |
3657
|
|
|
|
|
|
|
} |
3658
|
9
|
|
|
|
|
25
|
$self->{style}{sortkeys}{$name}= $val; |
3659
|
|
|
|
|
|
|
} |
3660
|
|
|
|
|
|
|
} |
3661
|
9
|
|
|
|
|
22
|
return $self; |
3662
|
|
|
|
|
|
|
} |
3663
|
|
|
|
|
|
|
*Keyorder=*KeyOrder; |
3664
|
|
|
|
|
|
|
sub SortKeys { |
3665
|
6
|
|
|
6
|
1
|
683
|
my $self=shift; |
3666
|
6
|
|
|
|
|
17
|
$self->KeyOrder("",@_); |
3667
|
|
|
|
|
|
|
} |
3668
|
|
|
|
|
|
|
*Sortkeys= *SortKeys; |
3669
|
|
|
|
|
|
|
*HashKeys = *Hashkeys = *KeyOrder; |
3670
|
|
|
|
|
|
|
|
3671
|
|
|
|
|
|
|
my %scalar_meth=map{ $_ => lc($_)} |
3672
|
|
|
|
|
|
|
qw(Declare Indent IndentCols IndentKeys |
3673
|
|
|
|
|
|
|
Verbose DumpGlob Deparse DeparseGlob DeparseFormat CodeStub |
3674
|
|
|
|
|
|
|
FormatStub Rle RLE Purity DualVars Dualvars EclipseName |
3675
|
|
|
|
|
|
|
Compress Compressor OptSpace); |
3676
|
|
|
|
|
|
|
|
3677
|
|
|
|
|
|
|
sub AUTOLOAD { |
3678
|
23
|
|
|
23
|
|
50531
|
(my $meth=$AUTOLOAD)=~s/^((?:\w+::)+)//; |
3679
|
23
|
|
|
|
|
37
|
my $name; |
3680
|
23
|
50
|
|
|
|
109
|
if (defined($name=$scalar_meth{$meth})) { |
|
|
0
|
|
|
|
|
|
3681
|
23
|
50
|
|
|
|
63
|
$DEBUG and print "AUTLOADING scalar meth $meth ($name)\n"; |
3682
|
23
|
100
|
|
221
|
1
|
2209
|
eval ' |
|
221
|
50
|
|
2
|
1
|
99252
|
|
|
221
|
50
|
|
3
|
0
|
558
|
|
|
57
|
50
|
|
2
|
1
|
127
|
|
|
57
|
50
|
|
4
|
1
|
252
|
|
|
164
|
50
|
|
2
|
1
|
462
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
10
|
|
|
0
|
|
|
|
|
0
|
|
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
12
|
|
|
0
|
|
|
|
|
0
|
|
|
2
|
|
|
|
|
42
|
|
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
7
|
|
|
0
|
|
|
|
|
0
|
|
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
12
|
|
|
0
|
|
|
|
|
0
|
|
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
9
|
|
|
0
|
|
|
|
|
|
|
3683
|
|
|
|
|
|
|
sub '.$meth.' { |
3684
|
|
|
|
|
|
|
my $self=shift->_safe_self(); |
3685
|
|
|
|
|
|
|
if (@_) { |
3686
|
|
|
|
|
|
|
$self->{style}{'.$name.'}=shift; |
3687
|
|
|
|
|
|
|
return $self |
3688
|
|
|
|
|
|
|
} else { |
3689
|
|
|
|
|
|
|
return $self->{style}{'.$name.'} |
3690
|
|
|
|
|
|
|
} |
3691
|
|
|
|
|
|
|
} |
3692
|
|
|
|
|
|
|
'; |
3693
|
23
|
50
|
|
|
|
104
|
$@ and die "$meth:$@\n"; |
3694
|
23
|
|
|
|
|
782
|
goto &$meth; |
3695
|
|
|
|
|
|
|
} elsif ($meth=~/[^A-Z]/) { |
3696
|
0
|
|
|
|
|
0
|
Carp::confess "Unhandled method/subroutine call $AUTOLOAD"; |
3697
|
|
|
|
|
|
|
} |
3698
|
|
|
|
|
|
|
} |
3699
|
|
|
|
|
|
|
|
3700
|
|
|
|
|
|
|
sub _get_lexicals { |
3701
|
79
|
|
|
79
|
|
85
|
my $cv=shift; |
3702
|
|
|
|
|
|
|
|
3703
|
79
|
50
|
|
|
|
151
|
if ($HasPadWalker) { |
3704
|
79
|
|
|
|
|
368
|
my ($names,$targs)=PadWalker::closed_over($cv); |
3705
|
79
|
50
|
|
|
|
161
|
if ($PadWalker::VERSION < 1) { |
3706
|
0
|
|
|
|
|
0
|
$names->{$_}=$names->{$targs->{$_}} for keys %$targs; |
3707
|
|
|
|
|
|
|
} else { |
3708
|
79
|
|
|
|
|
329
|
%$names=(%$names,%$targs); |
3709
|
|
|
|
|
|
|
} |
3710
|
79
|
|
|
|
|
192
|
return $names; |
3711
|
|
|
|
|
|
|
} |
3712
|
|
|
|
|
|
|
|
3713
|
0
|
|
|
|
|
0
|
my $svo=B::svref_2object($cv); |
3714
|
0
|
|
|
|
|
0
|
my @pl_array = eval { $svo->PADLIST->ARRAY }; |
|
0
|
|
|
|
|
0
|
|
3715
|
0
|
|
|
|
|
0
|
my @name_obj = eval { $pl_array[0]->ARRAY }; |
|
0
|
|
|
|
|
0
|
|
3716
|
|
|
|
|
|
|
|
3717
|
0
|
|
|
|
|
0
|
my %named; |
3718
|
0
|
|
|
|
|
0
|
for my $i ( 0..$#name_obj ) { |
3719
|
0
|
0
|
|
|
|
0
|
if ( ref($name_obj[$i])!~/SPECIAL/) { |
3720
|
0
|
|
|
|
|
0
|
$named{$i} = $name_obj[$i]->PV; |
3721
|
|
|
|
|
|
|
} |
3722
|
|
|
|
|
|
|
} |
3723
|
|
|
|
|
|
|
|
3724
|
0
|
|
|
|
|
0
|
my %inited; |
3725
|
|
|
|
|
|
|
my %used; |
3726
|
|
|
|
|
|
|
B::Utils::walkoptree_filtered( |
3727
|
|
|
|
|
|
|
$svo->ROOT, |
3728
|
0
|
|
|
0
|
|
0
|
sub { B::Utils::opgrep { name => [ qw[ padsv padav padhv ] ] }, @_ }, |
3729
|
|
|
|
|
|
|
sub { |
3730
|
0
|
|
|
0
|
|
0
|
my ( $op, @items )=@_; |
3731
|
0
|
|
|
|
|
0
|
my $targ = $op->targ; |
3732
|
0
|
0
|
|
|
|
0
|
my $name = $named{$targ} |
3733
|
|
|
|
|
|
|
or return; |
3734
|
|
|
|
|
|
|
|
3735
|
0
|
0
|
|
|
|
0
|
$inited{$name}++ |
3736
|
|
|
|
|
|
|
if $op->private & 128; |
3737
|
|
|
|
|
|
|
|
3738
|
0
|
0
|
|
|
|
0
|
if ( !$inited{$name} ) { |
3739
|
0
|
|
|
|
|
0
|
$used{$name} = $pl_array[1]->ARRAYelt($targ)->object_2svref; |
3740
|
0
|
|
|
|
|
0
|
$used{$targ} = $used{$name}; |
3741
|
0
|
|
|
|
|
0
|
$inited{$name}++; |
3742
|
|
|
|
|
|
|
} |
3743
|
|
|
|
|
|
|
} |
3744
|
0
|
|
|
|
|
0
|
); |
3745
|
0
|
|
|
|
|
0
|
return \%used; |
3746
|
|
|
|
|
|
|
} |
3747
|
|
|
|
|
|
|
|
3748
|
|
|
|
|
|
|
package Data::Dump::Streamer::Deparser; |
3749
|
24
|
|
|
24
|
|
129569
|
use B::Deparse; |
|
24
|
|
|
|
|
49
|
|
|
24
|
|
|
|
|
6254
|
|
3750
|
|
|
|
|
|
|
our @ISA=qw(B::Deparse); |
3751
|
|
|
|
|
|
|
my %cache; |
3752
|
|
|
|
|
|
|
|
3753
|
|
|
|
|
|
|
our $VERSION = '2.40'; |
3754
|
|
|
|
|
|
|
$VERSION= eval $VERSION; |
3755
|
|
|
|
|
|
|
if ( $VERSION ne $Data::Dump::Streamer::VERSION ) { |
3756
|
|
|
|
|
|
|
die "Incompatible Data::Dump::Streamer::Deparser v$VERSION vs Data::Dump::Streamer v$Data::Dump::Streamer::VERSION"; |
3757
|
|
|
|
|
|
|
} |
3758
|
|
|
|
|
|
|
|
3759
|
|
|
|
|
|
|
sub dds_usenames { |
3760
|
39
|
|
|
39
|
|
44
|
my $self=shift; |
3761
|
39
|
|
|
|
|
39
|
my $names=shift; |
3762
|
39
|
|
|
|
|
120
|
$cache{Data::Dump::Streamer::refaddr $self}=$names; |
3763
|
|
|
|
|
|
|
} |
3764
|
|
|
|
|
|
|
|
3765
|
|
|
|
|
|
|
sub padname { |
3766
|
45
|
|
|
45
|
|
61
|
my $self = shift; |
3767
|
45
|
|
|
|
|
41
|
my $targ = shift; |
3768
|
45
|
100
|
33
|
|
|
279
|
if ( $cache{Data::Dump::Streamer::refaddr $self} and $cache{Data::Dump::Streamer::refaddr $self}{$targ} ) { |
3769
|
39
|
|
|
|
|
4461
|
return $cache{Data::Dump::Streamer::refaddr $self}{$targ} |
3770
|
|
|
|
|
|
|
} |
3771
|
6
|
|
|
|
|
1242
|
return $self->padname_sv($targ)->PVX; |
3772
|
|
|
|
|
|
|
} |
3773
|
|
|
|
|
|
|
|
3774
|
|
|
|
|
|
|
sub DESTROY { |
3775
|
44
|
|
|
44
|
|
55
|
my $self=shift; |
3776
|
44
|
|
|
|
|
294
|
delete $cache{Data::Dump::Streamer::refaddr $self}; |
3777
|
|
|
|
|
|
|
} |
3778
|
|
|
|
|
|
|
|
3779
|
|
|
|
|
|
|
unless (B::AV->can('ARRAYelt')) { |
3780
|
|
|
|
|
|
|
eval <<' EOF_EVAL'; |
3781
|
|
|
|
|
|
|
sub B::AV::ARRAYelt { |
3782
|
|
|
|
|
|
|
my ($obj,$idx)=@_; |
3783
|
|
|
|
|
|
|
my @array=$obj->ARRAY; |
3784
|
|
|
|
|
|
|
return $array[$idx]; |
3785
|
|
|
|
|
|
|
} |
3786
|
|
|
|
|
|
|
EOF_EVAL |
3787
|
|
|
|
|
|
|
} |
3788
|
|
|
|
|
|
|
|
3789
|
|
|
|
|
|
|
1; |
3790
|
|
|
|
|
|
|
__END__ |