Re: [PATCH 5.005_57] pp_sort sorted out
[p5sagit/p5-mst-13.2.git] / ext / B / ramblings / flip-flop
CommitLineData
a8a597b2 1PP(pp_range)
2{
3 if (GIMME == G_ARRAY)
4 return cCONDOP->op_true;
5 return SvTRUEx(PAD_SV(op->op_targ)) ? cCONDOP->op_false : cCONDOP->op_true;
6}
7
8pp_range is a CONDOP.
9In array context, it just returns op_true.
10In scalar context it checks the truth of targ and returns
11op_false if true, op_true if false.
12
13flip is an UNOP.
14It "looks after" its child which is always a pp_range CONDOP.
15In array context, it just returns the child's op_false.
16In scalar context, there are three possible outcomes:
17 (1) set child's targ to 1, our targ to 1 and return op_next.
18 (2) set child's targ to 1, our targ to 0, sp-- and return child's op_false.
19 (3) Blank targ and TOPs and return op_next.
20Case 1 happens for a "..." with a matching lineno... or true TOPs.
21Case 2 happens for a ".." with a matching lineno... or true TOPs.
22Case 3 happens for a non-matching lineno or false TOPs.
23
24 $a = lhs..rhs;
25
26 ,-------> range
27 ^ / \
28 | true/ \false
29 | / \
30 first| lhs rhs
31 | \ first /
32 ^--- flip <----- flop
33 \ /
34 \ /
35 sassign
36
37
38/* range */
39if (SvTRUE(curpad[op->op_targ]))
40 goto label(op_false);
41/* op_true */
42...
43/* flip */
44/* For "..." returns op_next. For ".." returns op_next or op_first->op_false */
45/* end of basic block */
46goto out;
47label(range op_false):
48...
49/* flop */
50out:
51...