RepeatingNode
public interface RepeatingNode extends NodeInterface- Extends
A node that is repeatedly invoked as part of a Truffle loop control structure. Repeating nodes must extend 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.
Fields2
Object CONTINUE_LOOP_STATUS
CONTINUE_LOOP_STATUS
since 19.3Object CONTINUE_LOOP_STATUSA value indicating that the loop should be repeated.
Object BREAK_LOOP_STATUS
BREAK_LOOP_STATUS
since 19.3Object BREAK_LOOP_STATUSA value indicating that the loop should not be repeated. Any other value different than CONTINUE_LOOP_STATUS can also be used to indicate that the loop should not be repeated.
Methods4
boolean executeRepeating(VirtualFrame)
executeRepeating
since 0.8 or earlierboolean executeRepeating(VirtualFrame frame)Repeatedly invoked by a loop node implementation until the method returns false or throws an exception.
Parameters
frameVirtualFrame- the current execution frame passed through the interpreter
Returns
booleantrueif the method should be executed again to complete the loop andfalseif it must not.
Object executeRepeatingWithValue(VirtualFrame)
executeRepeatingWithValue
defaultsince 19.3default Object executeRepeatingWithValue(VirtualFrame frame)Repeatedly invoked by a 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.
Parameters
frameVirtualFrame- the current execution frame passed through the interpreter
Returns
Object- a value
vsatisfyingshouldContinue(v)== trueif the method should be executed again to complete the loop and any other value if it must not.
Object initialLoopStatus()
initialLoopStatus
defaultsince 20.3default Object initialLoopStatus()Returns a placeholder loop status used internally before the first iteration.
Returns
Object- a value satisfying
shouldContinue(initialLoopStatus(v)) == true
boolean shouldContinue(Object)
shouldContinue
defaultsince 20.3default boolean shouldContinue(Object returnValue)Predicate called on values returned by executeRepeatingWithValue().
Parameters
returnValueObject- a value returned by
executeRepeatingWithValue()
Returns
boolean- true if the loop should continue executing or false otherwise