summaryrefslogtreecommitdiff
path: root/op.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-08-18 22:09:17 -0700
committerFather Chrysostomos <sprout@cpan.org>2011-08-24 23:37:59 -0700
commit1e4b6aa1907f271ce023ffe6f03439e2ce7f65dc (patch)
tree66d2f60ccc3e423a6fd77021258a20e81ebfcefc /op.c
parent46e00a91c0fa7d86de7f65504ba0a402c422d58b (diff)
downloadperl-1e4b6aa1907f271ce023ffe6f03439e2ce7f65dc.tar.gz
Move coresub op-creation from gv.c to op.c
For functions that take handles as arguments, this code will need to call static functions in op.c, like is_handle_constructor. While we could make is_handle_constructor into a non-static function and call it from gv.c, that seems backwards, as it would result in a lot of op-manipulation code in the middle of gv.c. So this commit creates a new function in op.c, called coresub_op, which is only called from gv.c, from the &CORE::sub code.
Diffstat (limited to 'op.c')
-rw-r--r--op.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/op.c b/op.c
index d68389faab..74d27dd4f4 100644
--- a/op.c
+++ b/op.c
@@ -10326,6 +10326,44 @@ Perl_core_prototype(pTHX_ SV *sv, const char *name, const int code,
return sv;
}
+OP *
+Perl_coresub_op(pTHX_ SV * const coreargssv, const int code,
+ const int opnum)
+{
+ OP * const argop = newSVOP(OP_COREARGS,0,coreargssv);
+
+ PERL_ARGS_ASSERT_CORESUB_OP;
+
+ switch(opnum) {
+ case 0:
+ {
+ IV index = 0;
+ switch(-code) {
+ case KEY___FILE__ : index = 1; break;
+ case KEY___LINE__ : index = 2; break;
+ }
+ return op_append_elem(OP_LINESEQ,
+ argop,
+ newSLICEOP(0,
+ newSVOP(OP_CONST, 0, newSViv(index)),
+ newOP(OP_CALLER,0)
+ )
+ );
+ }
+ default:
+ switch (PL_opargs[opnum] & OA_CLASS_MASK) {
+ case OA_BASEOP:
+ return op_append_elem(
+ OP_LINESEQ, argop,
+ newOP(opnum,
+ opnum == OP_WANTARRAY ? OPpOFFBYONE << 8 : 0)
+ );
+ default:
+ return newUNOP(opnum,0,argop);
+ }
+ }
+}
+
#include "XSUB.h"
/* Efficient sub that returns a constant scalar value. */