summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsh Berlin <ash@cpan.org>2007-02-15 10:47:15 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2007-02-15 13:10:31 +0000
commitb6b46d6fef0ebfb87b28df83dc99c5caa7d12a75 (patch)
tree7d81ff17b7267bc9b441cc17ba9f9ef785d245f8
parent8ae10a673121fdbb7e442dbc204486adf42fe05c (diff)
downloadperl-b6b46d6fef0ebfb87b28df83dc99c5caa7d12a75.tar.gz
Re: Patch for Deep recursion in B::Deparse
Message-ID: <45D43A33.6070101@firemirror.com> p4raw-id: //depot/perl@30315
-rw-r--r--ext/B/B/Deparse.pm36
1 files changed, 20 insertions, 16 deletions
diff --git a/ext/B/B/Deparse.pm b/ext/B/B/Deparse.pm
index e2f1cf02d1..8fe96b0b27 100644
--- a/ext/B/B/Deparse.pm
+++ b/ext/B/B/Deparse.pm
@@ -20,7 +20,7 @@ use B qw(class main_root main_start main_cv svref_2object opnumber perlstring
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.80;
+$VERSION = 0.81;
use strict;
use vars qw/$AUTOLOAD/;
use warnings ();
@@ -1316,21 +1316,25 @@ sub find_scope {
carp("Undefined op in find_scope") if !defined $op;
return ($scope_st, $scope_en) unless $op->flags & OPf_KIDS;
- for (my $o=$op->first; $$o; $o=$o->sibling) {
- if ($o->name =~ /^pad.v$/ && $o->private & OPpLVAL_INTRO) {
- my $s = int($self->padname_sv($o->targ)->COP_SEQ_RANGE_LOW);
- my $e = $self->padname_sv($o->targ)->COP_SEQ_RANGE_HIGH;
- $scope_st = $s if !defined($scope_st) || $s < $scope_st;
- $scope_en = $e if !defined($scope_en) || $e > $scope_en;
- }
- elsif (is_state($o)) {
- my $c = $o->cop_seq;
- $scope_st = $c if !defined($scope_st) || $c < $scope_st;
- $scope_en = $c if !defined($scope_en) || $c > $scope_en;
- }
- elsif ($o->flags & OPf_KIDS) {
- ($scope_st, $scope_en) =
- $self->find_scope($o, $scope_st, $scope_en)
+ my @queue = ($op);
+ while(my $op = shift @queue ) {
+ for (my $o=$op->first; $$o; $o=$o->sibling) {
+ if ($o->name =~ /^pad.v$/ && $o->private & OPpLVAL_INTRO) {
+ my $s = int($self->padname_sv($o->targ)->COP_SEQ_RANGE_LOW);
+ my $e = $self->padname_sv($o->targ)->COP_SEQ_RANGE_HIGH;
+ $scope_st = $s if !defined($scope_st) || $s < $scope_st;
+ $scope_en = $e if !defined($scope_en) || $e > $scope_en;
+ return ($scope_st, $scope_en);
+ }
+ elsif (is_state($o)) {
+ my $c = $o->cop_seq;
+ $scope_st = $c if !defined($scope_st) || $c < $scope_st;
+ $scope_en = $c if !defined($scope_en) || $c > $scope_en;
+ return ($scope_st, $scope_en);
+ }
+ elsif ($o->flags & OPf_KIDS) {
+ unshift (@queue, $o);
+ }
}
}