Skip to content

class.c: Less cheating when creating accessor method CVs #23539

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

Merged
merged 1 commit into from
Aug 6, 2025

Conversation

leonerd
Copy link
Contributor

@leonerd leonerd commented Aug 4, 2025

The prior code manually constructed the OP_METHSTART op itself, filling in the field binding operations itself and using specially-constructed pad entries to contain fake copies of the field variables. While this technically worked, it will break upcoming code changes, as well as just being a weird special-case snowflake.

The new code imports the real field padname into the compiling pad in a manner much closer to the way real code would, and also sets the CvIsMETHOD flag on PL_compcv, so that the OP_METHSTART op is generated implicitly by newATTRSUB() in the usual way. This avoids keeping two copies of special-case code here in class.c.

  • This set of changes does not require a perldelta entry.

The prior code manually constructed the `OP_METHSTART` op itself,
filling in the field binding operations itself and using
specially-constructed pad entries to contain fake copies of the field
variables. While this technically worked, it will break upcoming code
changes, as well as just being a weird special-case snowflake.

The new code imports the real field padname into the compiling pad in a
manner much closer to the way real code would, and also sets the
`CvIsMETHOD` flag on `PL_compcv`, so that the `OP_METHSTART` op is
generated implicitly by `newATTRSUB()` in the usual way. This avoids
keeping two copies of special-case code here in `class.c`.
@leonerd leonerd merged commit ec78f9b into Perl:blead Aug 6, 2025
34 checks passed
@leonerd leonerd deleted the less-cheating-in-class.c branch August 6, 2025 08:07
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.

2 participants