Class BlockCodeBuilderImpl

java.lang.Object
org.glavo.classfile.impl.NonterminalCodeBuilder
org.glavo.classfile.impl.BlockCodeBuilderImpl
All Implemented Interfaces:
Consumer<CodeElement>, ClassFileBuilder<CodeElement,CodeBuilder>, CodeBuilder, CodeBuilder.BlockCodeBuilder

public final class BlockCodeBuilderImpl extends NonterminalCodeBuilder implements CodeBuilder.BlockCodeBuilder
  • Constructor Details

    • BlockCodeBuilderImpl

      public BlockCodeBuilderImpl(CodeBuilder parent, Label breakLabel)
  • Method Details

    • start

      public void start()
    • end

      public void end()
    • reachable

      public boolean reachable()
    • isEmpty

      public boolean isEmpty()
    • with

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

      public Label breakLabel()
      Description copied from interface: CodeBuilder.BlockCodeBuilder
      Returns the label locating where control is passed back to the parent block.. A branch to this label "break"'s out of the current block.

      If an instruction occurring immediately after the built block's last instruction would be reachable from that last instruction, then a goto instruction targeting the "break" label is appended to the built block.

      Specified by:
      breakLabel in interface CodeBuilder.BlockCodeBuilder
      Returns:
      the label locating where control is passed back to the parent block.