summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gv.c6
-rw-r--r--opnames.h10
-rwxr-xr-xregen/opcode.pl14
-rw-r--r--regen/opcodes12
4 files changed, 25 insertions, 17 deletions
diff --git a/gv.c b/gv.c
index c274065448..116d391148 100644
--- a/gv.c
+++ b/gv.c
@@ -59,11 +59,7 @@ Perl_gv_add_by_type(pTHX_ GV *gv, svtype type)
* if it walks like a dirhandle, then let's assume that
* this is a dirhandle.
*/
- what = PL_op->op_type == OP_READDIR ||
- PL_op->op_type == OP_TELLDIR ||
- PL_op->op_type == OP_SEEKDIR ||
- PL_op->op_type == OP_REWINDDIR ||
- PL_op->op_type == OP_CLOSEDIR ?
+ what = OP_IS_DIRHOP(PL_op->op_type) ?
"dirhandle" : "filehandle";
/* diag_listed_as: Bad symbol for filehandle */
} else if (type == SVt_PVHV) {
diff --git a/opnames.h b/opnames.h
index b55cda2b2d..26dfbaaac7 100644
--- a/opnames.h
+++ b/opnames.h
@@ -391,9 +391,10 @@ typedef enum opcode {
#define MAXO 372
-/* the OP_IS_(SOCKET|FILETEST) macros are optimized to a simple range
- check because all the member OPs are contiguous in opcode.pl
- <OPS> table. opcode.pl verifies the range contiguity. */
+/* the OP_IS_* macros are optimized to a simple range check because
+ all the member OPs are contiguous in regen/opcodes table.
+ opcode.pl verifies the range contiguity, or generates an OR-equals
+ expression */
#define OP_IS_SOCKET(op) \
((op) >= OP_SEND && (op) <= OP_GETPEERNAME)
@@ -407,4 +408,7 @@ typedef enum opcode {
#define OP_IS_NUMCOMPARE(op) \
((op) >= OP_LT && (op) <= OP_I_NCMP)
+#define OP_IS_DIRHOP(op) \
+ ((op) >= OP_READDIR && (op) <= OP_CLOSEDIR)
+
/* ex: set ro: */
diff --git a/regen/opcode.pl b/regen/opcode.pl
index 5e1cf62dc8..b4576da236 100755
--- a/regen/opcode.pl
+++ b/regen/opcode.pl
@@ -353,6 +353,8 @@ my %OP_IS_SOCKET; # /Fs/
my %OP_IS_FILETEST; # /F-/
my %OP_IS_FT_ACCESS; # /F-+/
my %OP_IS_NUMCOMPARE; # /S</
+my %OP_IS_DIRHOP; # /Fd/
+
my $OCSHIFT = 8;
my $OASHIFT = 12;
@@ -371,6 +373,10 @@ for my $op (@ops) {
$argsum |= $opclass{$flags} << $OCSHIFT;
my $argshift = $OASHIFT;
for my $arg (split(' ',$args{$op})) {
+ if ($arg =~ s/^D//) {
+ # handle 1st, just to put D 1st.
+ $OP_IS_DIRHOP{$op} = $opnum{$op};
+ }
if ($arg =~ /^F/) {
# record opnums of these opnames
$OP_IS_SOCKET{$op} = $opnum{$op} if $arg =~ s/s//;
@@ -407,15 +413,17 @@ END
print $on <<'EO_OP_IS_COMMENT';
-/* the OP_IS_(SOCKET|FILETEST) macros are optimized to a simple range
- check because all the member OPs are contiguous in opcode.pl
- <OPS> table. opcode.pl verifies the range contiguity. */
+/* the OP_IS_* macros are optimized to a simple range check because
+ all the member OPs are contiguous in regen/opcodes table.
+ opcode.pl verifies the range contiguity, or generates an OR-equals
+ expression */
EO_OP_IS_COMMENT
gen_op_is_macro( \%OP_IS_SOCKET, 'OP_IS_SOCKET');
gen_op_is_macro( \%OP_IS_FILETEST, 'OP_IS_FILETEST');
gen_op_is_macro( \%OP_IS_FT_ACCESS, 'OP_IS_FILETEST_ACCESS');
gen_op_is_macro( \%OP_IS_NUMCOMPARE, 'OP_IS_NUMCOMPARE');
+gen_op_is_macro( \%OP_IS_DIRHOP, 'OP_IS_DIRHOP');
sub gen_op_is_macro {
my ($op_is, $macname) = @_;
diff --git a/regen/opcodes b/regen/opcodes
index 7b871dbb3c..688f1661cd 100644
--- a/regen/opcodes
+++ b/regen/opcodes
@@ -30,7 +30,7 @@
# scalar - S list - L array - A
# hash - H sub (CV) - C file - F
# socket - Fs filetest - F- filetest_access - F-+
-# num-compare - S<
+# num-compare - S< dirhandle - DF
# reference - R
# "?" denotes an optional operand.
@@ -429,11 +429,11 @@ rmdir rmdir ck_fun isTu% S?
# Directory calls.
open_dir opendir ck_fun is@ F S
-readdir readdir ck_fun % F
-telldir telldir ck_fun st% F
-seekdir seekdir ck_fun s@ F S
-rewinddir rewinddir ck_fun s% F
-closedir closedir ck_fun is% F
+readdir readdir ck_fun % DF
+telldir telldir ck_fun st% DF
+seekdir seekdir ck_fun s@ DF S
+rewinddir rewinddir ck_fun s% DF
+closedir closedir ck_fun is% DF
# Process control.