From c931b03652afbc6f3525df91e6f1b821bf7c9fe3 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Thu, 25 Aug 2011 09:50:02 -0700 Subject: Allow ampersand calls for CORE subs with $*$$**$ protos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This enables ampersand calls and calls through references for CORE subs that have * and $ in their prototypes and a fixed number of arguments. Usually, the *-prototyped ops have their child ops wrapped in rv2gv’s (*{}) implicitly. The rv2gv op is sometimes flagged as an autoviv- ificatory op, such as the first argument to accept() or open(). S_is_handle_constructor contains the list of ops that turn on that flag. This commit makes the coreargs op use a couple of flags to serve the same purpose. pp_coreargs itself calls S_rv2gv (split out from pp_rv2gv recently for precisely this purpose) with arguments based on its own flags. Currently the autovivified glob gets a name like main::_GEN_0 instead of main::$a. I think we can live with that. --- op.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'op.c') diff --git a/op.c b/op.c index 4577bcc54f..606e086825 100644 --- a/op.c +++ b/op.c @@ -10332,6 +10332,7 @@ Perl_coresub_op(pTHX_ SV * const coreargssv, const int code, const int opnum) { OP * const argop = newSVOP(OP_COREARGS,0,coreargssv); + OP *o; PERL_ARGS_ASSERT_CORESUB_OP; @@ -10353,9 +10354,16 @@ Perl_coresub_op(pTHX_ SV * const coreargssv, const int code, opnum == OP_WANTARRAY ? OPpOFFBYONE << 8 : 0) ); case OA_BASEOP_OR_UNOP: - return newUNOP(opnum,0,argop); + o = newUNOP(opnum,0,argop); + onearg: + if (is_handle_constructor(o, 1)) + argop->op_private |= OPpCOREARGS_DEREF1; + return o; default: - return convert(opnum,0,argop); + o = convert(opnum,0,argop); + if (is_handle_constructor(o, 2)) + argop->op_private |= OPpCOREARGS_DEREF2; + goto onearg; } } } -- cgit v1.2.1