summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorStephen McCamant <smcc@mit.edu>1999-06-25 08:38:44 -0500
committerGurusamy Sarathy <gsar@cpan.org>1999-07-07 08:07:49 +0000
commit1a67a97c0300941ac67bfb1dd421467b8c59e21c (patch)
tree6af0288c91ab32f5ab3c8f6aabdca7d3b00e0e3e /ext
parentc4be5b273ea01a42f8bea870c9703dc3eaa652b6 (diff)
downloadperl-1a67a97c0300941ac67bfb1dd421467b8c59e21c.tar.gz
Eliminate CONDOPs
Message-ID: <14193.25034.113373.245377@alias-2.pr.mcs.net> p4raw-id: //depot/perl@3637
Diffstat (limited to 'ext')
-rw-r--r--ext/B/B.pm30
-rw-r--r--ext/B/B.xs35
-rw-r--r--ext/B/B/Bblock.pm9
-rw-r--r--ext/B/B/Bytecode.pm8
-rw-r--r--ext/B/B/C.pm12
-rw-r--r--ext/B/B/CC.pm14
-rw-r--r--ext/B/B/Debug.pm7
-rw-r--r--ext/B/B/Xref.pm7
-rw-r--r--ext/B/ramblings/flip-flop27
-rw-r--r--ext/B/typemap1
10 files changed, 35 insertions, 115 deletions
diff --git a/ext/B/B.pm b/ext/B/B.pm
index cdbd3b297e..b39659d1c9 100644
--- a/ext/B/B.pm
+++ b/ext/B/B.pm
@@ -38,7 +38,6 @@ use strict;
@B::UNOP::ISA = 'B::OP';
@B::BINOP::ISA = 'B::UNOP';
@B::LOGOP::ISA = 'B::UNOP';
-@B::CONDOP::ISA = 'B::UNOP';
@B::LISTOP::ISA = 'B::BINOP';
@B::SVOP::ISA = 'B::OP';
@B::GVOP::ISA = 'B::OP';
@@ -132,7 +131,9 @@ sub walkoptree_exec {
savesym($op, sprintf("%s (0x%lx)", class($op), $$op));
$op->$method($level);
$ppname = $op->ppaddr;
- if ($ppname =~ /^pp_(or|and|mapwhile|grepwhile|entertry)$/) {
+ if ($ppname =~
+ /^pp_(or|and|mapwhile|grepwhile|entertry|range|cond_expr)$/)
+ {
print $prefix, uc($1), " => {\n";
walkoptree_exec($op->other, $method, $level + 1);
print $prefix, "}\n";
@@ -148,19 +149,6 @@ sub walkoptree_exec {
walkoptree_exec($op->other->pmreplstart, $method, $level + 1);
print $prefix, "}\n";
$op = $op->other;
- } elsif ($ppname eq "pp_cond_expr") {
- # pp_cond_expr never returns op_next
- print $prefix, "TRUE => {\n";
- walkoptree_exec($op->true, $method, $level + 1);
- print $prefix, "}\n";
- $op = $op->false;
- redo;
- } elsif ($ppname eq "pp_range") {
- print $prefix, "TRUE => {\n";
- walkoptree_exec($op->true, $method, $level + 1);
- print $prefix, "}\n", $prefix, "FALSE => {\n";
- walkoptree_exec($op->false, $method, $level + 1);
- print $prefix, "}\n";
} elsif ($ppname eq "pp_enterloop") {
print $prefix, "REDO => {\n";
walkoptree_exec($op->redoop, $method, $level + 1);
@@ -555,7 +543,7 @@ C<REFCNT> (corresponding to the C function C<SvREFCNT>).
=head2 OP-RELATED CLASSES
-B::OP, B::UNOP, B::BINOP, B::LOGOP, B::CONDOP, B::LISTOP, B::PMOP,
+B::OP, B::UNOP, B::BINOP, B::LOGOP, B::LISTOP, B::PMOP,
B::SVOP, B::GVOP, B::PVOP, B::CVOP, B::LOOP, B::COP.
These classes correspond in
the obvious way to the underlying C structures of similar names. The
@@ -616,16 +604,6 @@ This returns the op description from the global C PL_op_desc array
=back
-=head2 B::CONDOP METHODS
-
-=over 4
-
-=item true
-
-=item false
-
-=back
-
=head2 B::LISTOP METHOD
=over 4
diff --git a/ext/B/B.xs b/ext/B/B.xs
index 1777b21254..79610c373e 100644
--- a/ext/B/B.xs
+++ b/ext/B/B.xs
@@ -52,15 +52,14 @@ typedef enum {
OPc_UNOP, /* 2 */
OPc_BINOP, /* 3 */
OPc_LOGOP, /* 4 */
- OPc_CONDOP, /* 5 */
- OPc_LISTOP, /* 6 */
- OPc_PMOP, /* 7 */
- OPc_SVOP, /* 8 */
- OPc_GVOP, /* 9 */
- OPc_PVOP, /* 10 */
- OPc_CVOP, /* 11 */
- OPc_LOOP, /* 12 */
- OPc_COP /* 13 */
+ OPc_LISTOP, /* 5 */
+ OPc_PMOP, /* 6 */
+ OPc_SVOP, /* 7 */
+ OPc_GVOP, /* 8 */
+ OPc_PVOP, /* 9 */
+ OPc_CVOP, /* 10 */
+ OPc_LOOP, /* 11 */
+ OPc_COP /* 12 */
} opclass;
static char *opclassnames[] = {
@@ -69,7 +68,6 @@ static char *opclassnames[] = {
"B::UNOP",
"B::BINOP",
"B::LOGOP",
- "B::CONDOP",
"B::LISTOP",
"B::PMOP",
"B::SVOP",
@@ -109,9 +107,6 @@ cc_opclass(pTHX_ OP *o)
case OA_LOGOP:
return OPc_LOGOP;
- case OA_CONDOP:
- return OPc_CONDOP;
-
case OA_LISTOP:
return OPc_LISTOP;
@@ -346,7 +341,6 @@ typedef OP *B__OP;
typedef UNOP *B__UNOP;
typedef BINOP *B__BINOP;
typedef LOGOP *B__LOGOP;
-typedef CONDOP *B__CONDOP;
typedef LISTOP *B__LISTOP;
typedef PMOP *B__PMOP;
typedef SVOP *B__SVOP;
@@ -616,19 +610,6 @@ B::OP
LOGOP_other(o)
B::LOGOP o
-#define CONDOP_true(o) o->op_true
-#define CONDOP_false(o) o->op_false
-
-MODULE = B PACKAGE = B::CONDOP PREFIX = CONDOP_
-
-B::OP
-CONDOP_true(o)
- B::CONDOP o
-
-B::OP
-CONDOP_false(o)
- B::CONDOP o
-
#define LISTOP_children(o) o->op_children
MODULE = B PACKAGE = B::LISTOP PREFIX = LISTOP_
diff --git a/ext/B/B/Bblock.pm b/ext/B/B/Bblock.pm
index df2a64214e..ae47cf9e04 100644
--- a/ext/B/B/Bblock.pm
+++ b/ext/B/B/Bblock.pm
@@ -99,14 +99,6 @@ sub B::LOGOP::mark_if_leader {
}
}
-sub B::CONDOP::mark_if_leader {
- my $op = shift;
- mark_leader($op->next);
- mark_leader($op->true);
- mark_leader($op->false);
-}
-
-
sub B::LISTOP::mark_if_leader {
my $op = shift;
my $first=$op->first;
@@ -158,7 +150,6 @@ sub compile {
# The ops pointed at by nextop, redoop and lastop->op_next of a LOOP
# The ops pointed at by op_next and op_other of a LOGOP, except
# for pp_entertry which has op_next and op_other->op_next
-# The ops pointed at by op_true and op_false of a CONDOP
# The op pointed at by op_pmreplstart of a PMOP
# The op pointed at by op_other->op_pmreplstart of pp_substcont?
# [The op after a pp_return] Omit
diff --git a/ext/B/B/Bytecode.pm b/ext/B/B/Bytecode.pm
index 42b91998b0..1bf436871b 100644
--- a/ext/B/B/Bytecode.pm
+++ b/ext/B/B/Bytecode.pm
@@ -260,14 +260,6 @@ sub B::BINOP::bytecode {
}
}
-sub B::CONDOP::bytecode {
- my $op = shift;
- my $trueix = $op->true->objix;
- my $falseix = $op->false->objix;
- $op->B::UNOP::bytecode;
- print "op_true $trueix\nop_false $falseix\n";
-}
-
sub B::LISTOP::bytecode {
my $op = shift;
my $children = $op->children;
diff --git a/ext/B/B/C.pm b/ext/B/B/C.pm
index 0385452ffc..3f8260e7ab 100644
--- a/ext/B/B/C.pm
+++ b/ext/B/B/C.pm
@@ -233,18 +233,6 @@ sub B::LOGOP::save {
savesym($op, sprintf("(OP*)&logop_list[%d]", $logopsect->index));
}
-sub B::CONDOP::save {
- my ($op, $level) = @_;
- my $sym = objsym($op);
- return $sym if defined $sym;
- $condopsect->add(sprintf("s\\_%x, s\\_%x, %s, %u, %u, %u, 0x%x, 0x%x, s\\_%x, s\\_%x, s\\_%x",
- ${$op->next}, ${$op->sibling}, $op->ppaddr,
- $op->targ, $op->type, $op_seq, $op->flags,
- $op->private, ${$op->first}, ${$op->true},
- ${$op->false}));
- savesym($op, sprintf("(OP*)&condop_list[%d]", $condopsect->index));
-}
-
sub B::LOOP::save {
my ($op, $level) = @_;
my $sym = objsym($op);
diff --git a/ext/B/B/CC.pm b/ext/B/B/CC.pm
index b909d44851..98c9318055 100644
--- a/ext/B/B/CC.pm
+++ b/ext/B/B/CC.pm
@@ -524,13 +524,13 @@ sub pp_or {
sub pp_cond_expr {
my $op = shift;
- my $false = $op->false;
+ my $false = $op->next;
unshift(@bblock_todo, $false);
reload_lexicals();
my $bool = pop_bool();
write_back_stack();
runtime(sprintf("if (!$bool) goto %s;", label($false)));
- return $op->true;
+ return $op->other;
}
sub pp_padsv {
@@ -1238,10 +1238,10 @@ sub pp_range {
# it to find and adjust out targ. We don't need it ourselves.
$op->save;
runtime sprintf("if (SvTRUE(PL_curpad[%d])) goto %s;",
- $op->targ, label($op->false));
- unshift(@bblock_todo, $op->false);
+ $op->targ, label($op->other));
+ unshift(@bblock_todo, $op->other);
}
- return $op->true;
+ return $op->next;
}
sub pp_flip {
@@ -1251,7 +1251,7 @@ sub pp_flip {
error("context of flip unknown at compile-time");
}
if (($flags & OPf_WANT)==OPf_WANT_LIST) {
- return $op->first->false;
+ return $op->first->other;
}
write_back_lexicals();
write_back_stack();
@@ -1269,7 +1269,7 @@ sub pp_flip {
} else {
runtime("\tsv_setiv(PL_curpad[$ix], 0);",
"\tsp--;",
- sprintf("\tgoto %s;", label($op->first->false)));
+ sprintf("\tgoto %s;", label($op->first->other)));
}
runtime("}",
qq{sv_setpv(PL_curpad[$ix], "");},
diff --git a/ext/B/B/Debug.pm b/ext/B/B/Debug.pm
index d10db9cb1a..75636265e6 100644
--- a/ext/B/B/Debug.pm
+++ b/ext/B/B/Debug.pm
@@ -39,13 +39,6 @@ sub B::LOGOP::debug {
printf "\top_other\t0x%x\n", ${$op->other};
}
-sub B::CONDOP::debug {
- my ($op) = @_;
- $op->B::UNOP::debug();
- printf "\top_true\t0x%x\n", ${$op->true};
- printf "\top_false\t0x%x\n", ${$op->false};
-}
-
sub B::LISTOP::debug {
my ($op) = @_;
$op->B::BINOP::debug();
diff --git a/ext/B/B/Xref.pm b/ext/B/B/Xref.pm
index 854db71189..16f25ff032 100644
--- a/ext/B/B/Xref.pm
+++ b/ext/B/B/Xref.pm
@@ -154,7 +154,7 @@ sub xref {
warn sprintf("top = [%s, %s, %s]\n", @$top) if $debug_top;
warn peekop($op), "\n" if $debug_op;
my $ppname = $op->ppaddr;
- if ($ppname =~ /^pp_(or|and|mapwhile|grepwhile)$/) {
+ if ($ppname =~ /^pp_(or|and|mapwhile|grepwhile|range|cond_expr)$/) {
xref($op->other);
} elsif ($ppname eq "pp_match" || $ppname eq "pp_subst") {
xref($op->pmreplstart);
@@ -162,11 +162,6 @@ sub xref {
xref($op->other->pmreplstart);
$op = $op->other;
redo;
- } elsif ($ppname eq "pp_cond_expr") {
- # pp_cond_expr never returns op_next
- xref($op->true);
- $op = $op->false;
- redo;
} elsif ($ppname eq "pp_enterloop") {
xref($op->redoop);
xref($op->nextop);
diff --git a/ext/B/ramblings/flip-flop b/ext/B/ramblings/flip-flop
index 183d541b98..e0cb8ff620 100644
--- a/ext/B/ramblings/flip-flop
+++ b/ext/B/ramblings/flip-flop
@@ -1,21 +1,24 @@
PP(pp_range)
{
if (GIMME == G_ARRAY)
- return cCONDOP->op_true;
- return SvTRUEx(PAD_SV(op->op_targ)) ? cCONDOP->op_false : cCONDOP->op_true;
+ return NORMAL;
+ if (SvTRUEx(PAD_SV(PL_op->op_targ)))
+ return cLOGOP->op_other;
+ else
+ return NORMAL;
}
-pp_range is a CONDOP.
-In array context, it just returns op_true.
+pp_range is a LOGOP.
+In array context, it just returns op_next.
In scalar context it checks the truth of targ and returns
-op_false if true, op_true if false.
+op_other if true, op_next if false.
flip is an UNOP.
-It "looks after" its child which is always a pp_range CONDOP.
-In array context, it just returns the child's op_false.
+It "looks after" its child which is always a pp_range LOGOP.
+In array context, it just returns the child's op_other.
In scalar context, there are three possible outcomes:
(1) set child's targ to 1, our targ to 1 and return op_next.
- (2) set child's targ to 1, our targ to 0, sp-- and return child's op_false.
+ (2) set child's targ to 1, our targ to 0, sp-- and return child's op_other.
(3) Blank targ and TOPs and return op_next.
Case 1 happens for a "..." with a matching lineno... or true TOPs.
Case 2 happens for a ".." with a matching lineno... or true TOPs.
@@ -37,14 +40,14 @@ Case 3 happens for a non-matching lineno or false TOPs.
/* range */
if (SvTRUE(curpad[op->op_targ]))
- goto label(op_false);
-/* op_true */
+ goto label(op_other);
+/* op_next */
...
/* flip */
-/* For "..." returns op_next. For ".." returns op_next or op_first->op_false */
+/* For "..." returns op_next. For ".." returns op_next or op_first->op_other */
/* end of basic block */
goto out;
-label(range op_false):
+label(range op_other):
...
/* flop */
out:
diff --git a/ext/B/typemap b/ext/B/typemap
index 3531c49fb2..948fdcd977 100644
--- a/ext/B/typemap
+++ b/ext/B/typemap
@@ -4,7 +4,6 @@ B::OP T_OP_OBJ
B::UNOP T_OP_OBJ
B::BINOP T_OP_OBJ
B::LOGOP T_OP_OBJ
-B::CONDOP T_OP_OBJ
B::LISTOP T_OP_OBJ
B::PMOP T_OP_OBJ
B::SVOP T_OP_OBJ