Give feature.pm the concept of no-op features
authorFather Chrysostomos <sprout@cpan.org>
Fri, 20 May 2016 21:30:14 +0000 (14:30 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 20 May 2016 22:59:58 +0000 (15:59 -0700)
feature.h
lib/B/Deparse.t
lib/feature.pm
regen/feature.pl

index a527e06..27dfd51 100644 (file)
--- a/feature.h
+++ b/feature.h
         FEATURE_IS_ENABLED("evalbytes")) \
     )
 
-#define FEATURE_POSTDEREF_IS_ENABLED \
-    ( \
-       CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
-        FEATURE_IS_ENABLED("postderef") \
-    )
-
 #define FEATURE_ARYBASE_IS_ENABLED \
     ( \
        CURRENT_FEATURE_BUNDLE <= FEATURE_BUNDLE_511 \
         FEATURE_IS_ENABLED("refaliasing") \
     )
 
-#define FEATURE_LEXSUBS_IS_ENABLED \
-    ( \
-       CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \
-        FEATURE_IS_ENABLED("lexsubs") \
-    )
-
 #define FEATURE_POSTDEREF_QQ_IS_ENABLED \
     ( \
        CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_523 \
index 19db404..fe13aae 100644 (file)
@@ -1941,12 +1941,11 @@ my($a, $b, $c) = @_;
 ####
 # SKIP ?$] < 5.017004 && "lexical subs not implemented on this Perl version"
 # lexical subroutine
-use feature 'lexical_subs';
+# CONTEXT use feature 'lexical_subs';
 no warnings "experimental::lexical_subs";
 my sub f {}
 print f();
 >>>>
-use feature 'lexical_subs';
 BEGIN {${^WARNING_BITS} = "\x54\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x55\x55\x15"}
 my sub f {
     BEGIN {${^WARNING_BITS} = "\x54\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x55\x15"}
@@ -1957,20 +1956,17 @@ print f();
 ####
 # SKIP ?$] < 5.017004 && "lexical subs not implemented on this Perl version"
 # lexical "state" subroutine
-use feature 'state', 'lexical_subs';
+# CONTEXT use feature 'state', 'lexical_subs';
 no warnings 'experimental::lexical_subs';
 state sub f {}
 print f();
 >>>>
-use feature 'lexical_subs';
 BEGIN {${^WARNING_BITS} = "\x54\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x55\x55\x15"}
-CORE::state sub f {
+state sub f {
     BEGIN {${^WARNING_BITS} = "\x54\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x55\x15"}
-    use feature 'state';
     
 }
 BEGIN {${^WARNING_BITS} = "\x54\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x55\x15"}
-use feature 'state';
 print f();
 ####
 # SKIP ?$] < 5.017004 && "lexical subs not implemented on this Perl version"
index f197f48..caa7326 100644 (file)
@@ -14,12 +14,10 @@ our %feature = (
     switch          => 'feature_switch',
     bitwise         => 'feature_bitwise',
     evalbytes       => 'feature_evalbytes',
-    postderef       => 'feature_postderef',
     array_base      => 'feature_arybase',
     signatures      => 'feature_signatures',
     current_sub     => 'feature___SUB__',
     refaliasing     => 'feature_refaliasing',
-    lexical_subs    => 'feature_lexsubs',
     postderef_qq    => 'feature_postderef_qq',
     unicode_eval    => 'feature_unieval',
     unicode_strings => 'feature_unicode',
@@ -30,7 +28,7 @@ our %feature_bundle = (
     "5.11"    => [qw(array_base say state switch unicode_strings)],
     "5.15"    => [qw(current_sub evalbytes fc say state switch unicode_eval unicode_strings)],
     "5.23"    => [qw(current_sub evalbytes fc postderef_qq say state switch unicode_eval unicode_strings)],
-    "all"     => [qw(array_base bitwise current_sub evalbytes fc lexical_subs postderef postderef_qq refaliasing say signatures state switch unicode_eval unicode_strings)],
+    "all"     => [qw(array_base bitwise current_sub evalbytes fc postderef_qq refaliasing say signatures state switch unicode_eval unicode_strings)],
     "default" => [qw(array_base)],
 );
 
@@ -48,6 +46,10 @@ $feature_bundle{"5.24"} = $feature_bundle{"5.23"};
 $feature_bundle{"5.25"} = $feature_bundle{"5.23"};
 $feature_bundle{"5.26"} = $feature_bundle{"5.23"};
 $feature_bundle{"5.9.5"} = $feature_bundle{"5.10"};
+my %noops = (
+    postderef => 1,
+    lexical_subs => 1,
+);
 
 our $hint_shift   = 26;
 our $hint_mask    = 0x1c000000;
@@ -497,6 +499,9 @@ sub __common {
             next;
         }
         if (!exists $feature{$name}) {
+            if (exists $noops{$name}) {
+                next;
+            }
             unknown_feature($name);
         }
        if ($import) {
index 0672ff6..e8ecece 100755 (executable)
@@ -27,11 +27,9 @@ my %feature = (
     switch          => 'switch',
     bitwise         => 'bitwise',
     evalbytes       => 'evalbytes',
-    postderef       => 'postderef',
     array_base      => 'arybase',
     current_sub     => '__SUB__',
     refaliasing     => 'refaliasing',
-    lexical_subs    => 'lexsubs',
     postderef_qq    => 'postderef_qq',
     unicode_eval    => 'unieval',
     unicode_strings => 'unicode',
@@ -65,6 +63,8 @@ my %feature_bundle = (
                    evalbytes current_sub fc postderef_qq)],
 );
 
+my @noops = qw( postderef lexical_subs );
+
 
 ###########################################################################
 # More data generated from the above
@@ -186,6 +186,10 @@ for (sort keys %Aliases) {
        qq'\$feature_bundle{"$_"} = \$feature_bundle{"$Aliases{$_}"};\n';
 };
 
+print $pm "my \%noops = (\n";
+print $pm "    $_ => 1,\n", for @noops;
+print $pm ");\n";
+
 print $pm <<EOPM;
 
 our \$hint_shift   = $HintShift;
@@ -778,6 +782,9 @@ sub __common {
             next;
         }
         if (!exists $feature{$name}) {
+            if (exists $noops{$name}) {
+                next;
+            }
             unknown_feature($name);
         }
        if ($import) {