Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit cd7a30d

Browse files
author
Reini Urban
committed
op: add more documention
about LOOP* in newWHILEOP, about LINKLIST.
1 parent e80f2a5 commit cd7a30d

File tree

1 file changed

+34
-14
lines changed

1 file changed

+34
-14
lines changed

op.c

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,9 +1644,18 @@ Perl_op_contextualize(pTHX_ OP *o, I32 context)
16441644
/*
16451645

16461646
=for apidoc Am|OP*|op_linklist|OP *o
1647+
16471648
This function is the implementation of the L</LINKLIST> macro. It should
16481649
not be called directly.
16491650

1651+
It is responsible to establish postfix order of the subtree, the kids,
1652+
linking recursively the next pointers together, depending on the
1653+
siblings and kids. The head is the exit node, the first kid the start
1654+
node, the siblings following each other.
1655+
1656+
The head node must have no next pointer, this is the exit condition
1657+
for the recursion.
1658+
16501659
=cut
16511660
*/
16521661

@@ -7669,25 +7678,36 @@ Perl_newLOOPOP(pTHX_ I32 flags, I32 debuggable PERL_UNUSED_DECL,
76697678
}
76707679

76717680
/*
7672-
=for apidoc Am|OP *|newWHILEOP|I32 flags|I32 debuggable|LOOP *loop|OP *expr|OP *block|OP *cont|I32 has_my
7681+
=for apidoc Am|OP *|newWHILEOP|I32 flags|UNUSED I32 debuggable|LOOP *loop|OP *expr|OP *block|OP *cont|I32 has_my
76737682

7674-
Constructs, checks, and returns an op tree expressing a C<while> loop.
7683+
Constructs, checks, and returns an op tree expressing a C<while> or
7684+
C<for>/C<foreach> loop or a single C<block> run only once.
76757685
This is a heavyweight loop, with structure that allows exiting the loop
76767686
by C<last> and suchlike.
76777687

7678-
C<loop> is an optional preconstructed C<enterloop> op to use in the
7679-
loop; if it is null then a suitable op will be constructed automatically.
7680-
C<expr> supplies the loop's controlling expression. C<block> supplies the
7681-
main body of the loop, and C<cont> optionally supplies a C<continue> block
7682-
that operates as a second half of the body. All of these optree inputs
7683-
are consumed by this function and become part of the constructed op tree.
7688+
C<loop> is an optional C<enterloop> op to use in the loop, with a
7689+
C<foreach> loop is is an C<enteriter> op. This op contains the five
7690+
main control paths: first, last, redoop, nextop, lastop. C<first>
7691+
being the list iterator, C<last> being the iteration variable,
7692+
C<redoop> the C<block> plus C<cont>, C<nextop> the C<cont> or an
7693+
C<unstack> op, C<lastop> a C<leaveloop> op, which is also the false
7694+
condition of the C<expr> (i.e. C<< expr->op_next >>).
7695+
7696+
C<expr> supplies the loop's controlling expression. With a C<foreach>
7697+
loop it is the C<iter> op, with C<while> the while expression, with
7698+
a single block it is NULL.
7699+
7700+
C<block> supplies the main body of the loop, and C<cont> optionally
7701+
supplies a C<continue> block that operates as a second half of the
7702+
body. All of these optree inputs are consumed by this function and
7703+
become part of the constructed op tree.
76847704

7685-
C<flags> gives the eight bits of C<op_flags> for the C<leaveloop>
7686-
op and, shifted up eight bits, the eight bits of C<op_private> for
7687-
the C<leaveloop> op, except that (in both cases) some bits will be set
7688-
automatically. C<debuggable> is currently unused and should always be 1.
7689-
C<has_my> can be supplied as true to force the
7690-
loop body to be enclosed in its own scope.
7705+
C<flags> gives the eight bits of C<op_flags> for the C<leaveloop> op
7706+
and, shifted up eight bits, the eight bits of C<op_private> for the
7707+
C<leaveloop> op, except that (in both cases) some bits will be set
7708+
automatically. C<debuggable> is currently unused and should always be
7709+
1. C<has_my> can be supplied as true to force the loop body to be
7710+
enclosed in its own scope.
76917711

76927712
=cut
76937713
*/

0 commit comments

Comments
 (0)