diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-08-25 09:50:02 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-08-25 09:50:02 -0700 |
commit | c931b03652afbc6f3525df91e6f1b821bf7c9fe3 (patch) | |
tree | 517008b87b4b6b8f94936681a51531ac04ef95d4 /op.c | |
parent | e664e0a4d2b36e9c34f1d617414f811f59792c9b (diff) | |
download | perl-c931b03652afbc6f3525df91e6f1b821bf7c9fe3.tar.gz |
Allow ampersand calls for CORE subs with $*$$**$ protos
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.
Diffstat (limited to 'op.c')
-rw-r--r-- | op.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -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; } } } |