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