summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-08-24 09:09:58 -0700
committerFather Chrysostomos <sprout@cpan.org>2011-08-26 12:43:13 -0700
commitc72a562989087cf45b7abfdbbfb4a823adac1604 (patch)
treeee17c214b370828ec404011e889a3c7958aa632f /pp.c
parentd3e26383b699ba248aece0da481bcd07d3e4aa60 (diff)
downloadperl-c72a562989087cf45b7abfdbbfb4a823adac1604.tar.gz
&CORE::lock()
This commit allows &CORE::lock to be called through references and via ampersand syntax. It adds code to pp_coreargs for handling the OA_SCALARREF case, though what it adds is currently lock-specific. (Subsequent commits will address that.) Since lock returns the scalar passed to it, not a copy, &CORE::lock needs to use op_leavesublv, rather than op_leavesub. But it can’t be an lvalue sub, as &CORE::lock = 3 should be disallowed. So we use the sneaky trick of turning on the lvalue flag before attaching the op tree to the sub (which causes newATTRSUB to use op_leavesublv), and then turning it off afterwards.
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/pp.c b/pp.c
index de2b35c2c5..fd17bc1299 100644
--- a/pp.c
+++ b/pp.c
@@ -6109,6 +6109,18 @@ PP(pp_coreargs)
));
}
break;
+ case OA_SCALARREF:
+ if (!svp || !*svp || !SvROK(*svp)
+ || SvTYPE(SvRV(*svp)) > SVt_PVCV
+ )
+ DIE(aTHX_
+ /* diag_listed_as: Type of arg %d to &CORE::%s must be %s*/
+ "Type of arg %d to &CORE::%s must be reference to one of "
+ "[$@%%&*]",
+ whicharg, OP_DESC(PL_op->op_next)
+ );
+ PUSHs(SvRV(*svp));
+ break;
default:
DIE(aTHX_ "panic: unknown OA_*: %x", (unsigned)(oa&7));
}