Class BasicBlockInstr

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

public final class BasicBlockInstr 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

    • BasicBlockInstr

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

    • addInstruction

      public void addInstruction(IRInstr instruction)
      Add instruction to this basic block.
    • addInstructions

      public BasicBlockInstr addInstructions(IRInstr... instructions)
      Add multiple instructions to this basic block.
    • addInstructions

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

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

      public String getLabel()
    • getInstructions

      public List<IRInstr> getInstructions()
    • getPredecessors

      public List<BasicBlockInstr> getPredecessors()
    • getSuccessors

      public List<BasicBlockInstr> getSuccessors()
    • isEmpty

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

      public IRInstr 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<IRInstr> getMethodCalls()
      Get all method call instructions in this block.
    • getMemoryManagementInstructions

      public List<IRInstr> 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