Class Label

java.lang.Object
org.biojava.utils.bytecode.Label
All Implemented Interfaces:
CodeGenerator

public class Label extends Object implements CodeGenerator
A Label used to mark a position in byte code.

Labels are used as the targets for jumps, and for exception handlers. Labels can be named. They implement CodeGenerator, which allows them to be added to things like an InstructionVector. The writeCode method takes care of marking the label with the context.

Author:
Thomas Down, Matthew Pocock
  • Field Details

  • Constructor Details

    • Label

      public Label()
    • Label

      public Label(String name)
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • writeCode

      public void writeCode(CodeContext ctx) throws CodeException
      Description copied from interface: CodeGenerator
      Write the byte or bytes for this CodeGenerator to a CodeContext.
      Specified by:
      writeCode in interface CodeGenerator
      Parameters:
      ctx - a CodeContext to write to
      Throws:
      CodeException - if there was some failure in writing to the context
    • stackDepth

      public int stackDepth()
      Description copied from interface: CodeGenerator
      Return the total depth of the stack required by this CodeGenerator.

      For single byte-code instructions, this will be the same as stackDelta() if stackDelta() is positive, zero otherwise. For a compound instruction, this will be the maximum stack depth required to execute all sub-instructions.

      Specified by:
      stackDepth in interface CodeGenerator
      Returns:
      the stack depth needed
    • stackDelta

      public int stackDelta()
      Description copied from interface: CodeGenerator
      Return the change in the stack dept this generator will cause.

      In the case of an instruction that adds items to the stack, stackDelta will be positive. For instructions that removes items from the stack, this will be negative.

      Specified by:
      stackDelta in interface CodeGenerator
      Returns:
      the change between stack depth before and after execution of this code