Class TransformingCodeBuilder

java.lang.Object
org.glavo.classfile.impl.TransformingCodeBuilder
All Implemented Interfaces:
Consumer<CodeElement>, ClassFileBuilder<CodeElement,CodeBuilder>, CodeBuilder, TerminalCodeBuilder

public final class TransformingCodeBuilder extends Object implements TerminalCodeBuilder
  • Constructor Details

  • Method Details

    • with

      public CodeBuilder with(CodeElement e)
      Description copied from interface: ClassFileBuilder
      Integrate the ClassFileElement into the entity being built.
      Specified by:
      with in interface ClassFileBuilder<CodeElement,CodeBuilder>
      Parameters:
      e - the element
      Returns:
      this builder
    • original

      public Optional<CodeModel> original()
      Description copied from interface: CodeBuilder
      Returns the CodeModel representing the method body being transformed, if this code builder represents the transformation of some CodeModel.
      Specified by:
      original in interface CodeBuilder
      Returns:
      the CodeModel representing the method body being transformed, if this code builder represents the transformation of some CodeModel
    • newLabel

      public Label newLabel()
      Description copied from interface: CodeBuilder
      Returns a fresh unbound label.
      Specified by:
      newLabel in interface CodeBuilder
      Returns:
      a fresh unbound label
    • startLabel

      public Label startLabel()
      Description copied from interface: CodeBuilder
      Returns the label associated with the beginning of the current block. If the current CodeBuilder is not a "block" builder, such as those provided by CodeBuilder.block(Consumer) or CodeBuilder.ifThenElse(Consumer, Consumer), the current block will be the entire method body.
      Specified by:
      startLabel in interface CodeBuilder
      Returns:
      the label associated with the beginning of the current block
    • endLabel

      public Label endLabel()
      Description copied from interface: CodeBuilder
      Returns the label associated with the end of the current block. If the current CodeBuilder is not a "block" builder, such as those provided by CodeBuilder.block(Consumer) or CodeBuilder.ifThenElse(Consumer, Consumer), the current block will be the entire method body.
      Specified by:
      endLabel in interface CodeBuilder
      Returns:
      the label associated with the end of the current block
    • receiverSlot

      public int receiverSlot()
      Description copied from interface: CodeBuilder
      Returns the local variable slot associated with the receiver..
      Specified by:
      receiverSlot in interface CodeBuilder
      Returns:
      the local variable slot associated with the receiver
    • parameterSlot

      public int parameterSlot(int paramNo)
      Description copied from interface: CodeBuilder
      Returns the local variable slot associated with the specified parameter.. The returned value is adjusted for the receiver slot (if the method is an instance method) and for the requirement that long and double values require two slots.
      Specified by:
      parameterSlot in interface CodeBuilder
      Parameters:
      paramNo - the index of the parameter
      Returns:
      the local variable slot associated with the specified parameter
    • allocateLocal

      public int allocateLocal(TypeKind typeKind)
      Description copied from interface: CodeBuilder
      Returns the local variable slot of a fresh local variable. This method makes reasonable efforts to determine which slots are in use and which are not. When transforming a method, fresh locals begin at the maxLocals of the original method. For a method being built directly, fresh locals begin after the last parameter slot.

      If the current code builder is a "block" code builder provided by CodeBuilder.block(Consumer), CodeBuilder.ifThen(Consumer), or CodeBuilder.ifThenElse(Consumer, Consumer), at the end of the block, locals are reset to their value at the beginning of the block.

      Specified by:
      allocateLocal in interface CodeBuilder
      Parameters:
      typeKind - the type of the local variable
      Returns:
      the local variable slot of a fresh local variable
    • constantPool

      public ConstantPoolBuilder constantPool()
      Description copied from interface: ClassFileBuilder
      Returns the constant pool builder associated with this builder.
      Specified by:
      constantPool in interface ClassFileBuilder<CodeElement,CodeBuilder>
      Returns:
      the constant pool builder associated with this builder