Class OnEmpty.UnwindAndJump

  • Enclosing class:

    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.
    • Constructor Detail

      • UnwindAndJump

        public UnwindAndJump​(java.util.Stack<java.lang.Class<?>> unwindStack,
                             LabelInfo label)
        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)
        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
        ga - the code generator
      • getLabel

        public LabelInfo getLabel()
        Get the label acting as the jump destination
        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
        details of the stack to be unwound