summaryrefslogtreecommitdiff
path: root/regen
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <leonerd@leonerd.org.uk>2021-07-27 14:55:14 +0100
committerPaul Evans <leonerd@leonerd.org.uk>2021-08-25 13:52:09 +0100
commitf79e2ff95fbb22eaf18e130c7cba8a9d40be3d75 (patch)
tree18bedb48e757671114f8f63c8691677a06b62a1b /regen
parent4b21956ed64a9303ab72a46be1cd68c22bff2560 (diff)
downloadperl-f79e2ff95fbb22eaf18e130c7cba8a9d40be3d75.tar.gz
Create `defer` syntax and `OP_PUSHDEFER` opcode
Adds syntax `defer { BLOCK }` to create a deferred block; code that is deferred until the scope exits. This syntax is guarded by use feature 'defer'; Adds a new opcode, `OP_PUSHDEFER`, which is a LOGOP whose `op_other` field gives the start of an optree to be deferred until scope exit. That op pointer will be stored on the save stack and invoked as part of scope unwind. Included is support for `B::Deparse` to deparse the optree back into syntax.
Diffstat (limited to 'regen')
-rwxr-xr-xregen/feature.pl9
-rwxr-xr-xregen/keywords.pl2
-rw-r--r--regen/opcodes1
-rw-r--r--regen/warnings.pl4
4 files changed, 14 insertions, 2 deletions
diff --git a/regen/feature.pl b/regen/feature.pl
index 79f789a96d..a07986e38a 100755
--- a/regen/feature.pl
+++ b/regen/feature.pl
@@ -41,6 +41,7 @@ my %feature = (
multidimensional => 'multidimensional',
bareword_filehandles => 'bareword_filehandles',
try => 'try',
+ defer => 'defer',
);
# NOTE: If a feature is ever enabled in a non-contiguous range of Perl
@@ -481,7 +482,7 @@ read_only_bottom_close_and_rename($h);
__END__
package feature;
-our $VERSION = '1.67';
+our $VERSION = '1.68';
FEATURES
@@ -838,6 +839,12 @@ C<try> are caught by executing the body of the C<catch> block.
For more information, see L<perlsyn/"Try Catch Exception Handling">.
+=head2 The 'defer' feature
+
+This feature enables the C<defer> block syntax, which allows a block of code
+to be deferred until when the flow of control leaves the block which contained
+it. For more details, see L<perlsyn/defer>.
+
=head1 FEATURE BUNDLES
It's possible to load multiple features together, using
diff --git a/regen/keywords.pl b/regen/keywords.pl
index 77f8aa9d93..ace205efb5 100755
--- a/regen/keywords.pl
+++ b/regen/keywords.pl
@@ -49,6 +49,7 @@ my %feature_kw = (
isa => 'isa',
try => 'try',
catch => 'try',
+ defer => 'defer',
);
my %pos = map { ($_ => 1) } @{$by_strength{'+'}};
@@ -152,6 +153,7 @@ __END__
-dbmclose
-dbmopen
+default
++defer
+defined
+delete
-die
diff --git a/regen/opcodes b/regen/opcodes
index 6a3f8db024..0192f1c804 100644
--- a/regen/opcodes
+++ b/regen/opcodes
@@ -582,3 +582,4 @@ entertrycatch try {block} ck_trycatch |
leavetrycatch try {block} exit ck_null @
poptry pop try ck_null @
catch catch {} block ck_null |
+pushdefer push defer {} block ck_null |
diff --git a/regen/warnings.pl b/regen/warnings.pl
index 056851f592..3d128449a4 100644
--- a/regen/warnings.pl
+++ b/regen/warnings.pl
@@ -16,7 +16,7 @@
#
# This script is normally invoked from regen.pl.
-$VERSION = '1.53';
+$VERSION = '1.54';
BEGIN {
require './regen/regen_lib.pl';
@@ -119,6 +119,8 @@ my $tree = {
[ 5.031, DEFAULT_ON ],
'experimental::try' =>
[ 5.033, DEFAULT_ON ],
+ 'experimental::defer' =>
+ [ 5.035, DEFAULT_ON ],
}],
'missing' => [ 5.021, DEFAULT_OFF],