X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FSub-Nary.git;a=blobdiff_plain;f=lib%2FSub%2FNary.pm;h=ef92fa178aab2f41bef787150aae2aec7b6ffca1;hp=52a3f8402e4c4783a0441da8ed35b24f4466ad9f;hb=84483a1d32823197ca6c6dcb5e839e8d5650e9e4;hpb=02510517a867d6f89d6dac825672e183e075e97e diff --git a/lib/Sub/Nary.pm b/lib/Sub/Nary.pm index 52a3f84..ef92fa1 100644 --- a/lib/Sub/Nary.pm +++ b/lib/Sub/Nary.pm @@ -9,8 +9,6 @@ use Carp qw/croak/; use B qw/class ppname svref_2object OPf_KIDS/; -use Test::More; use Data::Dumper; - =head1 NAME Sub::Nary - Try to count how many elements a subroutine can return in list context. @@ -26,8 +24,6 @@ BEGIN { $VERSION = '0.02'; } -our $DEBUG = 0; - =head1 SYNOPSIS use Sub::Nary; @@ -243,7 +239,6 @@ sub inspect { my ($self, $op) = @_; my $n = name($op); - diag "@ $n" if $DEBUG; return add($self->inspect_kids($op)), undef if $n eq 'return'; my $meth = $self->can('pp_' . $n); @@ -258,8 +253,6 @@ sub inspect { if (class($op) eq 'LOGOP' and not null $op->first) { my @res; - diag "? logop\n" if $DEBUG; - my $op = $op->first; my ($r1, $l1) = $self->inspect($op); return $r1, $l1 if defined $r1 and zero $l1; @@ -311,10 +304,8 @@ sub inspect_kids { $op = $op->first; redo; } - diag "> $n" if $DEBUG; my ($rc, $lc) = $self->inspect($op); $c = 1 - count $r; - diag Dumper [ $c, $r, \@l, $rc, $lc ] if $DEBUG; $r = add $r, scale $c, $rc if defined $rc; if (not defined $lc) { @l = (); @@ -323,7 +314,6 @@ sub inspect_kids { push @l, scale $c, $lc; } -# diag Dumper \@l if $DEBUG; my $l = scale +(1 - count $r), normalize combine @l; return $r, $l; @@ -365,7 +355,6 @@ sub pp_entersub { for (; not null $op->sibling; $op = $op->sibling) { my $n = name($op); next if $n eq 'nextstate'; - diag "* $n" if $DEBUG; my ($rc, $lc) = $self->inspect($op); $r = add $r, scale $c, $rc if defined $rc; if (zero $lc) { @@ -480,8 +469,6 @@ sub pp_aassign { sub pp_leaveloop { my ($self, $op) = @_; - diag "* leaveloop" if $DEBUG; - $op = $op->first; my ($r1, $l1); my $for; @@ -509,7 +496,6 @@ sub pp_leaveloop { my $r = (defined $r1) ? add $r1, scale +(1 - count $r1), $r2 : $r2; my $c = 1 - count $r; - diag "& leaveloop $c" if $DEBUG; return $r, $c ? { 0 => $c } : undef; } @@ -557,7 +543,6 @@ sub pp_grepwhile { my ($r1, $l1) = $self->inspect($op); return (add $r2, scale $c2, $r1), undef if defined $r1 and zero $l1 and not zero $l2; - diag Dumper [ [ $r1, $l1 ], [ $r2, $l2 ] ] if $DEBUG; my $c1 = count $l1; $l2 = { $l2 => 1 } unless ref $l2; @@ -582,7 +567,6 @@ sub pp_mapwhile { my ($r1, $l1) = $self->inspect($op); return (add $r2, scale $c2, $r1), undef if defined $r1 and zero $l1 and not zero $l2; - diag Dumper [ [ $r1, $l1 ], [ $r2, $l2 ] ] if $DEBUG; my $c1 = count $l1; $l2 = { $l2 => 1 } unless ref $l2;