Package com.saxonica.ee.bytecode.util

## Class OnEmpty.UnwindAndJump

- java.lang.Object
- - com.saxonica.ee.bytecode.util.OnEmpty
  - - com.saxonica.ee.bytecode.util.OnEmpty.UnwindAndJump

- Enclosing class:
    OnEmpty

      public static class OnEmpty.UnwindAndJump
      extends OnEmpty

  The UnwindAndJump subclass causes the code generator, when an expression evaluates to the empty sequence, to generate a "goto" instruction to a defined label; but before executing the jump, the stack will be unwound to a known position.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class com.saxonica.ee.bytecode.util.OnEmpty

      `OnEmpty.ReturnEmptyString, OnEmpty.ReturnNull, OnEmpty.UnwindAndJump`

  - ### Field Summary

    - ### Fields inherited from class com.saxonica.ee.bytecode.util.OnEmpty

      `RETURN_EMPTY_STRING, RETURN_NULL`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `UnwindAndJump​(LabelInfo label)` | Generate an UnwindAndStack action using an empty stack (no unwinding needed)
    `UnwindAndJump​(java.util.Stack<java.lang.Class> unwindStack, LabelInfo label)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `generate​(Generator ga)` | Generate code.
    `LabelInfo` | `getLabel()` | Get the label acting as the jump destination
    `java.util.Stack<java.lang.Class>` | `getUnwindStack()` | Get information about the stack that needs to be unwound before making the jump.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### UnwindAndJump

          public UnwindAndJump​(java.util.Stack<java.lang.Class> unwindStack,
                               LabelInfo label)

      Parameters:
        `unwindStack` - Information about the classes of object that will be on the bytecode stack and must be popped off the stack before jumping to the onEmpty label: the generated code must pop the items described on this stack before jumping to the label.
        `label` - a label to which control will be transferred (with nothing on the stack) if the result of the evaluation is an empty sequence. This mechanism supports the design pattern whereby many expressions return empty if one of there arguments is empty; rather than repeatedly checking for empty after evaluating each subexpression, there is a "longjump" treating this as an exception case.

    - #### UnwindAndJump

          public UnwindAndJump​(LabelInfo label)

      Generate an UnwindAndStack action using an empty stack (no unwinding needed)
      Parameters:
        `label` - the label to jump to

  - ### Method Detail

    - #### generate

          public void generate​(Generator ga)

      Generate code. (This method is not extensively used)
      Specified by:
        `generate` in class `OnEmpty`
      Parameters:
        `ga` - the code generator

    - #### getLabel

          public LabelInfo getLabel()

      Get the label acting as the jump destination
      Returns:
        the label

    - #### getUnwindStack

          public java.util.Stack<java.lang.Class> getUnwindStack()

      Get information about the stack that needs to be unwound before making the jump. This contains information about the class of object at each position, because doubles and longs occupy two words and need a pop2 instruction to remove them
      Returns:
        details of the stack to be unwound