public interface RepeatingNode extends NodeInterface
Node or a subclass of Node.
Repeating nodes are intended to be implemented by guest language implementations. For a full
usage example please see LoopNode.
Note: The result of shouldContinue(
executeRepeatingWithValue()) is
automatically profiled by the loop node, so the repeating node should not
use a loop condition profile.LoopNode,
TruffleRuntime.createLoopNode(RepeatingNode)| Modifier and Type | Field and Description |
|---|---|
static Object |
BREAK_LOOP_STATUS
A value indicating that the loop should not be repeated.
|
static Object |
CONTINUE_LOOP_STATUS
A value indicating that the loop should be repeated.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
executeRepeating(VirtualFrame frame)
Repeatedly invoked by a
loop node implementation until the method returns
false or throws an exception. |
default Object |
executeRepeatingWithValue(VirtualFrame frame)
Repeatedly invoked by a
loop node implementation, but allows returning a
language-specific loop exit status. |
default Object |
initialLoopStatus()
Returns a placeholder loop status used internally before the first iteration.
|
default boolean |
shouldContinue(Object returnValue)
Predicate called on values returned by
executeRepeatingWithValue(). |
static final Object CONTINUE_LOOP_STATUS
static final Object BREAK_LOOP_STATUS
CONTINUE_LOOP_STATUS can also be used to indicate that the loop should not be
repeated.boolean executeRepeating(VirtualFrame frame)
loop node implementation until the method returns
false or throws an exception.frame - the current execution frame passed through the interpretertrue if the method should be executed again to complete the loop and
false if it must not.default Object executeRepeatingWithValue(VirtualFrame frame)
loop node implementation, but allows returning a
language-specific loop exit status. Only languages that need to return custom loop statuses
should override this method.frame - the current execution frame passed through the interpreterv satisfying shouldContinue(v) == true if the method should be executed again to
complete the loop and any other value if it must not.default Object initialLoopStatus()
shouldContinue(initialLoopStatus(v)) == truedefault boolean shouldContinue(Object returnValue)
executeRepeatingWithValue().returnValue - a value returned by
executeRepeatingWithValue()