From c2f605db621edfb16309200bbba8ced984d34476 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Thu, 18 Aug 2011 22:19:25 -0700 Subject: [PATCH] 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. --- keywords.c | 2 +- keywords.h | 2 +- op.c | 13 +++---------- regen/keywords.pl | 4 ++++ 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/keywords.c b/keywords.c index d442b32..b9ef465 100644 --- a/keywords.c +++ b/keywords.c @@ -3399,5 +3399,5 @@ unknown: } /* Generated from: - * 34be1269b3c67c86c758c60794ddba6eadc528e0435f954d514c14a2f1c73a2e regen/keywords.pl + * 6563b55da87af894b79ef9d777217633eee6c7b5f352ff4c17317f562247f5fc regen/keywords.pl * ex: set ro: */ diff --git a/keywords.h b/keywords.h index 4631b67..83ad0ef 100644 --- a/keywords.h +++ b/keywords.h @@ -268,5 +268,5 @@ #define KEY_y 252 /* Generated from: - * 34be1269b3c67c86c758c60794ddba6eadc528e0435f954d514c14a2f1c73a2e regen/keywords.pl + * 6563b55da87af894b79ef9d777217633eee6c7b5f352ff4c17317f562247f5fc regen/keywords.pl * ex: set ro: */ diff --git a/op.c b/op.c index 74d27dd..1ca495c 100644 --- a/op.c +++ b/op.c @@ -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: diff --git a/regen/keywords.pl b/regen/keywords.pl index b286050..5f7f1ef 100755 --- a/regen/keywords.pl +++ b/regen/keywords.pl @@ -101,6 +101,10 @@ END read_only_bottom_close_and_rename($_, [$0]) foreach $c, $h; + +# coresub_op in op.c expects __FILE__, __LINE__ and __PACKAGE__ to be the +# first three. + __END__ NULL -- 2.7.4