Interface CodeEmitter


public interface CodeEmitter
Instructions of a method body, the subset the copier template needs. Names of classes are internal names (java/lang/Object), types of fields and methods are descriptors.
  • Method Details

    • loadReference

      void loadReference(int slot)
      Pushes a reference from a local variable.
      Parameters:
      slot - slot of the variable
    • loadInt

      void loadInt(int slot)
      Pushes an int from a local variable.
      Parameters:
      slot - slot of the variable
    • pushNull

      void pushNull()
      Pushes null.
    • pushInt

      void pushInt(int value)
      Pushes an int constant.
      Parameters:
      value - value
    • checkCast

      void checkCast(String type)
      Checks the type of the reference on the stack.
      Parameters:
      type - internal name of a class or descriptor of an array
    • getField

      void getField(String owner, String name, String descriptor)
      Replaces the object on the stack with the value of its field.
      Parameters:
      owner - internal name of the class declaring the field
      name - field name
      descriptor - field descriptor
    • putField

      void putField(String owner, String name, String descriptor)
      Sets the field of the object below the value on the stack.
      Parameters:
      owner - internal name of the class declaring the field
      name - field name
      descriptor - field descriptor
    • loadString

      void loadString(String value)
      Pushes a string constant.
      Parameters:
      value - value
    • loadClass

      void loadClass(String type)
      Pushes a class constant.
      Parameters:
      type - internal name of a class
    • getStatic

      void getStatic(String owner, String name, String descriptor)
      Pushes the value of a static field.
      Parameters:
      owner - internal name of the class declaring the field
      name - field name
      descriptor - field descriptor
    • putStatic

      void putStatic(String owner, String name, String descriptor)
      Sets a static field to the value on the stack.
      Parameters:
      owner - internal name of the class declaring the field
      name - field name
      descriptor - field descriptor
    • invokeStatic

      void invokeStatic(String owner, String name, String descriptor)
      Invokes a static method of a class.
      Parameters:
      owner - internal name of the class declaring the method
      name - method name
      descriptor - method descriptor
    • invokeSpecial

      void invokeSpecial(String owner, String name, String descriptor)
      Invokes a constructor or a private or super method.
      Parameters:
      owner - internal name of the class declaring the method
      name - method name
      descriptor - method descriptor
    • invokeVirtual

      void invokeVirtual(String owner, String name, String descriptor)
      Invokes a virtual method.
      Parameters:
      owner - internal name of the class declaring the method
      name - method name
      descriptor - method descriptor
    • storeReference

      void storeReference(int slot)
      Stores the reference on the stack into a local variable.
      Parameters:
      slot - index of the local variable
    • ifNull

      void ifNull(CodeLabel label)
      Jumps to the label if the reference on the stack is null.
      Parameters:
      label - target
    • returnVoid

      void returnVoid()
      Returns from a void method.
    • newLabel

      CodeLabel newLabel()
      Creates a label to be bound later.
      Returns:
      label
    • bind

      void bind(CodeLabel label)
      Binds the label to the current position.
      Parameters:
      label - label
    • tableSwitch

      void tableSwitch(int low, CodeLabel defaultLabel, CodeLabel... labels)
      Jumps by the int on the stack: to labels[value - low] or to the default label.
      Parameters:
      low - value of the first label
      defaultLabel - target of the other values
      labels - targets of the values from low