Interface RepeatingNode

All Superinterfaces:
NodeInterface

public interface RepeatingNode extends 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 Details

    • CONTINUE_LOOP_STATUS

      static final Object CONTINUE_LOOP_STATUS
      A value indicating that the loop should be repeated.
      Since:
      19.3
    • BREAK_LOOP_STATUS

      static final Object BREAK_LOOP_STATUS
      A 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.
      Since:
      19.3
  • Method Details

    • executeRepeating

      boolean executeRepeating(VirtualFrame frame)
      Repeatedly invoked by a loop node implementation until the method returns false 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 and false if it must not.
      Since:
      0.8 or earlier
    • executeRepeatingWithValue

      default 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:
      frame - the current execution frame passed through the interpreter
      Returns:
      a value v satisfying shouldContinue(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

      default Object initialLoopStatus()
      Returns a placeholder loop status used internally before the first iteration.
      Returns:
      a value satisfying shouldContinue(initialLoopStatus(v)) == true
      Since:
      20.3
    • shouldContinue

      default boolean shouldContinue(Object returnValue)
      Predicate called on values returned by executeRepeatingWithValue().
      Parameters:
      returnValue - a value returned by executeRepeatingWithValue()
      Returns:
      true if the loop should continue executing or false otherwise
      Since:
      20.3