Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create defer syntax and OP_PUSHDEFER opcode (RFC 0004) #19019

Merged
merged 1 commit into from Aug 25, 2021

Conversation

leonerd
Copy link
Contributor

@leonerd leonerd commented Aug 3, 2021

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.

This PR relates to RFC 0004 - https://github.com/Perl/RFCs/blob/master/rfcs/rfc0004.md

@leonerd leonerd force-pushed the defer branch 3 times, most recently from cc297fe to 33b620f Compare August 23, 2021 17:03
invoke_defer_block(pTHX_ void *_arg)
{
OP *start = (OP *)_arg;
I32 was_cxstack_ix = cxstack_ix;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this variable is unused in non-DEBUGGING builds

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahyes. Now fixed in a488435. (I'll squash before merging)

@tonycoz
Copy link
Contributor

tonycoz commented Aug 25, 2021

Except for the unused variable, it looks good to me.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants