summaryrefslogtreecommitdiff
path: root/keywords.c
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 /keywords.c
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 'keywords.c')
-rw-r--r--keywords.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/keywords.c b/keywords.c
index 624debc80a..e06ada4b3e 100644
--- a/keywords.c
+++ b/keywords.c
@@ -978,7 +978,7 @@ Perl_keyword (pTHX_ const char *name, I32 len, bool all_keywords)
goto unknown;
}
- case 5: /* 40 tokens of length 5 */
+ case 5: /* 41 tokens of length 5 */
switch (name[0])
{
case 'B':
@@ -1142,6 +1142,17 @@ Perl_keyword (pTHX_ const char *name, I32 len, bool all_keywords)
goto unknown;
}
+ case 'd':
+ if (name[1] == 'e' &&
+ name[2] == 'f' &&
+ name[3] == 'e' &&
+ name[4] == 'r')
+ { /* defer */
+ return (all_keywords || FEATURE_DEFER_IS_ENABLED ? KEY_defer : 0);
+ }
+
+ goto unknown;
+
case 'e':
if (name[1] == 'l' &&
name[2] == 's' &&
@@ -3475,5 +3486,5 @@ unknown:
}
/* Generated from:
- * 3a4f2004642b00b871c01cbdc018f6ca5ead6b4e0b2b184120c60b0b62a229dd regen/keywords.pl
+ * de1ee232f68ea8ae75d09f4f70b58fee8a6e6244dec3ab68baab54f7af9ce306 regen/keywords.pl
* ex: set ro: */