summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2015-01-03 18:50:35 -0800
committerFather Chrysostomos <sprout@cpan.org>2015-01-31 22:03:50 -0800
commit5d01050abccabc9ab4309d80d4b603d68575e0a8 (patch)
treecfb8704e39b55834345de342d99972ce1ea26d52
parent7dd648412d5aa4efd8fb68cc6d58d99d867af2a2 (diff)
downloadperl-5d01050abccabc9ab4309d80d4b603d68575e0a8.tar.gz
Add string- and number-specific bitop types
and also implement the pp functions, though nothing compiles to these ops yet.
-rw-r--r--ext/Opcode/Opcode.pm5
-rw-r--r--lib/B/Op_private.pm12
-rw-r--r--opcode.h64
-rw-r--r--opnames.h596
-rw-r--r--pp.c143
-rw-r--r--pp.h1
-rw-r--r--pp_proto.h6
-rwxr-xr-xregen/opcode.pl2
-rw-r--r--regen/opcodes8
9 files changed, 518 insertions, 319 deletions
diff --git a/ext/Opcode/Opcode.pm b/ext/Opcode/Opcode.pm
index 925b4ab438..c9a3f15f47 100644
--- a/ext/Opcode/Opcode.pm
+++ b/ext/Opcode/Opcode.pm
@@ -318,8 +318,9 @@ invert_opset function.
postdec i_postdec int hex oct abs pow multiply i_multiply
divide i_divide modulo i_modulo add i_add subtract i_subtract
- left_shift right_shift bit_and bit_xor bit_or negate i_negate
- not complement
+ left_shift right_shift bit_and bit_xor bit_or nbit_and
+ nbit_xor nbit_or sbit_and sbit_xor sbit_or negate i_negate not
+ complement ncomplement scomplement
lt i_lt gt i_gt le i_le ge i_ge eq i_eq ne i_ne ncmp i_ncmp
slt sgt sle sge seq sne scmp
diff --git a/lib/B/Op_private.pm b/lib/B/Op_private.pm
index 75317ec70f..03a5a83647 100644
--- a/lib/B/Op_private.pm
+++ b/lib/B/Op_private.pm
@@ -150,7 +150,7 @@ $bits{$_}{7} = 'OPpPV_IS_UTF8' for qw(dump goto last next redo);
$bits{$_}{6} = 'OPpREFCOUNTED' for qw(leave leaveeval leavesub leavesublv leavewrite);
$bits{$_}{6} = 'OPpRUNTIME' for qw(match pushre qr subst substcont);
$bits{$_}{2} = 'OPpSLICEWARNING' for qw(aslice hslice padav padhv rv2av rv2hv);
-$bits{$_}{4} = 'OPpTARGET_MY' for qw(abs add atan2 chdir chmod chomp chown chr chroot complement concat cos crypt divide exec exp flock getpgrp getppid getpriority hex i_add i_divide i_modulo i_multiply i_ncmp i_subtract index int kill left_shift length link log match mkdir modulo multiply oct ord pow push rand rename repeat right_shift rindex rmdir schomp scmp setpgrp setpriority sin sleep split sqrt srand stringify subst subtract symlink system time trans transr unlink unshift utime vec wait waitpid);
+$bits{$_}{4} = 'OPpTARGET_MY' for qw(abs add atan2 chdir chmod chomp chown chr chroot complement concat cos crypt divide exec exp flock getpgrp getppid getpriority hex i_add i_divide i_modulo i_multiply i_ncmp i_subtract index int kill left_shift length link log match mkdir modulo multiply nbit_and nbit_or nbit_xor ncomplement oct ord pow push rand rename repeat right_shift rindex rmdir schomp scmp scomplement setpgrp setpriority sin sleep split sqrt srand stringify subst subtract symlink system time trans transr unlink unshift utime vec wait waitpid);
$bits{$_}{5} = 'OPpTRANS_COMPLEMENT' for qw(trans transr);
$bits{$_}{7} = 'OPpTRANS_DELETE' for qw(trans transr);
$bits{$_}{0} = 'OPpTRANS_FROM_UTF' for qw(trans transr);
@@ -418,7 +418,11 @@ $bits{method_super}{0} = $bf[0];
@{$bits{msgsnd}}{3,2,1,0} = ($bf[3], $bf[3], $bf[3], $bf[3]);
@{$bits{multideref}}{5,4,0} = ('OPpMULTIDEREF_DELETE', 'OPpMULTIDEREF_EXISTS', $bf[0]);
@{$bits{multiply}}{1,0} = ($bf[1], $bf[1]);
+@{$bits{nbit_and}}{1,0} = ($bf[1], $bf[1]);
+@{$bits{nbit_or}}{1,0} = ($bf[1], $bf[1]);
+@{$bits{nbit_xor}}{1,0} = ($bf[1], $bf[1]);
@{$bits{ncmp}}{1,0} = ($bf[1], $bf[1]);
+$bits{ncomplement}{0} = $bf[0];
@{$bits{ne}}{1,0} = ($bf[1], $bf[1]);
$bits{negate}{0} = $bf[0];
$bits{next}{0} = $bf[0];
@@ -476,10 +480,14 @@ $bits{rv2hv}{0} = $bf[0];
@{$bits{rv2sv}}{5,4,0} = ($bf[6], $bf[6], $bf[0]);
$bits{rvalues}{0} = $bf[0];
@{$bits{sassign}}{7,6,1,0} = ('OPpASSIGN_CV_TO_GV', 'OPpASSIGN_BACKWARDS', $bf[1], $bf[1]);
+@{$bits{sbit_and}}{1,0} = ($bf[1], $bf[1]);
+@{$bits{sbit_or}}{1,0} = ($bf[1], $bf[1]);
+@{$bits{sbit_xor}}{1,0} = ($bf[1], $bf[1]);
$bits{scalar}{0} = $bf[0];
$bits{schomp}{0} = $bf[0];
$bits{schop}{0} = $bf[0];
@{$bits{scmp}}{1,0} = ($bf[1], $bf[1]);
+$bits{scomplement}{0} = $bf[0];
@{$bits{seek}}{3,2,1,0} = ($bf[3], $bf[3], $bf[3], $bf[3]);
@{$bits{seekdir}}{3,2,1,0} = ($bf[3], $bf[3], $bf[3], $bf[3]);
@{$bits{select}}{3,2,1,0} = ($bf[3], $bf[3], $bf[3], $bf[3]);
@@ -782,7 +790,7 @@ our %ops_using = (
OPpSORT_DESCEND => [qw(sort)],
OPpSPLIT_IMPLIM => [qw(split)],
OPpSUBSTR_REPL_FIRST => [qw(substr)],
- OPpTARGET_MY => [qw(abs add atan2 chdir chmod chomp chown chr chroot complement concat cos crypt divide exec exp flock getpgrp getppid getpriority hex i_add i_divide i_modulo i_multiply i_ncmp i_subtract index int kill left_shift length link log match mkdir modulo multiply oct ord pow push rand rename repeat right_shift rindex rmdir schomp scmp setpgrp setpriority sin sleep split sqrt srand stringify subst subtract symlink system time trans transr unlink unshift utime vec wait waitpid)],
+ OPpTARGET_MY => [qw(abs add atan2 chdir chmod chomp chown chr chroot complement concat cos crypt divide exec exp flock getpgrp getppid getpriority hex i_add i_divide i_modulo i_multiply i_ncmp i_subtract index int kill left_shift length link log match mkdir modulo multiply nbit_and nbit_or nbit_xor ncomplement oct ord pow push rand rename repeat right_shift rindex rmdir schomp scmp scomplement setpgrp setpriority sin sleep split sqrt srand stringify subst subtract symlink system time trans transr unlink unshift utime vec wait waitpid)],
OPpTRANS_COMPLEMENT => [qw(trans transr)],
);
diff --git a/opcode.h b/opcode.h
index 5d910fd7d1..edb2702b48 100644
--- a/opcode.h
+++ b/opcode.h
@@ -31,6 +31,8 @@
#define Perl_pp_sgt Perl_pp_sle
#define Perl_pp_sge Perl_pp_sle
#define Perl_pp_bit_xor Perl_pp_bit_or
+#define Perl_pp_nbit_xor Perl_pp_nbit_or
+#define Perl_pp_sbit_xor Perl_pp_sbit_or
#define Perl_pp_cos Perl_pp_sin
#define Perl_pp_exp Perl_pp_sin
#define Perl_pp_log Perl_pp_sin
@@ -243,10 +245,18 @@ EXTCONST char* const PL_op_name[] = {
"bit_and",
"bit_xor",
"bit_or",
+ "nbit_and",
+ "nbit_xor",
+ "nbit_or",
+ "sbit_and",
+ "sbit_xor",
+ "sbit_or",
"negate",
"i_negate",
"not",
"complement",
+ "ncomplement",
+ "scomplement",
"smartmatch",
"atan2",
"sin",
@@ -639,10 +649,18 @@ EXTCONST char* const PL_op_desc[] = {
"bitwise and (&)",
"bitwise xor (^)",
"bitwise or (|)",
+ "numeric bitiwse and (&)",
+ "numeric bitwise xor (^)",
+ "numeric bitwise or (|)",
+ "string bitiwse and (&)",
+ "string bitwise xor (^)",
+ "string bitwise or (|)",
"negation (-)",
"integer negation (-)",
"not",
"1's complement (~)",
+ "numeric 1's complement (~)",
+ "string 1's complement (~)",
"smart match",
"atan2",
"sin",
@@ -1049,10 +1067,18 @@ EXT Perl_ppaddr_t PL_ppaddr[] /* or perlvars.h */
Perl_pp_bit_and,
Perl_pp_bit_xor, /* implemented by Perl_pp_bit_or */
Perl_pp_bit_or,
+ Perl_pp_nbit_and,
+ Perl_pp_nbit_xor, /* implemented by Perl_pp_nbit_or */
+ Perl_pp_nbit_or,
+ Perl_pp_sbit_and,
+ Perl_pp_sbit_xor, /* implemented by Perl_pp_sbit_or */
+ Perl_pp_sbit_or,
Perl_pp_negate,
Perl_pp_i_negate,
Perl_pp_not,
Perl_pp_complement,
+ Perl_pp_ncomplement,
+ Perl_pp_scomplement,
Perl_pp_smartmatch,
Perl_pp_atan2,
Perl_pp_sin,
@@ -1455,10 +1481,18 @@ EXT Perl_check_t PL_check[] /* or perlvars.h */
Perl_ck_bitop, /* bit_and */
Perl_ck_bitop, /* bit_xor */
Perl_ck_bitop, /* bit_or */
+ Perl_ck_bitop, /* nbit_and */
+ Perl_ck_bitop, /* nbit_xor */
+ Perl_ck_bitop, /* nbit_or */
+ Perl_ck_bitop, /* sbit_and */
+ Perl_ck_bitop, /* sbit_xor */
+ Perl_ck_bitop, /* sbit_or */
Perl_ck_null, /* negate */
Perl_ck_null, /* i_negate */
Perl_ck_null, /* not */
Perl_ck_bitop, /* complement */
+ Perl_ck_bitop, /* ncomplement */
+ Perl_ck_null, /* scomplement */
Perl_ck_smartmatch, /* smartmatch */
Perl_ck_fun, /* atan2 */
Perl_ck_fun, /* sin */
@@ -1855,10 +1889,18 @@ EXTCONST U32 PL_opargs[] = {
0x0001120e, /* bit_and */
0x0001120e, /* bit_xor */
0x0001120e, /* bit_or */
+ 0x0001121e, /* nbit_and */
+ 0x0001121e, /* nbit_xor */
+ 0x0001121e, /* nbit_or */
+ 0x0001120e, /* sbit_and */
+ 0x0001120e, /* sbit_xor */
+ 0x0001120e, /* sbit_or */
0x0000112e, /* negate */
0x0000110e, /* i_negate */
0x00001106, /* not */
0x0000111e, /* complement */
+ 0x0000111e, /* ncomplement */
+ 0x0000111e, /* scomplement */
0x00000204, /* smartmatch */
0x0001141e, /* atan2 */
0x00009b9e, /* sin */
@@ -2485,10 +2527,18 @@ EXTCONST I16 PL_op_private_bitdef_ix[] = {
12, /* bit_and */
12, /* bit_xor */
12, /* bit_or */
+ 74, /* nbit_and */
+ 74, /* nbit_xor */
+ 74, /* nbit_or */
+ 12, /* sbit_and */
+ 12, /* sbit_xor */
+ 12, /* sbit_or */
0, /* negate */
0, /* i_negate */
0, /* not */
72, /* complement */
+ 72, /* ncomplement */
+ 72, /* scomplement */
12, /* smartmatch */
79, /* atan2 */
72, /* sin */
@@ -2802,7 +2852,7 @@ EXTCONST U16 PL_op_private_bitdefs[] = {
0x03b8, 0x1570, 0x3c8c, 0x3748, 0x2da5, /* const */
0x29dc, 0x2ef9, /* gvsv */
0x13d5, /* gv */
- 0x0067, /* gelem, lt, i_lt, gt, i_gt, le, i_le, ge, i_ge, eq, i_eq, ne, i_ne, ncmp, slt, sgt, sle, sge, seq, sne, bit_and, bit_xor, bit_or, smartmatch, lslice, xor */
+ 0x0067, /* gelem, lt, i_lt, gt, i_gt, le, i_le, ge, i_ge, eq, i_eq, ne, i_ne, ncmp, slt, sgt, sle, sge, seq, sne, bit_and, bit_xor, bit_or, sbit_and, sbit_xor, sbit_or, smartmatch, lslice, xor */
0x29dc, 0x3bd8, 0x0257, /* padsv */
0x29dc, 0x3bd8, 0x2acc, 0x38c9, /* padav */
0x29dc, 0x3bd8, 0x0534, 0x05d0, 0x2acc, 0x38c9, /* padhv */
@@ -2818,8 +2868,8 @@ EXTCONST U16 PL_op_private_bitdefs[] = {
0x0c9c, 0x1dd8, 0x0834, 0x3ef0, 0x3a0c, 0x2168, 0x01e4, 0x0141, /* trans, transr */
0x0adc, 0x0458, 0x0067, /* sassign */
0x0758, 0x2acc, 0x0067, /* aassign */
- 0x3ef0, 0x0003, /* chomp, schomp, complement, sin, cos, exp, log, sqrt, int, hex, oct, abs, length, ord, chr, chroot, rmdir */
- 0x3ef0, 0x0067, /* pow, multiply, i_multiply, divide, i_divide, modulo, i_modulo, add, i_add, subtract, i_subtract, concat, left_shift, right_shift, i_ncmp, scmp */
+ 0x3ef0, 0x0003, /* chomp, schomp, complement, ncomplement, scomplement, sin, cos, exp, log, sqrt, int, hex, oct, abs, length, ord, chr, chroot, rmdir */
+ 0x3ef0, 0x0067, /* pow, multiply, i_multiply, divide, i_divide, modulo, i_modulo, add, i_add, subtract, i_subtract, concat, left_shift, right_shift, i_ncmp, scmp, nbit_and, nbit_xor, nbit_or */
0x1058, 0x3ef0, 0x0067, /* repeat */
0x3ef0, 0x012f, /* stringify, atan2, rand, srand, index, rindex, crypt, push, unshift, flock, chdir, chown, unlink, chmod, utime, rename, link, symlink, mkdir, waitpid, system, exec, kill, getpgrp, setpgrp, getpriority, setpriority, sleep */
0x33f0, 0x2acc, 0x00cb, /* substr */
@@ -2964,10 +3014,18 @@ EXTCONST U8 PL_op_private_valid[] = {
/* BIT_AND */ (OPpARG2_MASK),
/* BIT_XOR */ (OPpARG2_MASK),
/* BIT_OR */ (OPpARG2_MASK),
+ /* NBIT_AND */ (OPpARG2_MASK|OPpTARGET_MY),
+ /* NBIT_XOR */ (OPpARG2_MASK|OPpTARGET_MY),
+ /* NBIT_OR */ (OPpARG2_MASK|OPpTARGET_MY),
+ /* SBIT_AND */ (OPpARG2_MASK),
+ /* SBIT_XOR */ (OPpARG2_MASK),
+ /* SBIT_OR */ (OPpARG2_MASK),
/* NEGATE */ (OPpARG1_MASK),
/* I_NEGATE */ (OPpARG1_MASK),
/* NOT */ (OPpARG1_MASK),
/* COMPLEMENT */ (OPpARG1_MASK|OPpTARGET_MY),
+ /* NCOMPLEMENT */ (OPpARG1_MASK|OPpTARGET_MY),
+ /* SCOMPLEMENT */ (OPpARG1_MASK|OPpTARGET_MY),
/* SMARTMATCH */ (OPpARG2_MASK),
/* ATAN2 */ (OPpARG4_MASK|OPpTARGET_MY),
/* SIN */ (OPpARG1_MASK|OPpTARGET_MY),
diff --git a/opnames.h b/opnames.h
index 013350a765..e68c8ca6a1 100644
--- a/opnames.h
+++ b/opnames.h
@@ -109,303 +109,311 @@ typedef enum opcode {
OP_BIT_AND = 92,
OP_BIT_XOR = 93,
OP_BIT_OR = 94,
- OP_NEGATE = 95,
- OP_I_NEGATE = 96,
- OP_NOT = 97,
- OP_COMPLEMENT = 98,
- OP_SMARTMATCH = 99,
- OP_ATAN2 = 100,
- OP_SIN = 101,
- OP_COS = 102,
- OP_RAND = 103,
- OP_SRAND = 104,
- OP_EXP = 105,
- OP_LOG = 106,
- OP_SQRT = 107,
- OP_INT = 108,
- OP_HEX = 109,
- OP_OCT = 110,
- OP_ABS = 111,
- OP_LENGTH = 112,
- OP_SUBSTR = 113,
- OP_VEC = 114,
- OP_INDEX = 115,
- OP_RINDEX = 116,
- OP_SPRINTF = 117,
- OP_FORMLINE = 118,
- OP_ORD = 119,
- OP_CHR = 120,
- OP_CRYPT = 121,
- OP_UCFIRST = 122,
- OP_LCFIRST = 123,
- OP_UC = 124,
- OP_LC = 125,
- OP_QUOTEMETA = 126,
- OP_RV2AV = 127,
- OP_AELEMFAST = 128,
- OP_AELEMFAST_LEX = 129,
- OP_AELEM = 130,
- OP_ASLICE = 131,
- OP_KVASLICE = 132,
- OP_AEACH = 133,
- OP_AKEYS = 134,
- OP_AVALUES = 135,
- OP_EACH = 136,
- OP_VALUES = 137,
- OP_KEYS = 138,
- OP_DELETE = 139,
- OP_EXISTS = 140,
- OP_RV2HV = 141,
- OP_HELEM = 142,
- OP_HSLICE = 143,
- OP_KVHSLICE = 144,
- OP_MULTIDEREF = 145,
- OP_UNPACK = 146,
- OP_PACK = 147,
- OP_SPLIT = 148,
- OP_JOIN = 149,
- OP_LIST = 150,
- OP_LSLICE = 151,
- OP_ANONLIST = 152,
- OP_ANONHASH = 153,
- OP_SPLICE = 154,
- OP_PUSH = 155,
- OP_POP = 156,
- OP_SHIFT = 157,
- OP_UNSHIFT = 158,
- OP_SORT = 159,
- OP_REVERSE = 160,
- OP_GREPSTART = 161,
- OP_GREPWHILE = 162,
- OP_MAPSTART = 163,
- OP_MAPWHILE = 164,
- OP_RANGE = 165,
- OP_FLIP = 166,
- OP_FLOP = 167,
- OP_AND = 168,
- OP_OR = 169,
- OP_XOR = 170,
- OP_DOR = 171,
- OP_COND_EXPR = 172,
- OP_ANDASSIGN = 173,
- OP_ORASSIGN = 174,
- OP_DORASSIGN = 175,
- OP_METHOD = 176,
- OP_ENTERSUB = 177,
- OP_LEAVESUB = 178,
- OP_LEAVESUBLV = 179,
- OP_CALLER = 180,
- OP_WARN = 181,
- OP_DIE = 182,
- OP_RESET = 183,
- OP_LINESEQ = 184,
- OP_NEXTSTATE = 185,
- OP_DBSTATE = 186,
- OP_UNSTACK = 187,
- OP_ENTER = 188,
- OP_LEAVE = 189,
- OP_SCOPE = 190,
- OP_ENTERITER = 191,
- OP_ITER = 192,
- OP_ENTERLOOP = 193,
- OP_LEAVELOOP = 194,
- OP_RETURN = 195,
- OP_LAST = 196,
- OP_NEXT = 197,
- OP_REDO = 198,
- OP_DUMP = 199,
- OP_GOTO = 200,
- OP_EXIT = 201,
- OP_METHOD_NAMED = 202,
- OP_METHOD_SUPER = 203,
- OP_METHOD_REDIR = 204,
- OP_METHOD_REDIR_SUPER = 205,
- OP_ENTERGIVEN = 206,
- OP_LEAVEGIVEN = 207,
- OP_ENTERWHEN = 208,
- OP_LEAVEWHEN = 209,
- OP_BREAK = 210,
- OP_CONTINUE = 211,
- OP_OPEN = 212,
- OP_CLOSE = 213,
- OP_PIPE_OP = 214,
- OP_FILENO = 215,
- OP_UMASK = 216,
- OP_BINMODE = 217,
- OP_TIE = 218,
- OP_UNTIE = 219,
- OP_TIED = 220,
- OP_DBMOPEN = 221,
- OP_DBMCLOSE = 222,
- OP_SSELECT = 223,
- OP_SELECT = 224,
- OP_GETC = 225,
- OP_READ = 226,
- OP_ENTERWRITE = 227,
- OP_LEAVEWRITE = 228,
- OP_PRTF = 229,
- OP_PRINT = 230,
- OP_SAY = 231,
- OP_SYSOPEN = 232,
- OP_SYSSEEK = 233,
- OP_SYSREAD = 234,
- OP_SYSWRITE = 235,
- OP_EOF = 236,
- OP_TELL = 237,
- OP_SEEK = 238,
- OP_TRUNCATE = 239,
- OP_FCNTL = 240,
- OP_IOCTL = 241,
- OP_FLOCK = 242,
- OP_SEND = 243,
- OP_RECV = 244,
- OP_SOCKET = 245,
- OP_SOCKPAIR = 246,
- OP_BIND = 247,
- OP_CONNECT = 248,
- OP_LISTEN = 249,
- OP_ACCEPT = 250,
- OP_SHUTDOWN = 251,
- OP_GSOCKOPT = 252,
- OP_SSOCKOPT = 253,
- OP_GETSOCKNAME = 254,
- OP_GETPEERNAME = 255,
- OP_LSTAT = 256,
- OP_STAT = 257,
- OP_FTRREAD = 258,
- OP_FTRWRITE = 259,
- OP_FTREXEC = 260,
- OP_FTEREAD = 261,
- OP_FTEWRITE = 262,
- OP_FTEEXEC = 263,
- OP_FTIS = 264,
- OP_FTSIZE = 265,
- OP_FTMTIME = 266,
- OP_FTATIME = 267,
- OP_FTCTIME = 268,
- OP_FTROWNED = 269,
- OP_FTEOWNED = 270,
- OP_FTZERO = 271,
- OP_FTSOCK = 272,
- OP_FTCHR = 273,
- OP_FTBLK = 274,
- OP_FTFILE = 275,
- OP_FTDIR = 276,
- OP_FTPIPE = 277,
- OP_FTSUID = 278,
- OP_FTSGID = 279,
- OP_FTSVTX = 280,
- OP_FTLINK = 281,
- OP_FTTTY = 282,
- OP_FTTEXT = 283,
- OP_FTBINARY = 284,
- OP_CHDIR = 285,
- OP_CHOWN = 286,
- OP_CHROOT = 287,
- OP_UNLINK = 288,
- OP_CHMOD = 289,
- OP_UTIME = 290,
- OP_RENAME = 291,
- OP_LINK = 292,
- OP_SYMLINK = 293,
- OP_READLINK = 294,
- OP_MKDIR = 295,
- OP_RMDIR = 296,
- OP_OPEN_DIR = 297,
- OP_READDIR = 298,
- OP_TELLDIR = 299,
- OP_SEEKDIR = 300,
- OP_REWINDDIR = 301,
- OP_CLOSEDIR = 302,
- OP_FORK = 303,
- OP_WAIT = 304,
- OP_WAITPID = 305,
- OP_SYSTEM = 306,
- OP_EXEC = 307,
- OP_KILL = 308,
- OP_GETPPID = 309,
- OP_GETPGRP = 310,
- OP_SETPGRP = 311,
- OP_GETPRIORITY = 312,
- OP_SETPRIORITY = 313,
- OP_TIME = 314,
- OP_TMS = 315,
- OP_LOCALTIME = 316,
- OP_GMTIME = 317,
- OP_ALARM = 318,
- OP_SLEEP = 319,
- OP_SHMGET = 320,
- OP_SHMCTL = 321,
- OP_SHMREAD = 322,
- OP_SHMWRITE = 323,
- OP_MSGGET = 324,
- OP_MSGCTL = 325,
- OP_MSGSND = 326,
- OP_MSGRCV = 327,
- OP_SEMOP = 328,
- OP_SEMGET = 329,
- OP_SEMCTL = 330,
- OP_REQUIRE = 331,
- OP_DOFILE = 332,
- OP_HINTSEVAL = 333,
- OP_ENTEREVAL = 334,
- OP_LEAVEEVAL = 335,
- OP_ENTERTRY = 336,
- OP_LEAVETRY = 337,
- OP_GHBYNAME = 338,
- OP_GHBYADDR = 339,
- OP_GHOSTENT = 340,
- OP_GNBYNAME = 341,
- OP_GNBYADDR = 342,
- OP_GNETENT = 343,
- OP_GPBYNAME = 344,
- OP_GPBYNUMBER = 345,
- OP_GPROTOENT = 346,
- OP_GSBYNAME = 347,
- OP_GSBYPORT = 348,
- OP_GSERVENT = 349,
- OP_SHOSTENT = 350,
- OP_SNETENT = 351,
- OP_SPROTOENT = 352,
- OP_SSERVENT = 353,
- OP_EHOSTENT = 354,
- OP_ENETENT = 355,
- OP_EPROTOENT = 356,
- OP_ESERVENT = 357,
- OP_GPWNAM = 358,
- OP_GPWUID = 359,
- OP_GPWENT = 360,
- OP_SPWENT = 361,
- OP_EPWENT = 362,
- OP_GGRNAM = 363,
- OP_GGRGID = 364,
- OP_GGRENT = 365,
- OP_SGRENT = 366,
- OP_EGRENT = 367,
- OP_GETLOGIN = 368,
- OP_SYSCALL = 369,
- OP_LOCK = 370,
- OP_ONCE = 371,
- OP_CUSTOM = 372,
- OP_REACH = 373,
- OP_RKEYS = 374,
- OP_RVALUES = 375,
- OP_COREARGS = 376,
- OP_RUNCV = 377,
- OP_FC = 378,
- OP_PADCV = 379,
- OP_INTROCV = 380,
- OP_CLONECV = 381,
- OP_PADRANGE = 382,
- OP_REFASSIGN = 383,
- OP_LVREF = 384,
- OP_LVREFSLICE = 385,
- OP_LVAVREF = 386,
- OP_ANONCONST = 387,
+ OP_NBIT_AND = 95,
+ OP_NBIT_XOR = 96,
+ OP_NBIT_OR = 97,
+ OP_SBIT_AND = 98,
+ OP_SBIT_XOR = 99,
+ OP_SBIT_OR = 100,
+ OP_NEGATE = 101,
+ OP_I_NEGATE = 102,
+ OP_NOT = 103,
+ OP_COMPLEMENT = 104,
+ OP_NCOMPLEMENT = 105,
+ OP_SCOMPLEMENT = 106,
+ OP_SMARTMATCH = 107,
+ OP_ATAN2 = 108,
+ OP_SIN = 109,
+ OP_COS = 110,
+ OP_RAND = 111,
+ OP_SRAND = 112,
+ OP_EXP = 113,
+ OP_LOG = 114,
+ OP_SQRT = 115,
+ OP_INT = 116,
+ OP_HEX = 117,
+ OP_OCT = 118,
+ OP_ABS = 119,
+ OP_LENGTH = 120,
+ OP_SUBSTR = 121,
+ OP_VEC = 122,
+ OP_INDEX = 123,
+ OP_RINDEX = 124,
+ OP_SPRINTF = 125,
+ OP_FORMLINE = 126,
+ OP_ORD = 127,
+ OP_CHR = 128,
+ OP_CRYPT = 129,
+ OP_UCFIRST = 130,
+ OP_LCFIRST = 131,
+ OP_UC = 132,
+ OP_LC = 133,
+ OP_QUOTEMETA = 134,
+ OP_RV2AV = 135,
+ OP_AELEMFAST = 136,
+ OP_AELEMFAST_LEX = 137,
+ OP_AELEM = 138,
+ OP_ASLICE = 139,
+ OP_KVASLICE = 140,
+ OP_AEACH = 141,
+ OP_AKEYS = 142,
+ OP_AVALUES = 143,
+ OP_EACH = 144,
+ OP_VALUES = 145,
+ OP_KEYS = 146,
+ OP_DELETE = 147,
+ OP_EXISTS = 148,
+ OP_RV2HV = 149,
+ OP_HELEM = 150,
+ OP_HSLICE = 151,
+ OP_KVHSLICE = 152,
+ OP_MULTIDEREF = 153,
+ OP_UNPACK = 154,
+ OP_PACK = 155,
+ OP_SPLIT = 156,
+ OP_JOIN = 157,
+ OP_LIST = 158,
+ OP_LSLICE = 159,
+ OP_ANONLIST = 160,
+ OP_ANONHASH = 161,
+ OP_SPLICE = 162,
+ OP_PUSH = 163,
+ OP_POP = 164,
+ OP_SHIFT = 165,
+ OP_UNSHIFT = 166,
+ OP_SORT = 167,
+ OP_REVERSE = 168,
+ OP_GREPSTART = 169,
+ OP_GREPWHILE = 170,
+ OP_MAPSTART = 171,
+ OP_MAPWHILE = 172,
+ OP_RANGE = 173,
+ OP_FLIP = 174,
+ OP_FLOP = 175,
+ OP_AND = 176,
+ OP_OR = 177,
+ OP_XOR = 178,
+ OP_DOR = 179,
+ OP_COND_EXPR = 180,
+ OP_ANDASSIGN = 181,
+ OP_ORASSIGN = 182,
+ OP_DORASSIGN = 183,
+ OP_METHOD = 184,
+ OP_ENTERSUB = 185,
+ OP_LEAVESUB = 186,
+ OP_LEAVESUBLV = 187,
+ OP_CALLER = 188,
+ OP_WARN = 189,
+ OP_DIE = 190,
+ OP_RESET = 191,
+ OP_LINESEQ = 192,
+ OP_NEXTSTATE = 193,
+ OP_DBSTATE = 194,
+ OP_UNSTACK = 195,
+ OP_ENTER = 196,
+ OP_LEAVE = 197,
+ OP_SCOPE = 198,
+ OP_ENTERITER = 199,
+ OP_ITER = 200,
+ OP_ENTERLOOP = 201,
+ OP_LEAVELOOP = 202,
+ OP_RETURN = 203,
+ OP_LAST = 204,
+ OP_NEXT = 205,
+ OP_REDO = 206,
+ OP_DUMP = 207,
+ OP_GOTO = 208,
+ OP_EXIT = 209,
+ OP_METHOD_NAMED = 210,
+ OP_METHOD_SUPER = 211,
+ OP_METHOD_REDIR = 212,
+ OP_METHOD_REDIR_SUPER = 213,
+ OP_ENTERGIVEN = 214,
+ OP_LEAVEGIVEN = 215,
+ OP_ENTERWHEN = 216,
+ OP_LEAVEWHEN = 217,
+ OP_BREAK = 218,
+ OP_CONTINUE = 219,
+ OP_OPEN = 220,
+ OP_CLOSE = 221,
+ OP_PIPE_OP = 222,
+ OP_FILENO = 223,
+ OP_UMASK = 224,
+ OP_BINMODE = 225,
+ OP_TIE = 226,
+ OP_UNTIE = 227,
+ OP_TIED = 228,
+ OP_DBMOPEN = 229,
+ OP_DBMCLOSE = 230,
+ OP_SSELECT = 231,
+ OP_SELECT = 232,
+ OP_GETC = 233,
+ OP_READ = 234,
+ OP_ENTERWRITE = 235,
+ OP_LEAVEWRITE = 236,
+ OP_PRTF = 237,
+ OP_PRINT = 238,
+ OP_SAY = 239,
+ OP_SYSOPEN = 240,
+ OP_SYSSEEK = 241,
+ OP_SYSREAD = 242,
+ OP_SYSWRITE = 243,
+ OP_EOF = 244,
+ OP_TELL = 245,
+ OP_SEEK = 246,
+ OP_TRUNCATE = 247,
+ OP_FCNTL = 248,
+ OP_IOCTL = 249,
+ OP_FLOCK = 250,
+ OP_SEND = 251,
+ OP_RECV = 252,
+ OP_SOCKET = 253,
+ OP_SOCKPAIR = 254,
+ OP_BIND = 255,
+ OP_CONNECT = 256,
+ OP_LISTEN = 257,
+ OP_ACCEPT = 258,
+ OP_SHUTDOWN = 259,
+ OP_GSOCKOPT = 260,
+ OP_SSOCKOPT = 261,
+ OP_GETSOCKNAME = 262,
+ OP_GETPEERNAME = 263,
+ OP_LSTAT = 264,
+ OP_STAT = 265,
+ OP_FTRREAD = 266,
+ OP_FTRWRITE = 267,
+ OP_FTREXEC = 268,
+ OP_FTEREAD = 269,
+ OP_FTEWRITE = 270,
+ OP_FTEEXEC = 271,
+ OP_FTIS = 272,
+ OP_FTSIZE = 273,
+ OP_FTMTIME = 274,
+ OP_FTATIME = 275,
+ OP_FTCTIME = 276,
+ OP_FTROWNED = 277,
+ OP_FTEOWNED = 278,
+ OP_FTZERO = 279,
+ OP_FTSOCK = 280,
+ OP_FTCHR = 281,
+ OP_FTBLK = 282,
+ OP_FTFILE = 283,
+ OP_FTDIR = 284,
+ OP_FTPIPE = 285,
+ OP_FTSUID = 286,
+ OP_FTSGID = 287,
+ OP_FTSVTX = 288,
+ OP_FTLINK = 289,
+ OP_FTTTY = 290,
+ OP_FTTEXT = 291,
+ OP_FTBINARY = 292,
+ OP_CHDIR = 293,
+ OP_CHOWN = 294,
+ OP_CHROOT = 295,
+ OP_UNLINK = 296,
+ OP_CHMOD = 297,
+ OP_UTIME = 298,
+ OP_RENAME = 299,
+ OP_LINK = 300,
+ OP_SYMLINK = 301,
+ OP_READLINK = 302,
+ OP_MKDIR = 303,
+ OP_RMDIR = 304,
+ OP_OPEN_DIR = 305,
+ OP_READDIR = 306,
+ OP_TELLDIR = 307,
+ OP_SEEKDIR = 308,
+ OP_REWINDDIR = 309,
+ OP_CLOSEDIR = 310,
+ OP_FORK = 311,
+ OP_WAIT = 312,
+ OP_WAITPID = 313,
+ OP_SYSTEM = 314,
+ OP_EXEC = 315,
+ OP_KILL = 316,
+ OP_GETPPID = 317,
+ OP_GETPGRP = 318,
+ OP_SETPGRP = 319,
+ OP_GETPRIORITY = 320,
+ OP_SETPRIORITY = 321,
+ OP_TIME = 322,
+ OP_TMS = 323,
+ OP_LOCALTIME = 324,
+ OP_GMTIME = 325,
+ OP_ALARM = 326,
+ OP_SLEEP = 327,
+ OP_SHMGET = 328,
+ OP_SHMCTL = 329,
+ OP_SHMREAD = 330,
+ OP_SHMWRITE = 331,
+ OP_MSGGET = 332,
+ OP_MSGCTL = 333,
+ OP_MSGSND = 334,
+ OP_MSGRCV = 335,
+ OP_SEMOP = 336,
+ OP_SEMGET = 337,
+ OP_SEMCTL = 338,
+ OP_REQUIRE = 339,
+ OP_DOFILE = 340,
+ OP_HINTSEVAL = 341,
+ OP_ENTEREVAL = 342,
+ OP_LEAVEEVAL = 343,
+ OP_ENTERTRY = 344,
+ OP_LEAVETRY = 345,
+ OP_GHBYNAME = 346,
+ OP_GHBYADDR = 347,
+ OP_GHOSTENT = 348,
+ OP_GNBYNAME = 349,
+ OP_GNBYADDR = 350,
+ OP_GNETENT = 351,
+ OP_GPBYNAME = 352,
+ OP_GPBYNUMBER = 353,
+ OP_GPROTOENT = 354,
+ OP_GSBYNAME = 355,
+ OP_GSBYPORT = 356,
+ OP_GSERVENT = 357,
+ OP_SHOSTENT = 358,
+ OP_SNETENT = 359,
+ OP_SPROTOENT = 360,
+ OP_SSERVENT = 361,
+ OP_EHOSTENT = 362,
+ OP_ENETENT = 363,
+ OP_EPROTOENT = 364,
+ OP_ESERVENT = 365,
+ OP_GPWNAM = 366,
+ OP_GPWUID = 367,
+ OP_GPWENT = 368,
+ OP_SPWENT = 369,
+ OP_EPWENT = 370,
+ OP_GGRNAM = 371,
+ OP_GGRGID = 372,
+ OP_GGRENT = 373,
+ OP_SGRENT = 374,
+ OP_EGRENT = 375,
+ OP_GETLOGIN = 376,
+ OP_SYSCALL = 377,
+ OP_LOCK = 378,
+ OP_ONCE = 379,
+ OP_CUSTOM = 380,
+ OP_REACH = 381,
+ OP_RKEYS = 382,
+ OP_RVALUES = 383,
+ OP_COREARGS = 384,
+ OP_RUNCV = 385,
+ OP_FC = 386,
+ OP_PADCV = 387,
+ OP_INTROCV = 388,
+ OP_CLONECV = 389,
+ OP_PADRANGE = 390,
+ OP_REFASSIGN = 391,
+ OP_LVREF = 392,
+ OP_LVREFSLICE = 393,
+ OP_LVAVREF = 394,
+ OP_ANONCONST = 395,
OP_max
} opcode;
-#define MAXO 388
+#define MAXO 396
#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 a1a161d45e..2cd2d5e03d 100644
--- a/pp.c
+++ b/pp.c
@@ -2224,6 +2224,34 @@ PP(pp_bit_and)
}
}
+PP(pp_nbit_and)
+{
+ dSP;
+ tryAMAGICbin_MG(band_amg, AMGf_assign);
+ {
+ dATARGET; dPOPTOPssrl;
+ if (PL_op->op_private & HINT_INTEGER) {
+ const IV i = SvIV_nomg(left) & SvIV_nomg(right);
+ SETi(i);
+ }
+ else {
+ const UV u = SvUV_nomg(left) & SvUV_nomg(right);
+ SETu(u);
+ }
+ }
+ RETURN;
+}
+
+PP(pp_sbit_and)
+{
+ dSP;
+ tryAMAGICbin_MG(sband_amg, AMGf_assign);
+ {
+ dATARGET; dPOPTOPssrl;
+ do_vop(OP_BIT_AND, TARG, left, right);
+ RETSETTARG;
+ }
+}
/* also used for: pp_bit_xor() */
@@ -2261,6 +2289,50 @@ PP(pp_bit_or)
}
}
+/* also used for: pp_nbit_xor() */
+
+PP(pp_nbit_or)
+{
+ dSP;
+ const int op_type = PL_op->op_type;
+
+ tryAMAGICbin_MG((op_type == OP_NBIT_OR ? bor_amg : bxor_amg),
+ AMGf_assign);
+ {
+ dATARGET; dPOPTOPssrl;
+ if (PL_op->op_private & HINT_INTEGER) {
+ const IV l = (USE_LEFT(left) ? SvIV_nomg(left) : 0);
+ const IV r = SvIV_nomg(right);
+ const IV result = op_type == OP_NBIT_OR ? (l | r) : (l ^ r);
+ SETi(result);
+ }
+ else {
+ const UV l = (USE_LEFT(left) ? SvUV_nomg(left) : 0);
+ const UV r = SvUV_nomg(right);
+ const UV result = op_type == OP_NBIT_OR ? (l | r) : (l ^ r);
+ SETu(result);
+ }
+ }
+ RETURN;
+}
+
+/* also used for: pp_sbit_xor() */
+
+PP(pp_sbit_or)
+{
+ dSP;
+ const int op_type = PL_op->op_type;
+
+ tryAMAGICbin_MG((op_type == OP_SBIT_OR ? sbor_amg : sbxor_amg),
+ AMGf_assign);
+ {
+ dATARGET; dPOPTOPssrl;
+ do_vop(op_type == OP_SBIT_OR ? OP_BIT_OR : OP_BIT_XOR, TARG, left,
+ right);
+ RETSETTARG;
+ }
+}
+
PERL_STATIC_INLINE bool
S_negate_string(pTHX)
{
@@ -2336,23 +2408,9 @@ PP(pp_not)
return NORMAL;
}
-PP(pp_complement)
+static void
+S_scomplement(pTHX_ SV *targ, SV *sv)
{
- dSP; dTARGET;
- tryAMAGICun_MG(compl_amg, AMGf_numeric);
- {
- dTOPss;
- if (SvNIOKp(sv)) {
- if (PL_op->op_private & HINT_INTEGER) {
- const IV i = ~SvIV_nomg(sv);
- SETi(i);
- }
- else {
- const UV u = ~SvUV_nomg(sv);
- SETu(u);
- }
- }
- else {
U8 *tmps;
I32 anum;
STRLEN len;
@@ -2413,8 +2471,7 @@ PP(pp_complement)
sv_usepvn_flags(TARG, (char*)result, nchar, SV_HAS_TRAILING_NUL);
SvUTF8_off(TARG);
}
- SETTARG;
- return NORMAL;
+ return;
}
#ifdef LIBERAL
{
@@ -2429,12 +2486,62 @@ PP(pp_complement)
#endif
for ( ; anum > 0; anum--, tmps++)
*tmps = ~*tmps;
+}
+
+PP(pp_complement)
+{
+ dSP; dTARGET;
+ tryAMAGICun_MG(compl_amg, AMGf_numeric);
+ {
+ dTOPss;
+ if (SvNIOKp(sv)) {
+ if (PL_op->op_private & HINT_INTEGER) {
+ const IV i = ~SvIV_nomg(sv);
+ SETi(i);
+ }
+ else {
+ const UV u = ~SvUV_nomg(sv);
+ SETu(u);
+ }
+ }
+ else {
+ S_scomplement(aTHX_ TARG, sv);
SETTARG;
}
return NORMAL;
}
}
+PP(pp_ncomplement)
+{
+ dSP;
+ tryAMAGICun_MG(compl_amg, AMGf_numeric);
+ {
+ dTARGET; dTOPss;
+ if (PL_op->op_private & HINT_INTEGER) {
+ const IV i = ~SvIV_nomg(sv);
+ SETi(i);
+ }
+ else {
+ const UV u = ~SvUV_nomg(sv);
+ SETu(u);
+ }
+ }
+ return NORMAL;
+}
+
+PP(pp_scomplement)
+{
+ dSP;
+ tryAMAGICun_MG(scompl_amg, AMGf_numeric);
+ {
+ dTARGET; dTOPss;
+ S_scomplement(aTHX_ TARG, sv);
+ SETTARG;
+ return NORMAL;
+ }
+}
+
/* integer versions of some of the above */
PP(pp_i_multiply)
diff --git a/pp.h b/pp.h
index b8e482bd31..c417c1ebbf 100644
--- a/pp.h
+++ b/pp.h
@@ -376,6 +376,7 @@ Does not use C<TARG>. See also C<XPUSHu>, C<mPUSHu> and C<PUSHu>.
#define RETSETYES RETURNX(SETs(&PL_sv_yes))
#define RETSETNO RETURNX(SETs(&PL_sv_no))
#define RETSETUNDEF RETURNX(SETs(&PL_sv_undef))
+#define RETSETTARG STMT_START { SETTARG; RETURN; } STMT_END
#define ARGTARG PL_op->op_targ
diff --git a/pp_proto.h b/pp_proto.h
index bbf6cf5f76..7f9d122333 100644
--- a/pp_proto.h
+++ b/pp_proto.h
@@ -160,7 +160,10 @@ PERL_CALLCONV OP *Perl_pp_mkdir(pTHX);
PERL_CALLCONV OP *Perl_pp_modulo(pTHX);
PERL_CALLCONV OP *Perl_pp_multideref(pTHX);
PERL_CALLCONV OP *Perl_pp_multiply(pTHX);
+PERL_CALLCONV OP *Perl_pp_nbit_and(pTHX);
+PERL_CALLCONV OP *Perl_pp_nbit_or(pTHX);
PERL_CALLCONV OP *Perl_pp_ncmp(pTHX);
+PERL_CALLCONV OP *Perl_pp_ncomplement(pTHX);
PERL_CALLCONV OP *Perl_pp_ne(pTHX);
PERL_CALLCONV OP *Perl_pp_negate(pTHX);
PERL_CALLCONV OP *Perl_pp_next(pTHX);
@@ -220,8 +223,11 @@ PERL_CALLCONV OP *Perl_pp_rv2cv(pTHX);
PERL_CALLCONV OP *Perl_pp_rv2gv(pTHX);
PERL_CALLCONV OP *Perl_pp_rv2sv(pTHX);
PERL_CALLCONV OP *Perl_pp_sassign(pTHX);
+PERL_CALLCONV OP *Perl_pp_sbit_and(pTHX);
+PERL_CALLCONV OP *Perl_pp_sbit_or(pTHX);
PERL_CALLCONV OP *Perl_pp_schop(pTHX);
PERL_CALLCONV OP *Perl_pp_scmp(pTHX);
+PERL_CALLCONV OP *Perl_pp_scomplement(pTHX);
PERL_CALLCONV OP *Perl_pp_seekdir(pTHX);
PERL_CALLCONV OP *Perl_pp_select(pTHX);
PERL_CALLCONV OP *Perl_pp_semctl(pTHX);
diff --git a/regen/opcode.pl b/regen/opcode.pl
index 327e45eda1..765816fd50 100755
--- a/regen/opcode.pl
+++ b/regen/opcode.pl
@@ -122,6 +122,8 @@ my @raw_alias = (
Perl_pp_shift => ['pop'],
Perl_pp_sin => [qw(cos exp log sqrt)],
Perl_pp_bit_or => ['bit_xor'],
+ Perl_pp_nbit_or => ['nbit_xor'],
+ Perl_pp_sbit_or => ['sbit_xor'],
Perl_pp_rv2av => ['rv2hv'],
Perl_pp_akeys => ['avalues'],
Perl_pp_rkeys => [qw(rvalues reach)],
diff --git a/regen/opcodes b/regen/opcodes
index 3061d33efb..614a54c439 100644
--- a/regen/opcodes
+++ b/regen/opcodes
@@ -165,11 +165,19 @@ scmp string comparison (cmp) ck_null ifsT2 S S
bit_and bitwise and (&) ck_bitop fst2 S S
bit_xor bitwise xor (^) ck_bitop fst2 S S
bit_or bitwise or (|) ck_bitop fst2 S S
+nbit_and numeric bitiwse and (&) ck_bitop fsT2 S S
+nbit_xor numeric bitwise xor (^) ck_bitop fsT2 S S
+nbit_or numeric bitwise or (|) ck_bitop fsT2 S S
+sbit_and string bitiwse and (&) ck_bitop fst2 S S
+sbit_xor string bitwise xor (^) ck_bitop fst2 S S
+sbit_or string bitwise or (|) ck_bitop fst2 S S
negate negation (-) ck_null Ifst1 S
i_negate integer negation (-) ck_null ifst1 S
not not ck_null ifs1 S
complement 1's complement (~) ck_bitop fsT1 S
+ncomplement numeric 1's complement (~) ck_bitop fsT1 S
+scomplement string 1's complement (~) ck_null fsT1 S
smartmatch smart match ck_smartmatch s2