This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Create `defer` syntax and `OP_PUSHDEFER` opcode
authorPaul "LeoNerd" Evans <leonerd@leonerd.org.uk>
Tue, 27 Jul 2021 13:55:14 +0000 (14:55 +0100)
committerPaul Evans <leonerd@leonerd.org.uk>
Wed, 25 Aug 2021 12:52:09 +0000 (13:52 +0100)
commitf79e2ff95fbb22eaf18e130c7cba8a9d40be3d75
tree18bedb48e757671114f8f63c8691677a06b62a1b
parent4b21956ed64a9303ab72a46be1cd68c22bff2560
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.
42 files changed:
MANIFEST
cop.h
embed.fnc
embed.h
ext/Opcode/Opcode.pm
feature.h
gv.c
keywords.c
keywords.h
lib/B/Deparse-core.t
lib/B/Deparse.pm
lib/B/Deparse.t
lib/B/Op_private.pm
lib/feature.pm
lib/warnings.pm
op.c
opcode.h
opnames.h
perl.h
perly.act
perly.h
perly.tab
perly.y
pod/perldelta.pod
pod/perldiag.pod
pod/perlmod.pod
pod/perlsyn.pod
pp_ctl.c
pp_proto.h
proto.h
regen/feature.pl
regen/keywords.pl
regen/opcodes
regen/warnings.pl
scope.c
sv.c
t/op/coreamp.t
t/op/coresubs.t
t/op/defer.t [new file with mode: 0644]
t/perf/opcount.t
toke.c
warnings.h