Class ScopeInstruction

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

public final class ScopeInstruction extends IRInstruction
Specialized IR instruction for scope management (SCOPE_ENTER, SCOPE_EXIT, SCOPE_REGISTER).

Scope instructions provide exception-safe memory management for EK9. They are no-ops on JVM (garbage collected) but generate cleanup code for LLVM targets.

  • Method Details

    • enter

      public static ScopeInstruction enter(String scopeId)
      Create scope enter instruction: SCOPE_ENTER scope_id Establishes a new memory management scope for exception safety.
    • enter

      public static ScopeInstruction enter(String scopeId, DebugInfo debugInfo)
      Create scope enter instruction with debug info: SCOPE_ENTER scope_id
    • exit

      public static ScopeInstruction exit(String scopeId)
      Create scope exit instruction: SCOPE_EXIT scope_id Automatically RELEASE all objects registered in this scope.
    • exit

      public static ScopeInstruction exit(String scopeId, DebugInfo debugInfo)
      Create scope exit instruction with debug info: SCOPE_EXIT scope_id
    • register

      public static ScopeInstruction register(String object, String scopeId)
      Create scope register instruction: SCOPE_REGISTER object, scope_id Register object for automatic cleanup when scope exits.
    • register

      public static ScopeInstruction register(String object, String scopeId, DebugInfo debugInfo)
      Create scope register instruction with debug info: SCOPE_REGISTER object, scope_id
    • addOperand

      public ScopeInstruction addOperand(String operand)
      Description copied from class: IRInstruction
      Add operand to this instruction.
      Overrides:
      addOperand in class IRInstruction
    • addOperands

      public ScopeInstruction addOperands(String... operands)
      Description copied from class: IRInstruction
      Add multiple operands to this instruction.
      Overrides:
      addOperands in class IRInstruction
    • getScopeId

      public String getScopeId()
      Get scope ID for this scope instruction.
    • getObject

      public String getObject()
      Get object name for SCOPE_REGISTER instructions.