Package com.oracle.truffle.api.nodes
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
-
Method Summary
Modifier and TypeMethodDescriptionboolean
executeRepeating
(VirtualFrame frame) Repeatedly invoked by aloop node
implementation until the method returnsfalse
or throws an exception.default Object
Repeatedly invoked by aloop node
implementation, but allows returning a language-specific loop exit status.default Object
Returns a placeholder loop status used internally before the first iteration.default boolean
shouldContinue
(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_STATUS
can also be used to indicate that the loop should not be repeated.- Since:
- 19.3
-
-
Method Details
-
executeRepeating
Repeatedly invoked by aloop node
implementation until the method returnsfalse
or throws an exception.- Parameters:
frame
- the current execution frame passed through the interpreter- Returns:
true
if the method should be executed again to complete the loop andfalse
if it must not.- Since:
- 0.8 or earlier
-
executeRepeatingWithValue
Repeatedly invoked by aloop 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:
frame
- the current execution frame passed through the interpreter- Returns:
- a value
v
satisfyingshouldContinue(v)
== true
if 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
-