diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-08-18 22:19:25 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-08-24 23:38:27 -0700 |
commit | c2f605db621edfb16309200bbba8ced984d34476 (patch) | |
tree | cff01a54d0de63402bdd6d7644d45e67f76d9992 /op.c | |
parent | 1e4b6aa1907f271ce023ffe6f03439e2ce7f65dc (diff) | |
download | perl-c2f605db621edfb16309200bbba8ced984d34476.tar.gz |
Simplify the CORE::__FOO__ op-generation code
It just happens that the (caller)[...] offsets for file and line are
the same as the keyword numbers. KEY___PACKAGE__ is 3 and (caller)[0]
returns the package, so keyword_number % 3 can be used for the offset
instead of an unwieldy switch block.
Diffstat (limited to 'op.c')
-rw-r--r-- | op.c | 13 |
1 files changed, 3 insertions, 10 deletions
@@ -10336,20 +10336,13 @@ Perl_coresub_op(pTHX_ SV * const coreargssv, const int code, 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, + return op_append_elem(OP_LINESEQ, argop, newSLICEOP(0, - newSVOP(OP_CONST, 0, newSViv(index)), + newSVOP(OP_CONST, 0, newSViv(-code % 3)), newOP(OP_CALLER,0) ) - ); - } + ); default: switch (PL_opargs[opnum] & OA_CLASS_MASK) { case OA_BASEOP: |