In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/df442ae4d3c2df4893d91c69568c334c4cb98082?hp=8e0a1bb9cff8cd2454b2ecbc25a56649bba360bd>
- Log ----------------------------------------------------------------- commit df442ae4d3c2df4893d91c69568c334c4cb98082 Merge: 26b17dd 7eae626 Author: Father Chrysostomos <[email protected]> Date: Sat Jan 31 22:04:04 2015 -0800 [Merge] [perl #123466] New experimental bitops Under âuse experimental "bitwise"â, & ! ^ ~ are now strictly numeric ops and &. |. ^. ~. are new ops that treat their arguments as strings. commit 7eae626b35510787f608b37bdcaecfef834a137f Author: Father Chrysostomos <[email protected]> Date: Sat Jan 31 18:26:53 2015 -0800 Increase $B::Deparse::VERSION to 1.33 M lib/B/Deparse.pm commit 69b20483e77437a943047e8390d7d2281ab02928 Author: Father Chrysostomos <[email protected]> Date: Thu Jan 8 22:13:02 2015 -0800 overload.pm: Document fifth arg for &|^~ M lib/overload.pm commit 636ac8fc9ac210e786fda679ad294c918022d0c5 Author: Father Chrysostomos <[email protected]> Date: Fri Jan 9 08:45:28 2015 -0800 5th arg to indicate numeric bitwise overloading M gv.c M lib/overload.t M pp.c M pp.h commit 594a52e669cf40aeb3e1f610fad70e3f919e8e10 Author: Father Chrysostomos <[email protected]> Date: Thu Jan 8 22:20:12 2015 -0800 overload.pm: Typo M lib/overload.pm commit 3dd9d4e4b1e12bd5830116e4e232b933c42be1c1 Author: Father Chrysostomos <[email protected]> Date: Thu Jan 8 22:19:38 2015 -0800 pp_hot.c: Note that amagic_call calls pp_pushmark M pp_hot.c commit 6207d112f3e84590afbf2323184d898258a51455 Author: Father Chrysostomos <[email protected]> Date: Sun Jan 4 17:48:26 2015 -0800 Mention experimental bitops in perlexperiment M pod/perlexperiment.pod commit 70ea8edf40d040203fd7e500c57232e04e3fc8cd Author: Father Chrysostomos <[email protected]> Date: Sun Jan 4 17:45:19 2015 -0800 feature.pm: Document the bitwise feature M lib/feature.pm M regen/feature.pl commit fb7054ba7bb9bc87ce6a32c6fad702be20e10077 Author: Father Chrysostomos <[email protected]> Date: Sun Jan 4 17:36:53 2015 -0800 Document string- and number-specific bitops in perlop M pod/perlop.pod commit e6288bd5f9144043a950cb01faafe8ffa5bd89d9 Author: Father Chrysostomos <[email protected]> Date: Sun Jan 4 17:13:12 2015 -0800 overload.t: Test experimental bitops M lib/overload.t commit 6d06ecceafd35d5028e1f8e07ccef129554b8135 Author: Father Chrysostomos <[email protected]> Date: Sun Jan 4 17:12:11 2015 -0800 gv.c: Make &.= overloading work M gv.c commit 3b41b1dff469337d35e4521c1f3331cb0e085019 Author: Father Chrysostomos <[email protected]> Date: Sun Jan 4 17:10:57 2015 -0800 overload.pm: Document &. etc. M lib/overload.pm commit 9219de7eacc2a8507fc1448a5f13f5aebb27e984 Author: Father Chrysostomos <[email protected]> Date: Sun Jan 4 16:58:14 2015 -0800 Increase $overload::VERSION to 1.25 M lib/overload.pm commit cb9052ada624969cf7196f56c575dc5bcc97f9e7 Author: Father Chrysostomos <[email protected]> Date: Sun Jan 4 16:57:41 2015 -0800 overload.pm: Add string-specific bitops M lib/overload.pm commit b6e8d7fe79102f41e9bcc4a8fe64682d106eccec Author: Father Chrysostomos <[email protected]> Date: Sun Jan 4 14:04:47 2015 -0800 Test new string- and num-specific bitops M t/op/bop.t commit c34c1a441ccd4670680cc97e90290d701ad85426 Author: Father Chrysostomos <[email protected]> Date: Sun Jan 4 11:53:31 2015 -0800 Test predecence warning on new bitops M t/lib/warnings/op commit 82afc3d431ee641f6f784b17d7b30aab82223d84 Author: Father Chrysostomos <[email protected]> Date: Sun Jan 4 11:49:31 2015 -0800 Test experimental bitop warning M t/lib/warnings/op commit a6eb74ec7f79f7c519927e9496acfe0a09cd1726 Author: Father Chrysostomos <[email protected]> Date: Sun Jan 4 11:44:03 2015 -0800 Warning about experimental bitops M op.c M opcode.h M pod/perldiag.pod M regen/opcodes commit 27f31adf88291fb0c1238c9bb558f95a54a8555b Author: Father Chrysostomos <[email protected]> Date: Sun Jan 4 11:21:35 2015 -0800 Deparse new bitops M lib/B/Deparse.pm M lib/B/Deparse.t commit 8823cb892f42d6ac57b0703ce34bf092db3507d4 Author: Father Chrysostomos <[email protected]> Date: Sun Jan 4 10:48:13 2015 -0800 Parse and compile string- and num-specific bitops Yay, the semicolons are back. M op.c M perly.act M perly.h M perly.tab M perly.y M pod/perldiag.pod M toke.c commit a9f19d0f50fa6980e7bdbcf691d81e40b2669a17 Author: Father Chrysostomos <[email protected]> Date: Sat Jan 3 22:34:28 2015 -0800 Add OP_IS_INFIX_BIT A convenience macro that a forthcoming commit will use. M opnames.h M regen/opcode.pl M regen/opcodes commit 448d2b66f6cf2d5395d6d8d4ae22812b489cb476 Author: Father Chrysostomos <[email protected]> Date: Sun Jan 4 11:02:21 2015 -0800 Deparse.t: Account for new warnings category Hmm. This is not particularly maintainable. M lib/B/Deparse.t commit 9f88e53735f463ef70909e0120b3c3f475cd143f Author: Father Chrysostomos <[email protected]> Date: Sat Jan 3 22:25:11 2015 -0800 Add experimental::bitwise warnings category M lib/warnings.pm M regen/warnings.pl M warnings.h commit 5e65fe5642505f62573d37c3279b024b00d6fbfb Author: Father Chrysostomos <[email protected]> Date: Sun Jan 4 10:51:54 2015 -0800 Increase $feature::VERSION to 1.40 M lib/feature.pm M regen/feature.pl commit cec892e70ee3421ec1820fe8e5df17cb07e1a686 Author: Father Chrysostomos <[email protected]> Date: Sat Jan 3 22:20:17 2015 -0800 Add bitwise feature feature M feature.h M lib/feature.pm M regen/feature.pl commit 5d01050abccabc9ab4309d80d4b603d68575e0a8 Author: Father Chrysostomos <[email protected]> Date: Sat Jan 3 18:50:35 2015 -0800 Add string- and number-specific bitop types and also implement the pp functions, though nothing compiles to these ops yet. M ext/Opcode/Opcode.pm M lib/B/Op_private.pm M opcode.h M opnames.h M pp.c M pp.h M pp_proto.h M regen/opcode.pl M regen/opcodes commit 7dd648412d5aa4efd8fb68cc6d58d99d867af2a2 Author: Father Chrysostomos <[email protected]> Date: Sat Jan 3 17:55:53 2015 -0800 Add overload types for string-specifc bitops M lib/overload/numbers.pm M overload.c M overload.h M regen/overload.pl commit 26b17dd21e4aedef224e009510eebb11d2256d3a Author: Father Chrysostomos <[email protected]> Date: Sat Jan 31 14:06:15 2015 -0800 Remove context param from sv_get_backrefs v5.21.7-83-geaab564 added sv_get_backrefs. v5.21.7-90-g8fbcb65 removed the one use of aTHX. M embed.fnc M embed.h M proto.h M sv.c ----------------------------------------------------------------------- Summary of changes: embed.fnc | 2 +- embed.h | 2 +- ext/Opcode/Opcode.pm | 5 +- feature.h | 6 + gv.c | 14 +- lib/B/Deparse.pm | 23 +- lib/B/Deparse.t | 29 ++- lib/B/Op_private.pm | 12 +- lib/feature.pm | 23 +- lib/overload.pm | 37 +-- lib/overload.t | 65 +++++- lib/overload/numbers.pm | 14 ++ lib/warnings.pm | 59 ++--- op.c | 23 +- opcode.h | 64 +++++- opnames.h | 599 ++++++++++++++++++++++++------------------------ overload.c | 14 ++ overload.h | 47 ++-- perly.act | 459 +++++++++++++++++++------------------ perly.h | 64 ++---- perly.tab | 67 +++--- perly.y | 2 +- pod/perldiag.pod | 14 +- pod/perlexperiment.pod | 15 ++ pod/perlop.pod | 55 ++++- pp.c | 143 ++++++++++-- pp.h | 2 + pp_hot.c | 3 +- pp_proto.h | 6 + proto.h | 4 +- regen/feature.pl | 21 +- regen/opcode.pl | 7 +- regen/opcodes | 18 +- regen/overload.pl | 7 + regen/warnings.pl | 2 + sv.c | 2 +- t/lib/warnings/op | 129 +++++++++++ t/op/bop.t | 43 +++- toke.c | 37 ++- warnings.h | 15 +- 40 files changed, 1410 insertions(+), 743 deletions(-) diff --git a/embed.fnc b/embed.fnc index 41b0087..cfe634f 100644 --- a/embed.fnc +++ b/embed.fnc @@ -1792,7 +1792,7 @@ Apdmb |void |sv_force_normal|NN SV *sv Apd |void |sv_force_normal_flags|NN SV *const sv|const U32 flags pX |SSize_t|tmps_grow_p |SSize_t ix Apd |SV* |sv_rvweaken |NN SV *const sv -ApPMd |SV* |sv_get_backrefs|NN SV *const sv +AnpPMd |SV* |sv_get_backrefs|NN SV *const sv : This is indirectly referenced by globals.c. This is somewhat annoying. p |int |magic_killbackrefs|NN SV *sv|NN MAGIC *mg Ap |OP* |newANONATTRSUB |I32 floor|NULLOK OP *proto|NULLOK OP *attrs|NULLOK OP *block diff --git a/embed.h b/embed.h index 15fa37e..802b624 100644 --- a/embed.h +++ b/embed.h @@ -621,7 +621,7 @@ #define sv_eq_flags(a,b,c) Perl_sv_eq_flags(aTHX_ a,b,c) #define sv_force_normal_flags(a,b) Perl_sv_force_normal_flags(aTHX_ a,b) #define sv_free(a) Perl_sv_free(aTHX_ a) -#define sv_get_backrefs(a) Perl_sv_get_backrefs(aTHX_ a) +#define sv_get_backrefs Perl_sv_get_backrefs #define sv_gets(a,b,c) Perl_sv_gets(aTHX_ a,b,c) #define sv_grow(a,b) Perl_sv_grow(aTHX_ a,b) #define sv_inc(a) Perl_sv_inc(aTHX_ a) diff --git a/ext/Opcode/Opcode.pm b/ext/Opcode/Opcode.pm index 925b4ab..c9a3f15 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/feature.h b/feature.h index 370896e..ba796eb 100644 --- a/feature.h +++ b/feature.h @@ -60,6 +60,12 @@ FEATURE_IS_ENABLED("switch")) \ ) +#define FEATURE_BITWISE_IS_ENABLED \ + ( \ + CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_CUSTOM && \ + FEATURE_IS_ENABLED("bitwise") \ + ) + #define FEATURE_EVALBYTES_IS_ENABLED \ ( \ CURRENT_FEATURE_BUNDLE == FEATURE_BUNDLE_515 \ diff --git a/gv.c b/gv.c index 6801816..82db197 100644 --- a/gv.c +++ b/gv.c @@ -2842,7 +2842,9 @@ Perl_try_amagic_un(pTHX_ int method, int flags) { SvGETMAGIC(arg); if (SvAMAGIC(arg) && (tmpsv = amagic_call(arg, &PL_sv_undef, method, - AMGf_noright | AMGf_unary))) { + AMGf_noright | AMGf_unary + | (flags & AMGf_numarg)))) + { if (flags & AMGf_set) { SETs(tmpsv); } @@ -2887,7 +2889,8 @@ Perl_try_amagic_bin(pTHX_ int method, int flags) { if (SvAMAGIC(left) || SvAMAGIC(right)) { SV * const tmpsv = amagic_call(left, right, method, - ((flags & AMGf_assign) && opASSIGN ? AMGf_assign: 0)); + ((flags & AMGf_assign) && opASSIGN ? AMGf_assign: 0) + | (flags & AMGf_numarg)); if (tmpsv) { if (flags & AMGf_set) { (void)POPs; @@ -3266,6 +3269,9 @@ Perl_amagic_call(pTHX_ SV *left, SV *right, int method, int flags) case band_amg: case bor_amg: case bxor_amg: + case sband_amg: + case sbor_amg: + case sbxor_amg: if (assign) force_scalar = 1; break; @@ -3392,6 +3398,10 @@ Perl_amagic_call(pTHX_ SV *left, SV *right, int method, int flags) PUSHs(newSVpvn_flags(AMG_id2name(method + assignshift), AMG_id2namelen(method + assignshift), SVs_TEMP)); } + else if (flags & AMGf_numarg) + PUSHs(&PL_sv_undef); + if (flags & AMGf_numarg) + PUSHs(&PL_sv_yes); PUSHs(MUTABLE_SV(cv)); PUTBACK; oldmark = TOPMARK; diff --git a/lib/B/Deparse.pm b/lib/B/Deparse.pm index 740192d..3dbcdfa 100644 --- a/lib/B/Deparse.pm +++ b/lib/B/Deparse.pm @@ -46,7 +46,7 @@ use B qw(class main_root main_start main_cv svref_2object opnumber perlstring MDEREF_SHIFT ); -$VERSION = '1.32'; +$VERSION = '1.33'; use strict; use vars qw/$AUTOLOAD/; use warnings (); @@ -2258,6 +2258,8 @@ sub pp_i_predec { pfixop(@_, "--", 23) } sub pp_i_postinc { maybe_targmy(@_, \&pfixop, "++", 23, POSTFIX) } sub pp_i_postdec { maybe_targmy(@_, \&pfixop, "--", 23, POSTFIX) } sub pp_complement { maybe_targmy(@_, \&pfixop, "~", 21) } +*pp_ncomplement = *pp_complement; +sub pp_scomplement { maybe_targmy(@_, \&pfixop, "~.", 21) } sub pp_negate { maybe_targmy(@_, \&real_negate) } sub real_negate { @@ -2763,8 +2765,10 @@ BEGIN { 'subtract' => 18, 'i_subtract' => 18, 'concat' => 18, 'left_shift' => 17, 'right_shift' => 17, - 'bit_and' => 13, + 'bit_and' => 13, 'nbit_and' => 13, 'sbit_and' => 13, 'bit_or' => 12, 'bit_xor' => 12, + 'sbit_or' => 12, 'sbit_xor' => 12, + 'nbit_or' => 12, 'nbit_xor' => 12, 'and' => 3, 'or' => 2, 'xor' => 2, ); @@ -2796,8 +2800,9 @@ BEGIN { 'subtract=' => 7, 'i_subtract=' => 7, 'concat=' => 7, 'left_shift=' => 7, 'right_shift=' => 7, - 'bit_and=' => 7, - 'bit_or=' => 7, 'bit_xor=' => 7, + 'bit_and=' => 7, 'sbit_and=' => 7, 'nbit_and=' => 7, + 'nbit_or=' => 7, 'nbit_xor=' => 7, + 'sbit_or=' => 7, 'sbit_xor=' => 7, 'andassign' => 7, 'orassign' => 7, ); @@ -2860,6 +2865,12 @@ sub pp_right_shift { maybe_targmy(@_, \&binop, ">>", 17, ASSIGN) } sub pp_bit_and { maybe_targmy(@_, \&binop, "&", 13, ASSIGN) } sub pp_bit_or { maybe_targmy(@_, \&binop, "|", 12, ASSIGN) } sub pp_bit_xor { maybe_targmy(@_, \&binop, "^", 12, ASSIGN) } +*pp_nbit_and = *pp_bit_and; +*pp_nbit_or = *pp_bit_or; +*pp_nbit_xor = *pp_bit_xor; +sub pp_sbit_and { maybe_targmy(@_, \&binop, "&.", 13, ASSIGN) } +sub pp_sbit_or { maybe_targmy(@_, \&binop, "|.", 12, ASSIGN) } +sub pp_sbit_xor { maybe_targmy(@_, \&binop, "^.", 12, ASSIGN) } sub pp_eq { binop(@_, "==", 14) } sub pp_ne { binop(@_, "!=", 14) } @@ -4358,8 +4369,8 @@ sub retscalar { |divide|i_divide|modulo|i_modulo|add|i_add|subtract |i_subtract|concat|stringify|left_shift|right_shift|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|bit_and|bit_xor|bit_or - |negate|i_negate|not|complement|smartmatch|atan2|sin|cos + |slt|sgt|sle|sge|seq|sne|scmp|[sn]?bit_(?:and|x?or)|negate + |i_negate|not|[sn]?complement|smartmatch|atan2|sin|cos |rand|srand|exp|log|sqrt|int|hex|oct|abs|length|substr |vec|index|rindex|sprintf|formline|ord|chr|crypt|ucfirst |lcfirst|uc|lc|quotemeta|aelemfast|aelem|exists|helem diff --git a/lib/B/Deparse.t b/lib/B/Deparse.t index d1764b1..3cfc9e0 100644 --- a/lib/B/Deparse.t +++ b/lib/B/Deparse.t @@ -1857,12 +1857,12 @@ my sub f {} print f(); >>>> use feature 'lexical_subs'; -BEGIN {${^WARNING_BITS} = "\x54\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x55\x55\x55"} +BEGIN {${^WARNING_BITS} = "\x54\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x55\x55\x55\x01"} my sub f { - BEGIN {${^WARNING_BITS} = "\x54\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x55\x55"} + BEGIN {${^WARNING_BITS} = "\x54\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x55\x55\x01"} } -BEGIN {${^WARNING_BITS} = "\x54\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x55\x55"} +BEGIN {${^WARNING_BITS} = "\x54\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x55\x55\x01"} print f(); #### # SKIP ?$] < 5.017004 && "lexical subs not implemented on this Perl version" @@ -1873,13 +1873,13 @@ state sub f {} print f(); >>>> use feature 'lexical_subs'; -BEGIN {${^WARNING_BITS} = "\x54\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x55\x55\x55"} +BEGIN {${^WARNING_BITS} = "\x54\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x55\x55\x55\x01"} CORE::state sub f { - BEGIN {${^WARNING_BITS} = "\x54\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x55\x55"} + BEGIN {${^WARNING_BITS} = "\x54\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x55\x55\x01"} use feature 'state'; } -BEGIN {${^WARNING_BITS} = "\x54\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x55\x55"} +BEGIN {${^WARNING_BITS} = "\x54\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x55\x55\x01"} use feature 'state'; print f(); #### @@ -2366,3 +2366,20 @@ my $x = $h{'foo'}[$i + $j]{$k}; chdir 'file'; chdir FH; chdir; +#### +# 5.22 bitops +# CONTEXT use feature "bitwise"; no warnings "experimental::bitwise"; +$_ = $_ | $_; +$_ = $_ & $_; +$_ = $_ ^ $_; +$_ = ~$_; +$_ = $_ |. $_; +$_ = $_ &. $_; +$_ = $_ ^. $_; +$_ = ~.$_; +$_ |= $_; +$_ &= $_; +$_ ^= $_; +$_ |.= $_; +$_ &.= $_; +$_ ^.= $_; diff --git a/lib/B/Op_private.pm b/lib/B/Op_private.pm index 75317ec..03a5a83 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_multi ... [309 chars truncated] +$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_multi ... [359 chars truncated] $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_multip ... [309 chars truncated] + 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_multip ... [359 chars truncated] OPpTRANS_COMPLEMENT => [qw(trans transr)], ); diff --git a/lib/feature.pm b/lib/feature.pm index de237b7..70d8ada 100644 --- a/lib/feature.pm +++ b/lib/feature.pm @@ -5,13 +5,14 @@ package feature; -our $VERSION = '1.39'; +our $VERSION = '1.40'; our %feature = ( fc => 'feature_fc', say => 'feature_say', state => 'feature_state', switch => 'feature_switch', + bitwise => 'feature_bitwise', evalbytes => 'feature_evalbytes', postderef => 'feature_postderef', array_base => 'feature_arybase', @@ -28,7 +29,7 @@ our %feature_bundle = ( "5.10" => [qw(array_base say state switch)], "5.11" => [qw(array_base say state switch unicode_strings)], "5.15" => [qw(current_sub evalbytes fc say state switch unicode_eval unicode_strings)], - "all" => [qw(array_base current_sub evalbytes fc lexical_subs postderef postderef_qq refaliasing say signatures state switch unicode_eval unicode_strings)], + "all" => [qw(array_base bitwise current_sub evalbytes fc lexical_subs postderef postderef_qq refaliasing say signatures state switch unicode_eval unicode_strings)], "default" => [qw(array_base)], ); @@ -319,6 +320,24 @@ See L<perlref/Assigning to References> for details. This feature is available from Perl 5.22 onwards. +=head2 The 'bitwise' feature + +B<WARNING>: This feature is still experimental and the implementation may +change in future versions of Perl. For this reason, Perl will +warn when you use the feature, unless you have explicitly disabled the +warning: + + no warnings "experimental::bitwise"; + +This makes the four standard bitwise operators (C<& | ^ ~>) treat their +operands consistently as numbers, and introduces four new dotted operators +(C<&. |. ^. ~.>) that treat their operands consistently as strings. The +same applies to the assignment variants (C<&= |= ^= &.= |.= ^.=>). + +See L<perlop/Bitwise String Operators> for details. + +This feature is available from Perl 5.22 onwards. + =head1 FEATURE BUNDLES It's possible to load multiple features together, using diff --git a/lib/overload.pm b/lib/overload.pm index dc37380..414c386 100644 --- a/lib/overload.pm +++ b/lib/overload.pm @@ -1,6 +1,6 @@ package overload; -our $VERSION = '1.24'; +our $VERSION = '1.25'; %ops = ( with_assign => "+ - * / % ** << >> x .", @@ -8,8 +8,8 @@ our $VERSION = '1.24'; num_comparison => "< <= > >= == !=", '3way_comparison' => "<=> cmp", str_comparison => "lt le gt ge eq ne", - binary => '& &= | |= ^ ^=', - unary => "neg ! ~", + binary => '& &= | |= ^ ^= &. &.= |. |.= ^. ^.=', + unary => "neg ! ~ ~.", mutators => '++ --', func => "atan2 cos sin exp abs log sqrt int", conversion => 'bool "" 0+ qr', @@ -252,7 +252,9 @@ illustrates the calling conventions: # * may recurse once - see table below Three arguments are passed to all subroutines specified in the -C<use overload> directive (with one exception - see L</nomethod>). +C<use overload> directive (with exceptions - see below, particularly +L</nomethod>). + The first of these is the operand providing the overloaded operator implementation - in this case, the object whose C<minus()> method is being called. @@ -310,6 +312,12 @@ An appropriate implementation of C<--> might look like # ... sub decr { --${$_[0]}; } +If the experimental "bitwise" feature is enabled (see L<feature>), a fifth +TRUE argument is passed to subroutines handling C<&>, C<|>, C<^> and C<~>. +This indicates that the caller is expecting numeric behaviour. The fourth +argument will be C<undef>, as that position (C<$_[3]>) is reserved for use +by L</nomethod>. + =head3 Mathemagic, Mutators, and Copy Constructors The term 'mathemagic' describes the overloaded implementation @@ -361,8 +369,8 @@ hash C<%overload::ops>: num_comparison => '< <= > >= == !=', '3way_comparison'=> '<=> cmp', str_comparison => 'lt le gt ge eq ne', - binary => '& &= | |= ^ ^=', - unary => 'neg ! ~', + binary => '& &= | |= ^ ^= &. &.= |. |.= ^. ^.=', + unary => 'neg ! ~ ~.', mutators => '++ --', func => 'atan2 cos sin exp abs log sqrt int', conversion => 'bool "" 0+ qr', @@ -407,7 +415,7 @@ evaluating an expression. =item * I<Assignments> += -= *= /= %= **= <<= >>= x= .= - &= |= ^= + &= |= ^= &.= |.= ^.= Simple assignment is not overloadable (the C<'='> key is used for the L<Copy Constructor>). @@ -437,7 +445,7 @@ even if C<$a> is a scalar. =item * I<Non-mutators with a mutator variant> + - * / % ** << >> x . - & | ^ + & | ^ &. |. ^. As described L<above|"Calling Conventions and Magic Autogeneration">, Perl may call methods for operators like C<+> and C<&> in the course @@ -650,9 +658,9 @@ to C<'-='> and C<'--'> above: And other assignment variations are analogous to C<'+='> and C<'-='> (and similar to C<'.='> and C<'x='> above): - operator || *= /= %= **= <<= >>= &= ^= |= - -------------------||-------------------------------- - autogenerated from || * / % ** << >> & ^ | + operator || *= /= %= **= <<= >>= &= ^= |= &.= ^.= |.= + -------------------||------------------------------------------- + autogenerated from || * / % ** << >> & ^ | &. ^. |. Note also that the copy constructor (key C<'='>) may be autogenerated, but only for objects based on scalars. @@ -668,7 +676,7 @@ expects. The minimal set is: + - * / % ** << >> x <=> cmp - & | ^ ~ + & | ^ ~ &. |. ^. ~. atan2 cos sin exp log sqrt int "" 0+ bool ~~ @@ -686,7 +694,8 @@ The specified function will be passed four parameters. The first three arguments coincide with those that would have been passed to the corresponding method if it had been defined. The fourth argument is the C<use overload> key for that missing -method. +method. If the experimental "bitwise" feature is enabled (see L<feature>), +a fifth TRUE argument is passed to subroutines handling C<&>, C<|>, C<^> and C<~> to indicate that the caller is expecting numeric behaviour. For example, if C<$a> is an object blessed into a package declaring @@ -1054,7 +1063,7 @@ the stashes, which are rarely used directly, thus should not slow down Perl.) If a package uses overload, it carries a special flag. This flag is also -set when new function are defined or @ISA is modified. There will be a +set when new functions are defined or @ISA is modified. There will be a slight speed penalty on the very first operation thereafter that supports overloading, while the overload tables are updated. If there is no overloading present, the flag is turned off. Thus the only speed penalty diff --git a/lib/overload.t b/lib/overload.t index 524d99f..6bbbb0b 100644 --- a/lib/overload.t +++ b/lib/overload.t @@ -48,7 +48,7 @@ package main; $| = 1; BEGIN { require './test.pl' } -plan tests => 5199; +plan tests => 5215; use Scalar::Util qw(tainted); @@ -2754,6 +2754,69 @@ is join(",", 1..3, scalar((bless([], 'xstack')) x 3, 1), 4..6), "1,2,3,1,4,5,6", '(...)x... in void cx with x overloaded [perl #121827]'; +package bitops { + our @o; + use overload do { + my %o; + for my $o (qw(& | ^ ~ &. |. ^. ~. &= |= ^= &.= |.= ^.=)) { + $o{$o} = sub { + ::ok !defined $_[3], "undef (or nonexistent) arg 3 for $o"; + push @o, $o, scalar @_, $_[4]//'u'; + $_[0] + } + } + %o, '=' => sub { bless [] }; + } +} +{ + use experimental 'bitwise'; + my $o = bless [], bitops::; + $_ = $o & 0; + $_ = $o | 0; + $_ = $o ^ 0; + $_ = ~$o; + $_ = $o &. 0; + $_ = $o |. 0; + $_ = $o ^. 0; + $_ = ~.$o; + $o &= 0; + $o |= 0; + $o ^= 0; + $o &.= 0; + $o |.= 0; + $o ^.= 0; + # elems are in triplets: op, length of @_, numeric? (1/u for y/n) + is "@bitops::o", '& 5 1 | 5 1 ^ 5 1 ~ 5 1 &. 3 u |. 3 u ^. 3 u ~. 3 u ' . '&= 5 1 |= 5 1 ^= 5 1 &.= 3 u |.= 3 u ^.= 3 u', + 'experimental "bitwise" ops' +} +package bitops2 { + our @o; + use overload + nomethod => sub { push @o, $_[3], scalar @_, $_[4]//'u'; $_[0] }, + '=' => sub { bless [] }; +} +{ + use experimental 'bitwise'; + my $o = bless [], bitops2::; + $_ = $o & 0; + $_ = $o | 0; + $_ = $o ^ 0; + $_ = ~$o; + $_ = $o &. 0; + $_ = $o |. 0; + $_ = $o ^. 0; + $_ = ~.$o; + $o &= 0; + $o |= 0; + $o ^= 0; + $o &.= 0; + $o |.= 0; + $o ^.= 0; + # elems are in triplets: op, length of @_, numeric? (1/u for y/n) + is "@bitops2::o", '& 5 1 | 5 1 ^ 5 1 ~ 5 1 &. 4 u |. 4 u ^. 4 u ~. 4 u ' . '&= 5 1 |= 5 1 ^= 5 1 &.= 4 u |.= 4 u ^.= 4 u', + 'experimental "bitwise" ops with nomethod' +} + { # undefining the overload stash -- KEEP THIS TEST LAST package ant; use overload '+' => 'onion'; diff --git a/lib/overload/numbers.pm b/lib/overload/numbers.pm index a90c175..ccea9e1 100644 --- a/lib/overload/numbers.pm +++ b/lib/overload/numbers.pm @@ -62,13 +62,20 @@ our @names = qw# (>>= (& (&= + (&. + (&.= (| (|= + (|. + (|.= (^ (^= + (^. + (^.= (<=> (cmp (~ + (~. (atan2 (cos (sin @@ -133,13 +140,20 @@ our @enums = qw# rshift_ass band band_ass + sband + sband_ass bor bor_ass + sbor + sbor_ass bxor bxor_ass + sbxor + sbxor_ass ncmp scmp compl + scompl atan2 cos sin diff --git a/lib/warnings.pm b/lib/warnings.pm index 80c9cd9..cad00ea 100644 --- a/lib/warnings.pm +++ b/lib/warnings.pm @@ -86,17 +86,18 @@ our %Offsets = ( 'syscalls' => 118, # Warnings Categories added in Perl 5.021 - 'experimental::const_attr' => 120, - 'experimental::re_strict' => 122, - 'experimental::refaliasing' => 124, - 'experimental::win32_perlio' => 126, - 'locale' => 128, - 'missing' => 130, - 'redundant' => 132, + 'experimental::bitwise' => 120, + 'experimental::const_attr' => 122, + 'experimental::re_strict' => 124, + 'experimental::refaliasing' => 126, + 'experimental::win32_perlio' => 128, + 'locale' => 130, + 'missing' => 132, + 'redundant' => 134, ); our %Bits = ( - 'all' => "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x15", # [0..66] + 'all' => "\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55", # [0..67] 'ambiguous' => "\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [29] 'bareword' => "\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [30] 'closed' => "\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [6] @@ -106,18 +107,19 @@ our %Bits = ( 'digit' => "\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [31] 'exec' => "\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [7] 'exiting' => "\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [3] - 'experimental' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x55\x15\x55\x00", # [51..58,60..63] + 'experimental' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x55\x15\x55\x01", # [51..58,60..64] 'experimental::autoderef' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00", # [56] - 'experimental::const_attr' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00", # [60] + 'experimental::bitwise' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00", # [60] + 'experimental::const_attr' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00", # [61] 'experimental::lexical_subs' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00", # [52] 'experimental::lexical_topic' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00", # [53] 'experimental::postderef' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00", # [57] - 'experimental::re_strict' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00", # [61] - 'experimental::refaliasing' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00", # [62] + 'experimental::re_strict' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00", # [62] + 'experimental::refaliasing' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00", # [63] 'experimental::regex_sets' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00", # [54] 'experimental::signatures' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00", # [58] 'experimental::smartmatch' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00", # [55] - 'experimental::win32_perlio' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00", # [63] + 'experimental::win32_perlio' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01", # [64] 'glob' => "\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [4] 'illegalproto' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00", # [47] 'imprecision' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00", # [46] @@ -125,10 +127,10 @@ our %Bits = ( 'internal' => "\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [24] 'io' => "\x00\x54\x55\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00", # [5..11,59] 'layer' => "\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [8] - 'locale' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01", # [64] + 'locale' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04", # [65] 'malloc' => "\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [25] 'misc' => "\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [12] - 'missing' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04", # [65] + 'missing' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10", # [66] 'newline' => "\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [9] 'non_unicode' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00", # [48] 'nonchar' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00", # [49] @@ -145,7 +147,7 @@ our %Bits = ( 'qw' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00", # [36] 'recursion' => "\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [18] 'redefine' => "\x00\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [19] - 'redundant' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10", # [66] + 'redundant' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40", # [67] 'regexp' => "\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [20] 'reserved' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00", # [37] 'semicolon' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00", # [38] @@ -166,7 +168,7 @@ our %Bits = ( ); our %DeadBits = ( - 'all' => "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\x2a", # [0..66] + 'all' => "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa", # [0..67] 'ambiguous' => "\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [29] 'bareword' => "\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [30] 'closed' => "\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [6] @@ -176,18 +178,19 @@ our %DeadBits = ( 'digit' => "\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [31] 'exec' => "\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [7] 'exiting' => "\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [3] - 'experimental' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\xaa\x2a\xaa\x00", # [51..58,60..63] + 'experimental' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\xaa\x2a\xaa\x02", # [51..58,60..64] 'experimental::autoderef' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00", # [56] - 'experimental::const_attr' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00", # [60] + 'experimental::bitwise' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00", # [60] + 'experimental::const_attr' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00", # [61] 'experimental::lexical_subs' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00", # [52] 'experimental::lexical_topic' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00", # [53] 'experimental::postderef' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00", # [57] - 'experimental::re_strict' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00", # [61] - 'experimental::refaliasing' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00", # [62] + 'experimental::re_strict' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00", # [62] + 'experimental::refaliasing' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00", # [63] 'experimental::regex_sets' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00", # [54] 'experimental::signatures' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00", # [58] 'experimental::smartmatch' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00", # [55] - 'experimental::win32_perlio' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00", # [63] + 'experimental::win32_perlio' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02", # [64] 'glob' => "\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [4] 'illegalproto' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00", # [47] 'imprecision' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00", # [46] @@ -195,10 +198,10 @@ our %DeadBits = ( 'internal' => "\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [24] 'io' => "\x00\xa8\xaa\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00", # [5..11,59] 'layer' => "\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [8] - 'locale' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02", # [64] + 'locale' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08", # [65] 'malloc' => "\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [25] 'misc' => "\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [12] - 'missing' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08", # [65] + 'missing' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20", # [66] 'newline' => "\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [9] 'non_unicode' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00", # [48] 'nonchar' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00", # [49] @@ -215,7 +218,7 @@ our %DeadBits = ( 'qw' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00", # [36] 'recursion' => "\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [18] 'redefine' => "\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [19] - 'redundant' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20", # [66] + 'redundant' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80", # [67] 'regexp' => "\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", # [20] 'reserved' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00", # [37] 'semicolon' => "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\x00\x00\x00\x00\x00\x00", # [38] @@ -237,8 +240,8 @@ our %DeadBits = ( # These are used by various things, including our own tests our $NONE = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; -our $DEFAULT = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x00\x55\x15\x55\x01", # [2,56,60,52,53,57,61,62,54,58,55,63,4,64,22,23,25] -our $LAST_BIT = 134 ; +our $DEFAULT = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x00\x55\x15\x55\x05", # [2,56,60,61,52,53,57,62,63,54,58,55,64,4,65,22,23,25] +our $LAST_BIT = 136 ; our $BYTES = 17 ; our $All = "" ; vec($All, $Offsets{'all'}, 2) = 3 ; @@ -725,6 +728,8 @@ The current hierarchy is: | | | +- experimental::autoderef | | + | +- experimental::bitwise + | | | +- experimental::const_attr | | | +- experimental::lexical_subs diff --git a/op.c b/op.c index 5aeedfc..db53f97 100644 --- a/op.c +++ b/op.c @@ -9481,10 +9481,15 @@ Perl_ck_bitop(pTHX_ OP *o) PERL_ARGS_ASSERT_CK_BITOP; o->op_private = (U8)(PL_hints & HINT_INTEGER); + + if (o->op_type == OP_NBIT_OR || o->op_type == OP_SBIT_OR + || o->op_type == OP_NBIT_XOR || o->op_type == OP_SBIT_XOR + || o->op_type == OP_NBIT_AND || o->op_type == OP_SBIT_AND + || o->op_type == OP_NCOMPLEMENT || o->op_type == OP_SCOMPLEMENT) + Perl_ck_warner_d(aTHX_ packWARN(WARN_EXPERIMENTAL__BITWISE), + "The bitwise feature is experimental"); if (!(o->op_flags & OPf_STACKED) /* Not an assignment */ - && (o->op_type == OP_BIT_OR - || o->op_type == OP_BIT_AND - || o->op_type == OP_BIT_XOR)) + && OP_IS_INFIX_BIT(o->op_type)) { const OP * const left = cBINOPo->op_first; const OP * const right = OpSIBLING(left); @@ -9493,9 +9498,15 @@ Perl_ck_bitop(pTHX_ OP *o) (OP_IS_NUMCOMPARE(right->op_type) && (right->op_flags & OPf_PARENS) == 0)) Perl_ck_warner(aTHX_ packWARN(WARN_PRECEDENCE), - "Possible precedence problem on bitwise %c operator", - o->op_type == OP_BIT_OR ? '|' - : o->op_type == OP_BIT_AND ? '&' : '^' + "Possible precedence problem on bitwise %s operator", + o->op_type == OP_BIT_OR + ||o->op_type == OP_NBIT_OR ? "|" + : o->op_type == OP_BIT_AND + ||o->op_type == OP_NBIT_AND ? "&" + : o->op_type == OP_BIT_XOR + ||o->op_type == OP_NBIT_XOR ? "^" + : o->op_type == OP_SBIT_OR ? "|." + : o->op_type == OP_SBIT_AND ? "&." : "^." ); } return o; diff --git a/opcode.h b/opcode.h index 5d910fd..cf39a4b 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_bitop, /* 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, getpgr ... [46 chars truncated] 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 013350a..c225ac4 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 @@ -428,4 +436,7 @@ typedef enum opcode { #define OP_IS_DIRHOP(op) \ ((op) >= OP_READDIR && (op) <= OP_CLOSEDIR) +#define OP_IS_INFIX_BIT(op) \ + ((op) >= OP_BIT_AND && (op) <= OP_SBIT_OR) + /* ex: set ro: */ diff --git a/overload.c b/overload.c index cd28df4..3cf64c7 100644 --- a/overload.c +++ b/overload.c @@ -65,13 +65,20 @@ static const U8 PL_AMG_namelens[NofAMmeth] = { 4, 2, 3, + 3, + 4, 2, 3, + 3, + 4, 2, 3, + 3, + 4, 4, 4, 2, + 3, 6, 4, 4, @@ -141,13 +148,20 @@ static const char * const PL_AMG_names[NofAMmeth] = { "(>>=", /* rshift_ass */ "(&", /* band */ "(&=", /* band_ass */ + "(&.", /* sband */ + "(&.=", /* sband_ass */ "(|", /* bor */ "(|=", /* bor_ass */ + "(|.", /* sbor */ + "(|.=", /* sbor_ass */ "(^", /* bxor */ "(^=", /* bxor_ass */ + "(^.", /* sbxor */ + "(^.=", /* sbxor_ass */ "(<=>", /* ncmp */ "(cmp", /* scmp */ "(~", /* compl */ + "(~.", /* scompl */ "(atan2", /* atan2 */ "(cos", /* cos */ "(sin", /* sin */ diff --git a/overload.h b/overload.h index 1628ac0..50e7660 100644 --- a/overload.h +++ b/overload.h @@ -62,26 +62,33 @@ enum { rshift_ass_amg, /* 0x2d >>= */ band_amg, /* 0x2e & */ band_ass_amg, /* 0x2f &= */ - bor_amg, /* 0x30 | */ - bor_ass_amg, /* 0x31 |= */ - bxor_amg, /* 0x32 ^ */ - bxor_ass_amg, /* 0x33 ^= */ - ncmp_amg, /* 0x34 <=> */ - scmp_amg, /* 0x35 cmp */ - compl_amg, /* 0x36 ~ */ - atan2_amg, /* 0x37 atan2 */ - cos_amg, /* 0x38 cos */ - sin_amg, /* 0x39 sin */ - exp_amg, /* 0x3a exp */ - log_amg, /* 0x3b log */ - sqrt_amg, /* 0x3c sqrt */ - repeat_amg, /* 0x3d x */ - repeat_ass_amg, /* 0x3e x= */ - concat_amg, /* 0x3f . */ - concat_ass_amg, /* 0x40 .= */ - smart_amg, /* 0x41 ~~ */ - ftest_amg, /* 0x42 -X */ - regexp_amg, /* 0x43 qr */ + sband_amg, /* 0x30 &. */ + sband_ass_amg, /* 0x31 &.= */ + bor_amg, /* 0x32 | */ + bor_ass_amg, /* 0x33 |= */ + sbor_amg, /* 0x34 |. */ + sbor_ass_amg, /* 0x35 |.= */ + bxor_amg, /* 0x36 ^ */ + bxor_ass_amg, /* 0x37 ^= */ + sbxor_amg, /* 0x38 ^. */ + sbxor_ass_amg, /* 0x39 ^.= */ + ncmp_amg, /* 0x3a <=> */ + scmp_amg, /* 0x3b cmp */ + compl_amg, /* 0x3c ~ */ + scompl_amg, /* 0x3d ~. */ + atan2_amg, /* 0x3e atan2 */ + cos_amg, /* 0x3f cos */ + sin_amg, /* 0x40 sin */ + exp_amg, /* 0x41 exp */ + log_amg, /* 0x42 log */ + sqrt_amg, /* 0x43 sqrt */ + repeat_amg, /* 0x44 x */ + repeat_ass_amg, /* 0x45 x= */ + concat_amg, /* 0x46 . */ + concat_ass_amg, /* 0x47 .= */ + smart_amg, /* 0x48 ~~ */ + ftest_amg, /* 0x49 -X */ + regexp_amg, /* 0x4a qr */ max_amg_code /* Do not leave a trailing comma here. C9X allows it, C89 doesn't. */ }; diff --git a/perly.act b/perly.act index 5519ed2..4c06834 100644 --- a/perly.act +++ b/perly.act @@ -8,7 +8,7 @@ case 2: #line 115 "perly.y" { parser->expect = XSTATE; - } + ;} break; case 3: @@ -17,14 +17,14 @@ case 2: newPROG(block_end((ps[(3) - (4)].val.ival),(ps[(4) - (4)].val.opval))); PL_compiling.cop_seq = 0; (yyval.ival) = 0; - } + ;} break; case 4: #line 125 "perly.y" { parser->expect = XTERM; - } + ;} break; case 5: @@ -32,14 +32,14 @@ case 2: { PL_eval_root = (ps[(3) - (3)].val.opval); (yyval.ival) = 0; - } + ;} break; case 6: #line 134 "perly.y" { parser->expect = XBLOCK; - } + ;} break; case 7: @@ -50,14 +50,14 @@ case 2: (yyval.ival) = 0; yyunlex(); parser->yychar = YYEOF; - } + ;} break; case 8: #line 146 "perly.y" { parser->expect = XSTATE; - } + ;} break; case 9: @@ -68,14 +68,14 @@ case 2: (yyval.ival) = 0; yyunlex(); parser->yychar = YYEOF; - } + ;} break; case 10: #line 158 "perly.y" { parser->expect = XSTATE; - } + ;} break; case 11: @@ -86,14 +86,14 @@ case 2: (yyval.ival) = 0; yyunlex(); parser->yychar = YYEOF; - } + ;} break; case 12: #line 170 "perly.y" { parser->expect = XSTATE; - } + ;} break; case 13: @@ -101,7 +101,7 @@ case 2: { PL_eval_root = (ps[(3) - (3)].val.opval); (yyval.ival) = 0; - } + ;} break; case 14: @@ -109,7 +109,7 @@ case 2: { if (parser->copline > (line_t)(ps[(1) - (4)].val.ival)) parser->copline = (line_t)(ps[(1) - (4)].val.ival); (yyval.opval) = block_end((ps[(2) - (4)].val.ival), (ps[(3) - (4)].val.opval)); - } + ;} break; case 15: @@ -117,13 +117,13 @@ case 2: { if (parser->copline > (line_t)(ps[(1) - (7)].val.ival)) parser->copline = (line_t)(ps[(1) - (7)].val.ival); (yyval.opval) = block_end((ps[(2) - (7)].val.ival), (ps[(5) - (7)].val.opval)); - } + ;} break; case 16: #line 197 "perly.y" { (yyval.ival) = block_start(TRUE); - parser->parsed_sub = 0; } + parser->parsed_sub = 0; ;} break; case 17: @@ -131,18 +131,18 @@ case 2: { if (parser->copline > (line_t)(ps[(1) - (4)].val.ival)) parser->copline = (line_t)(ps[(1) - (4)].val.ival); (yyval.opval) = block_end((ps[(2) - (4)].val.ival), (ps[(3) - (4)].val.opval)); - } + ;} break; case 18: #line 209 "perly.y" { (yyval.ival) = block_start(FALSE); - parser->parsed_sub = 0; } + parser->parsed_sub = 0; ;} break; case 19: #line 215 "perly.y" - { (yyval.opval) = (OP*)NULL; } + { (yyval.opval) = (OP*)NULL; ;} break; case 20: @@ -151,12 +151,12 @@ case 2: PL_pad_reset_pending = TRUE; if ((ps[(1) - (2)].val.opval) && (ps[(2) - (2)].val.opval)) PL_hints |= HINT_BLOCK_SCOPE; - } + ;} break; case 21: #line 226 "perly.y" - { (yyval.opval) = (OP*)NULL; } + { (yyval.opval) = (OP*)NULL; ;} break; case 22: @@ -165,38 +165,38 @@ case 2: PL_pad_reset_pending = TRUE; if ((ps[(1) - (2)].val.opval) && (ps[(2) - (2)].val.opval)) PL_hints |= HINT_BLOCK_SCOPE; - } + ;} break; case 23: #line 237 "perly.y" { (yyval.opval) = (ps[(1) - (1)].val.opval) ? newSTATEOP(0, NULL, (ps[(1) - (1)].val.opval)) : NULL; - } + ;} break; case 24: #line 241 "perly.y" - { (yyval.opval) = (ps[(1) - (1)].val.opval); } + { (yyval.opval) = (ps[(1) - (1)].val.opval); ;} break; case 25: #line 245 "perly.y" { (yyval.opval) = newSTATEOP(SVf_UTF8 * (ps[(1) - (2)].val.pval)[strlen((ps[(1) - (2)].val.pval))+1], (ps[(1) - (2)].val.pval), (ps[(2) - (2)].val.opval)); - } + ;} break; case 26: #line 249 "perly.y" { (yyval.opval) = newSTATEOP(SVf_UTF8 * (ps[(1) - (2)].val.pval)[strlen((ps[(1) - (2)].val.pval))+1], (ps[(1) - (2)].val.pval), (ps[(2) - (2)].val.opval)); - } + ;} break; case 27: #line 256 "perly.y" - { (yyval.opval) = (ps[(1) - (1)].val.opval); } + { (yyval.opval) = (ps[(1) - (1)].val.opval); ;} break; case 28: @@ -209,7 +209,7 @@ case 2: pad_add_weakref(fmtcv); } parser->parsed_sub = 1; - } + ;} break; case 29: @@ -234,7 +234,7 @@ case 2: CvCLONE_on(PL_compcv); parser->in_my = 0; parser->in_my_stash = NULL; - } + ;} break; case 30: @@ -248,7 +248,7 @@ case 2: (yyval.opval) = (OP*)NULL; intro_my(); parser->parsed_sub = 1; - } + ;} break; case 31: @@ -273,7 +273,7 @@ case 2: CvCLONE_on(PL_compcv); parser->in_my = 0; parser->in_my_stash = NULL; - } + ;} break; case 32: @@ -293,7 +293,7 @@ case 2: (yyval.opval) = (OP*)NULL; intro_my(); parser->parsed_sub = 1; - } + ;} break; case 33: @@ -303,12 +303,12 @@ case 2: if ((ps[(2) - (4)].val.opval)) package_version((ps[(2) - (4)].val.opval)); (yyval.opval) = (OP*)NULL; - } + ;} break; case 34: #line 347 "perly.y" - { CvSPECIAL_on(PL_compcv); /* It's a BEGIN {} */ } + { CvSPECIAL_on(PL_compcv); /* It's a BEGIN {} */ ;} break; case 35: @@ -318,7 +318,7 @@ case 2: utilize((ps[(1) - (7)].val.ival), (ps[(2) - (7)].val.ival), (ps[(4) - (7)].val.opval), (ps[(5) - (7)].val.opval), (ps[(6) - (7)].val.opval)); parser->parsed_sub = 1; (yyval.opval) = (OP*)NULL; - } + ;} break; case 36: @@ -327,7 +327,7 @@ case 2: (yyval.opval) = block_end((ps[(3) - (7)].val.ival), newCONDOP(0, (ps[(4) - (7)].val.opval), op_scope((ps[(6) - (7)].val.opval)), (ps[(7) - (7)].val.opval))); parser->copline = (line_t)(ps[(1) - (7)].val.ival); - } + ;} break; case 37: @@ -336,7 +336,7 @@ case 2: (yyval.opval) = block_end((ps[(3) - (7)].val.ival), newCONDOP(0, (ps[(4) - (7)].val.opval), op_scope((ps[(6) - (7)].val.opval)), (ps[(7) - (7)].val.opval))); parser->copline = (line_t)(ps[(1) - (7)].val.ival); - } + ;} break; case 38: @@ -350,17 +350,17 @@ case 2: ? 0 : offset)); parser->copline = (line_t)(ps[(1) - (6)].val.ival); - } + ;} break; case 39: #line 379 "perly.y" - { (yyval.opval) = block_end((ps[(3) - (6)].val.ival), newWHENOP((ps[(4) - (6)].val.opval), op_scope((ps[(6) - (6)].val.opval)))); } + { (yyval.opval) = block_end((ps[(3) - (6)].val.ival), newWHENOP((ps[(4) - (6)].val.opval), op_scope((ps[(6) - (6)].val.opval)))); ;} break; case 40: #line 381 "perly.y" - { (yyval.opval) = newWHENOP(0, op_scope((ps[(2) - (2)].val.opval))); } + { (yyval.opval) = newWHENOP(0, op_scope((ps[(2) - (2)].val.opval))); ;} break; case 41: @@ -370,7 +370,7 @@ case 2: newWHILEOP(0, 1, (LOOP*)(OP*)NULL, (ps[(4) - (8)].val.opval), (ps[(7) - (8)].val.opval), (ps[(8) - (8)].val.opval), (ps[(6) - (8)].val.ival))); parser->copline = (line_t)(ps[(1) - (8)].val.ival); - } + ;} break; case 42: @@ -380,17 +380,17 @@ case 2: newWHILEOP(0, 1, (LOOP*)(OP*)NULL, (ps[(4) - (8)].val.opval), (ps[(7) - (8)].val.opval), (ps[(8) - (8)].val.opval), (ps[(6) - (8)].val.ival))); **** PATCH TRUNCATED AT 2000 LINES -- 2496 NOT SHOWN **** -- Perl5 Master Repository
