sub B::GV::SAFENAME {
my $name = (shift())->NAME;
- $name =~ s/^([\cA-\cZ])/"^".chr(64 + ord($1))/e;
+
+ # The regex below corresponds to the isCONTROLVAR macro
+ # from toke.c
+
+ $name =~ s/^([\cA-\cZ\c\\c[\c]\c?\c_\c^])/"^".chr(64 ^ ord($1))/e;
return $name;
}
+sub B::IV::int_value {
+ my ($self) = @_;
+ return (($self->FLAGS() & SVf_IVisUV()) ? $self->UVX : $self->IV);
+}
+
my $debug;
my $op_count = 0;
my @parents = ();
=item IV
+Returns the value of the IV, I<interpreted as
+a signed integer>. This will be misleading
+if C<FLAGS & SVf_IVisUV>. Perhaps you want the
+C<int_value> method instead?
+
=item IVX
+=item UVX
+
+=item int_value
+
+This method returns the value of the IV as an integer.
+It differs from C<IV> in that it returns the correct
+value regardless of whether it's stored signed or
+unsigned.
+
=item needs64bits
=item packiv
my $self = shift;
my $gv = shift;
my $stash = $gv->STASH->NAME;
- my $name = $gv->NAME;
+ my $name = $gv->SAFENAME;
if ($stash eq $self->{'curstash'} or $globalnames{$name}
or $name =~ /^[^A-Za-z_]/)
{
} else {
$stash = $stash . "::";
}
- if ($name =~ /^([\cA-\cZ])(.*)$/) {
- $name = "^" . chr(64 + ord($1)) . $2;
- $name = "{$name}" if length($2); # ${^WARNING_BITS} etc
+ if ($name =~ /^\^../) {
+ $name = "{$name}"; # ${^WARNING_BITS} etc
}
return $stash . $name;
}
if (class($sv) eq "SPECIAL") {
return ('undef', '1', '0')[$$sv-1]; # sv_undef, sv_yes, sv_no
} elsif ($sv->FLAGS & SVf_IOK) {
- return $sv->IV;
+ return $sv->int_value;
} elsif ($sv->FLAGS & SVf_NOK) {
return $sv->NV;
} elsif ($sv->FLAGS & SVf_ROK) {
package B::Terse;
use strict;
use B qw(peekop class walkoptree walkoptree_exec walkoptree_slow
- main_start main_root cstring svref_2object);
+ main_start main_root cstring svref_2object SVf_IVisUV);
use B::Asmdata qw(@specialsv_name);
sub terse {
sub B::IV::terse {
my ($sv, $level) = @_;
print indent($level);
- printf "%s (0x%lx) %d\n", class($sv), $$sv, $sv->IV;
+ my $v = $sv->FLAGS & SVf_IVisUV ? "%u" : "%d";
+ printf "%s (0x%lx) $v\n", class($sv), $$sv, $sv->int_value;
}
sub B::NV::terse {