summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2016-05-16 18:15:42 -0700
committerFather Chrysostomos <sprout@cpan.org>2016-05-20 22:13:42 -0700
commit881018827f9961cf5132d9243259ca1e9e2c0330 (patch)
tree885e428d1f49352fc3bdd25da66ac304fff72906
parentd88ca568f0ba6af079816962f37e415fd773f90e (diff)
downloadperl-881018827f9961cf5132d9243259ca1e9e2c0330.tar.gz
Add avhvswitch op
&CORE::keys() et al. will use this to switch between keys and akeys depending on the argument type.
-rw-r--r--ext/Opcode/Opcode.pm2
-rw-r--r--lib/B/Op_private.pm1
-rw-r--r--opcode.h9
-rw-r--r--opnames.h25
-rw-r--r--pp.c6
-rw-r--r--pp_proto.h1
-rw-r--r--regen/opcodes1
7 files changed, 31 insertions, 14 deletions
diff --git a/ext/Opcode/Opcode.pm b/ext/Opcode/Opcode.pm
index 1522c4c378..2c5e2a207f 100644
--- a/ext/Opcode/Opcode.pm
+++ b/ext/Opcode/Opcode.pm
@@ -338,7 +338,7 @@ invert_opset function.
warn die lineseq nextstate scope enter leave
- rv2cv anoncode prototype coreargs anonconst
+ rv2cv anoncode prototype coreargs avhvswitch anonconst
entersub leavesub leavesublv return method method_named
method_super method_redir method_redir_super
diff --git a/lib/B/Op_private.pm b/lib/B/Op_private.pm
index 79a7e9ee4e..c4916efd24 100644
--- a/lib/B/Op_private.pm
+++ b/lib/B/Op_private.pm
@@ -245,6 +245,7 @@ $bits{anonconst}{0} = $bf[0];
@{$bits{atan2}}{3,2,1,0} = ($bf[3], $bf[3], $bf[3], $bf[3]);
$bits{av2arylen}{0} = $bf[0];
$bits{avalues}{0} = $bf[0];
+$bits{avhvswitch}{0} = $bf[0];
$bits{backtick}{0} = $bf[0];
@{$bits{bind}}{3,2,1,0} = ($bf[3], $bf[3], $bf[3], $bf[3]);
@{$bits{binmode}}{3,2,1,0} = ($bf[3], $bf[3], $bf[3], $bf[3]);
diff --git a/opcode.h b/opcode.h
index 965abe2133..0a37dfcd4d 100644
--- a/opcode.h
+++ b/opcode.h
@@ -528,6 +528,7 @@ EXTCONST char* const PL_op_name[] = {
"once",
"custom",
"coreargs",
+ "avhvswitch",
"runcv",
"fc",
"padcv",
@@ -929,6 +930,7 @@ EXTCONST char* const PL_op_desc[] = {
"once",
"unknown custom operator",
"CORE:: subroutine",
+ "Array/hash switch",
"__SUB__",
"fc",
"private subroutine",
@@ -1344,6 +1346,7 @@ EXT Perl_ppaddr_t PL_ppaddr[] /* or perlvars.h */
Perl_pp_once,
Perl_pp_custom, /* implemented by Perl_unimplemented_op */
Perl_pp_coreargs,
+ Perl_pp_avhvswitch,
Perl_pp_runcv,
Perl_pp_fc,
Perl_pp_padcv,
@@ -1755,6 +1758,7 @@ EXT Perl_check_t PL_check[] /* or perlvars.h */
Perl_ck_null, /* once */
Perl_ck_null, /* custom */
Perl_ck_null, /* coreargs */
+ Perl_ck_null, /* avhvswitch */
Perl_ck_null, /* runcv */
Perl_ck_fun, /* fc */
Perl_ck_null, /* padcv */
@@ -2160,6 +2164,7 @@ EXTCONST U32 PL_opargs[] = {
0x00000300, /* once */
0x00000000, /* custom */
0x00000600, /* coreargs */
+ 0x00000108, /* avhvswitch */
0x00000004, /* runcv */
0x00009b8e, /* fc */
0x00000040, /* padcv */
@@ -2797,6 +2802,7 @@ EXTCONST I16 PL_op_private_bitdef_ix[] = {
0, /* once */
-1, /* custom */
181, /* coreargs */
+ 0, /* avhvswitch */
3, /* runcv */
0, /* fc */
-1, /* padcv */
@@ -2826,7 +2832,7 @@ EXTCONST I16 PL_op_private_bitdef_ix[] = {
*/
EXTCONST U16 PL_op_private_bitdefs[] = {
- 0x0003, /* scalar, prototype, refgen, srefgen, ref, readline, regcmaybe, regcreset, regcomp, chop, schop, defined, undef, study, preinc, i_preinc, predec, i_predec, postinc, i_postinc, postdec, i_postdec, negate, i_negate, not, complement, ucfirst, lcfirst, uc, lc, quotemeta, aeach, avalues, each, values, pop, shift, grepstart, grepwhile, mapstart, mapwhile, range, and, or, dor, andassign, orassign, dorassign, method, method_named, method_super, method_redir, method_redir_super, entergiven, leavegiven, enterwhen, leavewhen, untie, tied, dbmclose, getsockname, getpeername, lstat, stat, readlink, readdir, telldir, rewinddir, closedir, localtime, alarm, require, dofile, entertry, ghbyname, gnbyname, gpbyname, shostent, snetent, sprotoent, sservent, gpwnam, gpwuid, ggrnam, ggrgid, lock, once, fc, anonconst */
+ 0x0003, /* scalar, prototype, refgen, srefgen, ref, readline, regcmaybe, regcreset, regcomp, chop, schop, defined, undef, study, preinc, i_preinc, predec, i_predec, postinc, i_postinc, postdec, i_postdec, negate, i_negate, not, complement, ucfirst, lcfirst, uc, lc, quotemeta, aeach, avalues, each, values, pop, shift, grepstart, grepwhile, mapstart, mapwhile, range, and, or, dor, andassign, orassign, dorassign, method, method_named, method_super, method_redir, method_redir_super, entergiven, leavegiven, enterwhen, leavewhen, untie, tied, dbmclose, getsockname, getpeername, lstat, stat, readlink, readdir, telldir, rewinddir, closedir, localtime, alarm, require, dofile, entertry, ghbyname, gnbyname, gpbyname, shostent, snetent, sprotoent, sservent, gpwnam, gpwuid, ggrnam, ggrgid, lock, once, avhvswitch, fc, anonconst */
0x2b5c, 0x3d59, /* pushmark */
0x00bd, /* wantarray, runcv */
0x03b8, 0x17f0, 0x3e0c, 0x38c8, 0x2f25, /* const */
@@ -3278,6 +3284,7 @@ EXTCONST U8 PL_op_private_valid[] = {
/* ONCE */ (OPpARG1_MASK),
/* CUSTOM */ (0xff),
/* COREARGS */ (OPpCOREARGS_DEREF1|OPpCOREARGS_DEREF2|OPpCOREARGS_SCALARMOD|OPpCOREARGS_PUSHMARK),
+ /* AVHVSWITCH */ (OPpARG1_MASK),
/* RUNCV */ (OPpOFFBYONE),
/* FC */ (OPpARG1_MASK),
/* PADCV */ (0),
diff --git a/opnames.h b/opnames.h
index 65ccab6967..99b19d0b99 100644
--- a/opnames.h
+++ b/opnames.h
@@ -396,21 +396,22 @@ typedef enum opcode {
OP_ONCE = 379,
OP_CUSTOM = 380,
OP_COREARGS = 381,
- OP_RUNCV = 382,
- OP_FC = 383,
- OP_PADCV = 384,
- OP_INTROCV = 385,
- OP_CLONECV = 386,
- OP_PADRANGE = 387,
- OP_REFASSIGN = 388,
- OP_LVREF = 389,
- OP_LVREFSLICE = 390,
- OP_LVAVREF = 391,
- OP_ANONCONST = 392,
+ OP_AVHVSWITCH = 382,
+ OP_RUNCV = 383,
+ OP_FC = 384,
+ OP_PADCV = 385,
+ OP_INTROCV = 386,
+ OP_CLONECV = 387,
+ OP_PADRANGE = 388,
+ OP_REFASSIGN = 389,
+ OP_LVREF = 390,
+ OP_LVREFSLICE = 391,
+ OP_LVAVREF = 392,
+ OP_ANONCONST = 393,
OP_max
} opcode;
-#define MAXO 393
+#define MAXO 394
#define OP_FREED MAXO
/* the OP_IS_* macros are optimized to a simple range check because
diff --git a/pp.c b/pp.c
index 1db39be0b0..36f7a4f5e5 100644
--- a/pp.c
+++ b/pp.c
@@ -6380,6 +6380,12 @@ PP(pp_coreargs)
RETURN;
}
+PP(pp_avhvswitch)
+{
+ dSP;
+ RETURN;
+}
+
PP(pp_runcv)
{
dSP;
diff --git a/pp_proto.h b/pp_proto.h
index 17241d38ea..fd54df8e45 100644
--- a/pp_proto.h
+++ b/pp_proto.h
@@ -22,6 +22,7 @@ PERL_CALLCONV OP *Perl_pp_anonlist(pTHX);
PERL_CALLCONV OP *Perl_pp_aslice(pTHX);
PERL_CALLCONV OP *Perl_pp_atan2(pTHX);
PERL_CALLCONV OP *Perl_pp_av2arylen(pTHX);
+PERL_CALLCONV OP *Perl_pp_avhvswitch(pTHX);
PERL_CALLCONV OP *Perl_pp_backtick(pTHX);
PERL_CALLCONV OP *Perl_pp_bind(pTHX);
PERL_CALLCONV OP *Perl_pp_binmode(pTHX);
diff --git a/regen/opcodes b/regen/opcodes
index fe72fe3918..893deb07da 100644
--- a/regen/opcodes
+++ b/regen/opcodes
@@ -556,6 +556,7 @@ custom unknown custom operator ck_null 0
# For CORE:: subs
coreargs CORE:: subroutine ck_null $
+avhvswitch Array/hash switch ck_null t1
runcv __SUB__ ck_null s0