diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-08-19 08:27:14 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-08-24 23:46:36 -0700 |
commit | 527d644b124fe2e8dfe6e07204f8b22f7a7ab83d (patch) | |
tree | d8f18a6e9b694d9b49fdcf95bd3bbf29810822f7 /op.c | |
parent | c2f605db621edfb16309200bbba8ced984d34476 (diff) | |
download | perl-527d644b124fe2e8dfe6e07204f8b22f7a7ab83d.tar.gz |
Enable ampersand calls to CORE subs with $$$ prototypes
This applies to functions that just take plain scalar arguments, all
of which are mandatory. Functions that take optional arguments are
not supported yet. truncate() is not supported yet, either (its $$
prototype is not entirely veracious).
This commit enables those functions to be called via &CORE::foo() syn-
tax or through references.
You can now encrypt a string like this: "string"->CORE::crypt($salt).
Each function’s op tree is like this:
$ ./perl -Ilib -MO=Concise,CORE::atan2 -e 'BEGIN{\&CORE::atan2}'
CORE::atan2:
3 <1> leavesub[1 ref] K/REFC,1 ->(end)
2 <@> atan2[t1] sK ->3
- <0> ex-pushmark s ->1
1 <$> coreargs(IV 100) s ->2
-e syntax OK
This commit adds code to ck_fun to skip the argument check if
coresubs is present. Otherwise we get a ‘Not enough arguments for
atan2’ error.
Diffstat (limited to 'op.c')
-rw-r--r-- | op.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -7685,6 +7685,7 @@ Perl_ck_fun(pTHX_ OP *o) tokid = &kid->op_sibling; kid = kid->op_sibling; } + if (kid && kid->op_type == OP_COREARGS) return o; while (oa) { if (oa & OA_OPTIONAL || (oa & 7) == OA_LIST) { @@ -10351,8 +10352,10 @@ Perl_coresub_op(pTHX_ SV * const coreargssv, const int code, newOP(opnum, opnum == OP_WANTARRAY ? OPpOFFBYONE << 8 : 0) ); - default: + case OA_BASEOP_OR_UNOP: return newUNOP(opnum,0,argop); + default: + return convert(opnum,0,argop); } } } |