]> git.vpit.fr Git - perl/modules/Sub-Nary.git/blobdiff - lib/Sub/Nary.pm
An entersub has always at least a pushmark and a rv2cv
[perl/modules/Sub-Nary.git] / lib / Sub / Nary.pm
index 838fab0c7cfd79dfa807c6473311439894f7a872..1406d6695dbde7f89ce4e62c52177c039a34cef4 100644 (file)
@@ -15,13 +15,13 @@ Sub::Nary - Try to count how many elements a subroutine can return in list conte
 
 =head1 VERSION
 
-Version 0.02
+Version 0.03
 
 =cut
 
 our $VERSION;
 BEGIN {
- $VERSION  = '0.02';
+ $VERSION  = '0.03';
 }
 
 =head1 SYNOPSIS
@@ -230,7 +230,6 @@ sub enter {
  my $r = add $self->inspect($op->first);
  shift @{$self->{cv}};
 
- $r = { $r => 1 } unless ref $r;
  $self->{cache}->{$tag} = { %$r };
  return undef, $r;
 }
@@ -344,23 +343,16 @@ sub pp_entersub {
  my ($self, $op) = @_;
 
  $op = $op->first while $op->flags & OPf_KIDS;
- return undef, 0 if null $op;
- if (name($op) eq 'pushmark') {
-  $op = $op->sibling;
-  return undef, 0 if null $op;
- }
+ # First must be a pushmark
+ $op = $op->sibling;
+ # Next must be non null - at worse it's the rv2cv
 
  my $r;
  my $c = 1;
  for (; not null $op->sibling; $op = $op->sibling) {
-  my $n = name($op);
-  next if $n eq 'nextstate';
   my ($rc, $lc) = $self->inspect($op);
-  $r = add $r, scale $c, $rc if defined $rc;
-  if (zero $lc) {
-   $c = 1 - count $r;
-   return $r, $c ? { 0 => $c } : undef
-  }
+  return $rc, $lc if defined $rc and not defined $lc;
+  $r = add $r, scale $c, $rc;
   $c *= count $lc;
  }
 
@@ -453,6 +445,15 @@ sub pp_rv2av {
  $self->inspect($op);
 }
 
+sub pp_sassign {
+ my ($self, $op) = @_;
+
+ my $r = ($self->inspect($op->first))[0];
+
+ my $c = 1 - count $r;
+ return $r, $c ? { 1 => $c } : undef
+}
+
 sub pp_aassign {
  my ($self, $op) = @_;
 
@@ -601,7 +602,7 @@ You can contact me by mail or on #perl @ FreeNode (vincent or Prof_Vince).
 
 =head1 BUGS
 
-Please report any bugs or feature requests to C<bug-b-nary at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Sub-Nary>.  I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
+Please report any bugs or feature requests to C<bug-sub-nary at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Sub-Nary>.  I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
 
 =head1 SUPPORT