Skip to content

Commit 194bb98

Browse files
committed
ParseXS: refactor: rm xsub_stack_was_reset field
Remove the following field from the ExtUtils::ParseXS class: xsub_stack_was_reset and replace it with this new field in the ExtUtils::ParseXS::Node::output_part class: stack_was_reset
1 parent 0f55cf9 commit 194bb98

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS.pm

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,6 @@ BEGIN {
253253
# (such as '<=>') to a boolean indicating
254254
# whether that method has been listed by
255255
# OVERLOAD (for duplicate spotting).
256-
257-
# Per-XSUB code-emitting state:
258-
259-
'xsub_stack_was_reset', # An XSprePUSH was emitted, so return values
260-
# should be PUSHed rather than just set.
261256
);
262257

263258
# do 'use fields', except: fields needs Hash::Util which is XS, which

dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Node.pm

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,7 +1512,7 @@ sub as_output_code {
15121512
# OUTPUT:
15131513
# RETVAL output_code
15141514
print "\t$output_code\n";
1515-
print "\t++SP;\n" if $pxs->{xsub_stack_was_reset};
1515+
print "\t++SP;\n" if $xbody->{output_part}{stack_was_reset};
15161516
return;
15171517
}
15181518

@@ -1737,7 +1737,7 @@ sub as_output_code {
17371737
}
17381738

17391739
print @lines;
1740-
print "\t++SP;\n" if $pxs->{xsub_stack_was_reset};
1740+
print "\t++SP;\n" if $xbody->{output_part}{stack_was_reset};
17411741
}
17421742

17431743

@@ -2365,8 +2365,6 @@ sub parse {
23652365

23662366
$self->SUPER::parse($pxs); # set file/line_no
23672367

2368-
$pxs->{xsub_stack_was_reset} = 0; # XSprePUSH not yet emitted
2369-
23702368
# Process any implicit INPUT section.
23712369
{
23722370
my $input = ExtUtils::ParseXS::Node::INPUT->new();
@@ -2587,6 +2585,9 @@ BEGIN { $build_subclass->('', # parent
25872585

25882586
'targ_used', # Bool: the TARG has been allocated for this body,
25892587
# so is no longer available for use.
2588+
2589+
'stack_was_reset', # Bool: An XSprePUSH was emitted, so return values
2590+
# should be PUSHed rather than just set.
25902591
)};
25912592

25922593

@@ -2621,6 +2622,9 @@ sub as_code {
26212622
# TARG is available for use within this body.
26222623
$self->{targ_used} = 0;
26232624

2625+
# SP still pointing at top arg
2626+
$self->{stack_was_reset} = 0;
2627+
26242628
if ($self->{kids}) {
26252629
$_->as_code($pxs, $xsub, $xbody) for @{$self->{kids}};
26262630
}
@@ -2658,7 +2662,7 @@ sub as_code {
26582662
# If there are any OUTLIST vars to be returned, we reset SP to
26592663
# the base of the stack frame and then PUSH any return values.
26602664
print "\tXSprePUSH;\n";
2661-
$pxs->{xsub_stack_was_reset} = 1;
2665+
$self->{stack_was_reset} = 1;
26622666
}
26632667

26642668
# Extend the stack if we're going to return more values than were

0 commit comments

Comments
 (0)