Interface RepeatingNode
- All Superinterfaces:
NodeInterface
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.- Since:
- 0.8 or earlier
- See Also:
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbooleanexecuteRepeating(VirtualFrame frame) Repeatedly invoked by aloop nodeimplementation until the method returnsfalseor throws an exception.default ObjectRepeatedly invoked by aloop nodeimplementation, but allows returning a language-specific loop exit status.default ObjectReturns a placeholder loop status used internally before the first iteration.default booleanshouldContinue(Object returnValue) Predicate called on values returned byexecuteRepeatingWithValue().
-
Field Details
-
CONTINUE_LOOP_STATUS
A value indicating that the loop should be repeated.- Since:
- 19.3
-
BREAK_LOOP_STATUS
A value indicating that the loop should not be repeated. Any other value different thanCONTINUE_LOOP_STATUScan also be used to indicate that the loop should not be repeated.- Since:
- 19.3
-
-
Method Details
-
executeRepeating
Repeatedly invoked by aloop nodeimplementation until the method returnsfalseor throws an exception.- Parameters:
frame- the current execution frame passed through the interpreter- Returns:
trueif the method should be executed again to complete the loop andfalseif it must not.- Since:
- 0.8 or earlier
-
executeRepeatingWithValue
Repeatedly invoked by aloop nodeimplementation, but allows returning a language-specific loop exit status. Only languages that need to return custom loop statuses should override this method.- Parameters:
frame- the current execution frame passed through the interpreter- Returns:
- a value
vsatisfyingshouldContinue(v)== trueif the method should be executed again to complete the loop and any other value if it must not. - Since:
- 19.3
-
initialLoopStatus
Returns a placeholder loop status used internally before the first iteration.- Returns:
- a value satisfying
shouldContinue(initialLoopStatus(v)) == true - Since:
- 20.3
-
shouldContinue
Predicate called on values returned byexecuteRepeatingWithValue().- Parameters:
returnValue- a value returned byexecuteRepeatingWithValue()- Returns:
- true if the loop should continue executing or false otherwise
- Since:
- 20.3
-