summaryrefslogtreecommitdiff
path: root/lib/B
diff options
context:
space:
mode:
authorJames Raspass <jraspass@gmail.com>2022-06-11 23:33:31 +0100
committerTony Cook <tony@develop-help.com>2022-07-05 11:17:31 +1000
commita02b8151f9b69201233f9ca5774db280c34684de (patch)
treec783043e3e74ece3c98f4c71d828aa4eb571adc5 /lib/B
parentc5327cb77526e4e4c7bb83e24be20ac48e85b1fa (diff)
downloadperl-a02b8151f9b69201233f9ca5774db280c34684de.tar.gz
Add builtin::is_tainted
Also tweak the implementation of the other two boolean builtins (is_bool & is_weak) to be slightly more efficient.
Diffstat (limited to 'lib/B')
-rw-r--r--lib/B/Deparse.pm22
-rw-r--r--lib/B/Deparse.t1
-rw-r--r--lib/B/Op_private.pm5
3 files changed, 15 insertions, 13 deletions
diff --git a/lib/B/Deparse.pm b/lib/B/Deparse.pm
index 7c2ecf992c..fbd12e73b7 100644
--- a/lib/B/Deparse.pm
+++ b/lib/B/Deparse.pm
@@ -7,7 +7,7 @@
# This is based on the module of the same name by Malcolm Beattie,
# but essentially none of his code remains.
-package B::Deparse;
+package B::Deparse 1.65;
use strict;
use Carp;
use B qw(class main_root main_start main_cv svref_2object opnumber perlstring
@@ -53,7 +53,6 @@ use B qw(class main_root main_start main_cv svref_2object opnumber perlstring
MDEREF_SHIFT
);
-our $VERSION = '1.64';
our $AUTOLOAD;
use warnings ();
require feature;
@@ -6660,15 +6659,16 @@ sub builtin1 {
return "builtin::$name($arg)";
}
-sub pp_is_bool { $_[0]->maybe_targmy(@_[1,2], \&builtin1, "is_bool"); }
-sub pp_is_weak { $_[0]->maybe_targmy(@_[1,2], \&builtin1, "is_weak"); }
-sub pp_weaken { builtin1(@_, "weaken"); }
-sub pp_unweaken { builtin1(@_, "unweaken"); }
-sub pp_blessed { builtin1(@_, "blessed"); }
-sub pp_refaddr { $_[0]->maybe_targmy(@_[1,2], \&builtin1, "refaddr"); }
-sub pp_reftype { $_[0]->maybe_targmy(@_[1,2], \&builtin1, "reftype"); }
-sub pp_ceil { $_[0]->maybe_targmy(@_[1,2], \&builtin1, "ceil"); }
-sub pp_floor { $_[0]->maybe_targmy(@_[1,2], \&builtin1, "floor"); }
+sub pp_is_bool { builtin1(@_, "is_bool"); }
+sub pp_is_weak { builtin1(@_, "is_weak"); }
+sub pp_weaken { builtin1(@_, "weaken"); }
+sub pp_unweaken { builtin1(@_, "unweaken"); }
+sub pp_blessed { builtin1(@_, "blessed"); }
+sub pp_refaddr { $_[0]->maybe_targmy(@_[1,2], \&builtin1, "refaddr"); }
+sub pp_reftype { $_[0]->maybe_targmy(@_[1,2], \&builtin1, "reftype"); }
+sub pp_ceil { $_[0]->maybe_targmy(@_[1,2], \&builtin1, "ceil"); }
+sub pp_floor { $_[0]->maybe_targmy(@_[1,2], \&builtin1, "floor"); }
+sub pp_is_tainted { builtin1(@_, "is_tainted"); }
1;
__END__
diff --git a/lib/B/Deparse.t b/lib/B/Deparse.t
index e7a76c81fe..535719e966 100644
--- a/lib/B/Deparse.t
+++ b/lib/B/Deparse.t
@@ -3221,6 +3221,7 @@ $x = builtin::refaddr(undef);
$x = builtin::reftype(undef);
$x = builtin::ceil($x);
$x = builtin::floor($x);
+$x = builtin::is_tainted($x);
####
# boolean true preserved
my $x = !0;
diff --git a/lib/B/Op_private.pm b/lib/B/Op_private.pm
index fd86782ad2..f763b297eb 100644
--- a/lib/B/Op_private.pm
+++ b/lib/B/Op_private.pm
@@ -149,7 +149,7 @@ $bits{$_}{6} = 'OPpPAD_STATE' for qw(lvavref lvref padav padhv padsv pushmark re
$bits{$_}{7} = 'OPpPV_IS_UTF8' for qw(dump goto last next redo);
$bits{$_}{6} = 'OPpREFCOUNTED' for qw(leave leaveeval leavesub leavesublv leavewrite);
$bits{$_}{2} = 'OPpSLICEWARNING' for qw(aslice hslice padav padhv rv2av rv2hv);
-$bits{$_}{4} = 'OPpTARGET_MY' for qw(abs add atan2 ceil chdir chmod chomp chown chr chroot concat cos crypt divide exec exp flock floor getpgrp getppid getpriority hex i_add i_divide i_modulo i_multiply i_subtract index int is_bool is_weak kill left_shift length link log mkdir modulo multiconcat multiply nbit_and nbit_or nbit_xor ncomplement oct ord pow push rand refaddr reftype rename right_shift rindex rmdir schomp scomplement setpgrp setpriority sin sleep sqrt srand stringify subtract symlink system time unlink unshift utime wait waitpid);
+$bits{$_}{4} = 'OPpTARGET_MY' for qw(abs add atan2 ceil chdir chmod chomp chown chr chroot concat cos crypt divide exec exp flock floor getpgrp getppid getpriority hex i_add i_divide i_modulo i_multiply i_subtract index int kill left_shift length link log mkdir modulo multiconcat multiply nbit_and nbit_or nbit_xor ncomplement oct ord pow push rand refaddr reftype rename right_shift rindex rmdir schomp scomplement setpgrp setpriority sin sleep sqrt srand stringify subtract symlink system time unlink unshift utime wait waitpid);
$bits{$_}{0} = 'OPpTRANS_CAN_FORCE_UTF8' for qw(trans transr);
$bits{$_}{5} = 'OPpTRANS_COMPLEMENT' for qw(trans transr);
$bits{$_}{7} = 'OPpTRANS_DELETE' for qw(trans transr);
@@ -404,6 +404,7 @@ $bits{i_preinc}{0} = $bf[0];
$bits{int}{0} = $bf[0];
@{$bits{ioctl}}{3,2,1,0} = ($bf[4], $bf[4], $bf[4], $bf[4]);
$bits{is_bool}{0} = $bf[0];
+$bits{is_tainted}{0} = $bf[0];
$bits{is_weak}{0} = $bf[0];
@{$bits{isa}}{1,0} = ($bf[1], $bf[1]);
@{$bits{join}}{3,2,1,0} = ($bf[4], $bf[4], $bf[4], $bf[4]);
@@ -849,7 +850,7 @@ our %ops_using = (
OPpSORT_DESCEND => [qw(sort)],
OPpSPLIT_ASSIGN => [qw(split)],
OPpSUBSTR_REPL_FIRST => [qw(substr)],
- OPpTARGET_MY => [qw(abs add atan2 ceil chdir chmod chomp chown chr chroot concat cos crypt divide exec exp flock floor getpgrp getppid getpriority hex i_add i_divide i_modulo i_multiply i_subtract index int is_bool is_weak kill left_shift length link log mkdir modulo multiconcat multiply nbit_and nbit_or nbit_xor ncomplement oct ord pow push rand refaddr reftype rename right_shift rindex rmdir schomp scomplement setpgrp setpriority sin sleep sqrt srand stringify subtract symlink system time unlink unshift utime wait waitpid)],
+ OPpTARGET_MY => [qw(abs add atan2 ceil chdir chmod chomp chown chr chroot concat cos crypt divide exec exp flock floor getpgrp getppid getpriority hex i_add i_divide i_modulo i_multiply i_subtract index int kill left_shift length link log mkdir modulo multiconcat multiply nbit_and nbit_or nbit_xor ncomplement oct ord pow push rand refaddr reftype rename right_shift rindex rmdir schomp scomplement setpgrp setpriority sin sleep sqrt srand stringify subtract symlink system time unlink unshift utime wait waitpid)],
OPpTRANS_CAN_FORCE_UTF8 => [qw(trans transr)],
OPpTRUEBOOL => [qw(blessed grepwhile index length padav padhv pos ref rindex rv2av rv2hv subst)],
OPpUSEINT => [qw(bit_and bit_or bit_xor complement left_shift nbit_and nbit_or nbit_xor ncomplement right_shift sbit_and sbit_or sbit_xor)],