Deparse CORE::say, etc., when bundle hints are in use
authorFather Chrysostomos <sprout@cpan.org>
Sat, 24 Dec 2011 08:06:20 +0000 (00:06 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 24 Dec 2011 17:25:21 +0000 (09:25 -0800)
dist/B-Deparse/Deparse.pm
dist/B-Deparse/t/deparse.t

index d7a5caa..b78ef67 100644 (file)
@@ -1583,14 +1583,26 @@ my %feature_keywords = (
     __SUB__ => '__SUB__',
 );
 
+my $feature_bundle_mask = 0x1c000000;
+
 sub keyword {
     my $self = shift;
     my $name = shift;
     return $name if $name =~ /^CORE::/; # just in case
     if (exists $feature_keywords{$name}) {
+       my $hh;
+       my $hints = $self->{hints} & $feature_bundle_mask;
+       if ($hints && $hints != $feature_bundle_mask) {
+           require feature;
+           local $^H = $self->{hints};
+           # Shh! Keep quite about this function.  It is not to be
+           # relied upon.
+           $hh = { map +($_ => 1), feature::current_bundle() };
+       }
+       elsif ($hints) { $hh = $self->{'hinthash'} }
        return "CORE::$name"
-        if !$self->{'hinthash'}
-        || !$self->{'hinthash'}{"feature_$feature_keywords{$name}"}
+        if !$hh
+        || !$hh->{"feature_$feature_keywords{$name}"}
     }
     if (
       $name !~ /^(?:chom?p|do|exec|glob|s(?:elect|ystem))\z/
index 046d276..92917fd 100644 (file)
@@ -837,6 +837,41 @@ CORE::given ($x) {
 CORE::evalbytes '';
 () = CORE::__SUB__;
 ####
+# feature features when feature has been disabled by use VERSION
+use feature (sprintf(":%vd", $^V));
+use 1;
+CORE::state $x;
+CORE::say $x;
+CORE::given ($x) {
+    CORE::when (3) {
+        continue;
+    }
+    CORE::default {
+        CORE::break;
+    }
+}
+CORE::evalbytes '';
+() = CORE::__SUB__;
+>>>>
+BEGIN {
+    $^H{'feature___SUB__'} = '1';
+    $^H{'feature_unieval'} = '1';
+    $^H{'feature_unicode'} = '1';
+    $^H{'feature_evalbytes'} = '1';
+}
+CORE::state $x;
+CORE::say $x;
+CORE::given ($x) {
+    CORE::when (3) {
+        continue;
+    }
+    CORE::default {
+        CORE::break;
+    }
+}
+CORE::evalbytes '';
+() = CORE::__SUB__;
+####
 # $#- $#+ $#{%} etc.
 my @x;
 @x = ($#{`}, $#{~}, $#{!}, $#{@}, $#{$}, $#{%}, $#{^}, $#{&}, $#{*});