Class BasicBlock

java.lang.Object
org.ek9lang.compiler.ir.BasicBlock
All Implemented Interfaces:
INode

public final class BasicBlock extends Object implements INode
Represents a basic block in the EK9 IR - a sequence of instructions with single entry and exit.

Basic blocks are fundamental units of control flow analysis and optimization. Each block contains a linear sequence of instructions ending with a control flow instruction.

  • Constructor Details

    • BasicBlock

      public BasicBlock(String label)
      Create basic block with given label.
  • Method Details

    • addInstruction

      public BasicBlock addInstruction(IRInstruction instruction)
      Add instruction to this basic block.
    • addInstructions

      public BasicBlock addInstructions(IRInstruction... instructions)
      Add multiple instructions to this basic block.
    • addInstructions

      public BasicBlock addInstructions(List<IRInstruction> instructions)
      Add multiple instructions from a list.
    • addSuccessor

      public BasicBlock addSuccessor(BasicBlock successor)
      Add successor basic block (control flow edge).
    • getLabel

      public String getLabel()
    • getInstructions

      public List<IRInstruction> getInstructions()
    • getPredecessors

      public List<BasicBlock> getPredecessors()
    • getSuccessors

      public List<BasicBlock> getSuccessors()
    • isEmpty

      public boolean isEmpty()
      Check if this block is empty (no instructions).
    • getLastInstruction

      public IRInstruction getLastInstruction()
      Get the last instruction in this block (usually control flow).
    • endsWithControlFlow

      public boolean endsWithControlFlow()
      Check if this block ends with a control flow instruction.
    • isTerminator

      public boolean isTerminator()
      Check if this block is a terminator (ends with RETURN).
    • getMethodCalls

      public List<IRInstruction> getMethodCalls()
      Get all method call instructions in this block.
    • getMemoryManagementInstructions

      public List<IRInstruction> getMemoryManagementInstructions()
      Get all memory management instructions in this block.
    • accept

      public void accept(INodeVisitor visitor)
      Specified by:
      accept in interface INode
    • toString

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

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object