Package: org.codehaus.groovy.transform.tailrec

## [Java] Class ReturnStatementToIterationConverter

- org.codehaus.groovy.transform.tailrec.ReturnStatementToIterationConverter

-     public class ReturnStatementToIterationConverter
      extends Object

  Translates all return statements into an invocation of the next iteration. This can be either - "continue LOOP_LABEL": Outside closures - "throw LOOP_EXCEPTION": Inside closures

  Moreover, before adding the recur statement the iteration parameters (originally the method args) are set to their new value. To prevent variable aliasing parameters will be copied into temp vars before they are changes so that their current iteration value can be used when setting other params.

  There's probably place for optimizing the amount of variable copying being done, e.g. parameters that are only handed through must not be copied at all.

- - ### Constructor Summary

    Constructors
    Constructor and description
    `ReturnStatementToIterationConverter()` Creates a converter that uses the default recurrence statement.
    `ReturnStatementToIterationConverter(Statement recurStatement)` Creates a converter that uses the supplied recurrence statement.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public Statement` | `convert(ReturnStatement statement, Map<Integer, Map<String, Object>> positionMapping)` Converts a recursive return statement into iterative assignments followed by the recur statement.
    `` | `public Statement` | `getRecurStatement()` Returns the statement used to trigger the next iteration.
    `` | `public void` | `setRecurStatement(Statement recurStatement)` Sets the statement used to trigger the next iteration.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### public ReturnStatementToIterationConverter()

      Creates a converter that uses the default recurrence statement.

    - #### public ReturnStatementToIterationConverter(Statement recurStatement)

      Creates a converter that uses the supplied recurrence statement.

      Parameters:
        `recurStatement` - the statement that advances to the next iteration

  - ### Method Detail

    - #### public Statement convert(ReturnStatement statement, Map<Integer, Map<String, Object>> positionMapping)

      Converts a recursive return statement into iterative assignments followed by the recur statement.

      Parameters:
        `statement` - the return statement to convert
        `positionMapping` - the parameter mapping keyed by argument position
      Returns:
        the converted statement, or the original statement if it is not a method call

    - #### public Statement getRecurStatement()

      Returns the statement used to trigger the next iteration.

      Returns:
        the recurrence statement

    - #### public void setRecurStatement(Statement recurStatement)

      Sets the statement used to trigger the next iteration.

      Parameters:
        `recurStatement` - the recurrence statement to use