diff options
author | David Mitchell <davem@iabyn.com> | 2015-10-02 17:28:00 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2016-02-03 08:59:39 +0000 |
commit | b95eccd3c957974356edd3c076146c996d76431d (patch) | |
tree | 8e843bea3c515fcb3faee44d317eaab1e9261a67 /cop.h | |
parent | bb3300d13ef3aaac93877cf6868160413dd618fa (diff) | |
download | perl-b95eccd3c957974356edd3c076146c996d76431d.tar.gz |
pp_given: avoid using savestack for old var
Add a new field, defsv_save, to struct block_givwhen, and use this
to save the previous $_ in 'when(expr)' rather than saving it on the save
stack.
Also add POPWHEN and POPGIVEN macros. The former is a no-op for now.
Diffstat (limited to 'cop.h')
-rw-r--r-- | cop.h | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -836,12 +836,23 @@ struct block_loop { /* given/when context */ struct block_givwhen { OP *leave_op; + SV *defsv_save; /* the original $_ */ }; -#define PUSHGIVEN(cx) \ +#define PUSHWHEN(cx) \ cx->blk_givwhen.leave_op = cLOGOP->op_other; -#define PUSHWHEN PUSHGIVEN +#define PUSHGIVEN(cx, orig_var) \ + PUSHWHEN(cx); \ + cx->blk_givwhen.defsv_save = orig_var; + +#define POPWHEN(cx) \ + NOOP; + +#define POPGIVEN(cx) \ + SvREFCNT_dec(GvSV(PL_defgv)); \ + GvSV(PL_defgv) = cx->blk_givwhen.defsv_save; + /* context common to subroutines, evals and loops */ struct block { |