OPpTRANS_SQUASH OPpTRANS_DELETE OPpTRANS_COMPLEMENT OPpTARGET_MY
OPpCONST_ARYBASE OPpEXISTS_SUB OPpSORT_NUMERIC OPpSORT_INTEGER
OPpSORT_REVERSE
- SVf_IOK SVf_NOK SVf_ROK SVf_POK SVpad_OUR
- CVf_METHOD CVf_LOCKED CVf_LVALUE
+ SVf_IOK SVf_NOK SVf_ROK SVf_POK SVpad_OUR SVf_FAKE
+ CVf_METHOD CVf_LOCKED CVf_LVALUE CVf_ASSERTION
PMf_KEEP PMf_GLOBAL PMf_CONTINUE PMf_EVAL PMf_ONCE PMf_SKIPWHITE
PMf_MULTILINE PMf_SINGLELINE PMf_FOLD PMf_EXTENDED);
$VERSION = 0.63;
return unless $self->const_sv($constop)->PV eq $module;
$constop = $constop->sibling;
- $version = $self->const_sv($constop)->int_value;
+ $version = $self->const_sv($constop);
+ if (class($version) ne "PVMG") {
+ # version is either an integer or a double
+ $version = $version->PV;
+ } else {
+ # version specified as a v-string
+ $version = 'v'.join '.', map ord, split //, $version->PV;
+ }
$constop = $constop->sibling;
return if $constop->name ne "method_named";
return if $self->const_sv($constop)->PV ne "VERSION";
if ($cv->FLAGS & SVf_POK) {
$proto = "(". $cv->PV . ") ";
}
- if ($cv->CvFLAGS & (CVf_METHOD|CVf_LOCKED|CVf_LVALUE)) {
+ if ($cv->CvFLAGS & (CVf_METHOD|CVf_LOCKED|CVf_LVALUE|CVf_ASSERTION)) {
$proto .= ": ";
$proto .= "lvalue " if $cv->CvFLAGS & CVf_LVALUE;
$proto .= "locked " if $cv->CvFLAGS & CVf_LOCKED;
$proto .= "method " if $cv->CvFLAGS & CVf_METHOD;
+ $proto .= "assertion " if $cv->CvFLAGS & CVf_ASSERTION;
}
local($self->{'curcv'}) = $cv;
if ($op->private & (OPpLVAL_INTRO|$our_intro)
and not $self->{'avoid_local'}{$$op}) {
my $our_local = ($op->private & OPpLVAL_INTRO) ? "local" : "our";
+ if( $our_local eq 'our' ) {
+ die "Unexpected our($text)\n" unless $text =~ /^\W(\w+::)*\w+\z/;
+ $text =~ s/(\w+::)+//;
+ }
if (want_scalar($op)) {
return "$our_local $text";
} else {
sub populate_curcvlex {
my $self = shift;
for (my $cv = $self->{'curcv'}; class($cv) eq "CV"; $cv = $cv->OUTSIDE) {
- my @padlist = $cv->PADLIST->ARRAY;
+ my $padlist = $cv->PADLIST;
+ # an undef CV still in lexical chain
+ next if class($padlist) eq "SPECIAL";
+ my @padlist = $padlist->ARRAY;
my @ns = $padlist[0]->ARRAY;
for (my $i=0; $i<@ns; ++$i) {
next;
}
my $name = $ns[$i]->PVX;
- my $seq_st = $ns[$i]->NVX;
- my $seq_en = int($ns[$i]->IVX);
+ my ($seq_st, $seq_en) =
+ ($ns[$i]->FLAGS & SVf_FAKE)
+ ? (0, 999999)
+ : ($ns[$i]->NVX, $ns[$i]->IVX);
push @{$self->{'curcvlex'}{$name}}, [$seq_st, $seq_en];
}
my $body;
my $cond = undef;
if ($kid->name eq "lineseq") { # bare or infinite loop
- if (is_state $kid->last) { # infinite
+ if ($kid->last->name eq "unstack") { # infinite
$head = "while (1) "; # Can't use for(;;) if there's a continue
$cond = "";
} else {
$var = $self->pp_threadsv($enter, 1);
} else { # regular my() variable
$var = $self->pp_padsv($enter, 1);
- if ($self->padname_sv($enter->targ)->IVX ==
- $kid->first->first->sibling->last->cop_seq)
- {
- # If the scope of this variable closes at the last
- # statement of the loop, it must have been
- # declared here.
- $var = "my " . $var;
- }
}
} elsif ($var->name eq "rv2gv") {
$var = $self->pp_rv2sv($var, 1);
+ if ($enter->private & OPpOUR_INTRO) {
+ # our declarations don't have package names
+ $var =~ s/^(.).*::/$1/;
+ $var = "our $var";
+ }
} elsif ($var->name eq "gv") {
$var = "\$" . $self->deparse($var, 1);
}
return "{;}"; # {} could be a hashref
}
# If there isn't a continue block, then the next pointer for the loop
- # will point to the unstack, which is kid's penultimate child, except
+ # will point to the unstack, which is kid's last child, except
# in a bare loop, when it will point to the leaveloop. When neither of
- # these conditions hold, then the third-to-last child in the continue
+ # these conditions hold, then the second-to-last child is the continue
# block (or the last in a bare loop).
my $cont_start = $enter->nextop;
my $cont;
- if ($$cont_start != $$op && ${$cont_start->sibling} != ${$body->last}) {
+ if ($$cont_start != $$op && ${$cont_start} != ${$body->last}) {
if ($bare) {
$cont = $body->last;
} else {
$cont = $body->first;
- while (!null($cont->sibling->sibling->sibling)) {
+ while (!null($cont->sibling->sibling)) {
$cont = $cont->sibling;
}
}
sub pp_null {
my $self = shift;
- my($op, $cx) = @_;
+ my($op, $cx, $flags) = @_;
if (class($op) eq "OP") {
# old value is lost
return $self->{'ex_const'} if $op->targ == OP_CONST;
. $self->deparse($op->first->sibling, 20),
$cx, 20);
} elsif ($op->flags & OPf_SPECIAL && $cx == 0 && !$op->targ) {
- return "do {\n\t". $self->deparse($op->first, $cx) ."\n\b};";
+ if ($flags) {
+ return $self->deparse($op->first, $cx);
+ }
+ else {
+ return "do {\n\t". $self->deparse($op->first, $cx) ."\n\b};";
+ }
} elsif (!null($op->first->sibling) and
$op->first->sibling->name eq "null" and
class($op->first->sibling) eq "UNOP" and
| \\[uUlLQE]
)
- /length($4) ? "$1$2$4" : "$1$2\\$3"/xeg;
+ /defined($4) && length($4) ? "$1$2$4" : "$1$2\\$3"/xeg;
return $str;
}
sub const {
my $sv = shift;
if (class($sv) eq "SPECIAL") {
- return ('undef', '1', '0')[$$sv-1]; # sv_undef, sv_yes, sv_no
+ return ('undef', '1', '(!1)')[$$sv-1]; # sv_undef, sv_yes, sv_no
} elsif (class($sv) eq "NULL") {
return 'undef';
} elsif ($sv->FLAGS & SVf_IOK) {
my $first = $self->dq($op->first);
my $last = $self->dq($op->last);
- # Disambiguate "${foo}bar", "${foo}{bar}", "${foo}[1]"
+ # Disambiguate "${foo}bar", "${foo}{bar}", "${foo}[1]", "$foo\::bar"
($last =~ /^[A-Z\\\^\[\]_?]/ &&
$first =~ s/([\$@])\^$/${1}{^}/) # "${^}W" etc
- || ($last =~ /^[{\[\w_]/ &&
+ || ($last =~ /^[:'{\[\w_]/ &&
$first =~ s/([\$@])([A-Za-z_]\w*)$/${1}{$2}/);
return $first . $last;
sub pure_string {
my ($self, $op) = @_;
+ return 0 if null $op;
my $type = $op->name;
if ($type eq 'const') {
$flags .= "e";
}
if ($op->pmflags & PMf_EVAL) {
- $repl = $self->deparse($repl, 0);
+ $repl = $self->deparse($repl, 0, 1);
} else {
$repl = $self->dq($repl);
}