Enum Class IROpcode

java.lang.Object
java.lang.Enum<IROpcode>
org.ek9lang.compiler.ir.IROpcode
All Implemented Interfaces:
Serializable, Comparable<IROpcode>, Constable

public enum IROpcode extends Enum<IROpcode>
Enumeration of all IR opcodes used in the EK9 intermediate representation.

Key Design Principle: All EK9 operators become method calls (CALL instructions). No primitive arithmetic operations (ADD, SUB, etc.) are included - everything goes through EK9's object method dispatch system.

This design ensures target-agnostic IR that works equally well for: - JVM bytecode generation - LLVM-C++ target

  • Enum Constant Details

    • LOAD

      public static final IROpcode LOAD
      Load value from memory location into temporary/register. Format: LOAD dest = source_location
    • STORE

      public static final IROpcode STORE
      Store value from temporary/register into memory location. Format: STORE dest_location = source
    • LOAD_LITERAL

      public static final IROpcode LOAD_LITERAL
      Load literal/constant value into temporary/register. Format: LOAD_LITERAL dest = literal_value, literal_type Handles: String literals, numeric literals, boolean literals, etc.
    • REFERENCE

      public static final IROpcode REFERENCE
      Declare variable reference (no memory allocation). Format: REFERENCE variable_name, type_info Used for parameters and variable-only declarations. Backend handles appropriate reference storage.
    • CALL

      public static final IROpcode CALL
      Standard method call with resolved signature. Format: CALL result = object.method(args...) Handles: EK9 operators (a + b → a._add(b)), normal method calls
    • CALL_VIRTUAL

      public static final IROpcode CALL_VIRTUAL
      Virtual method call (polymorphic dispatch). Format: CALL_VIRTUAL result = object.method(args...)
    • CALL_STATIC

      public static final IROpcode CALL_STATIC
      Static method/function call. Format: CALL_STATIC result = Type.method(args...)
    • CALL_DISPATCHER

      public static final IROpcode CALL_DISPATCHER
      Dispatcher method call (runtime type-based dispatch). Format: CALL_DISPATCHER result = object.dispatcherMethod(args...) Uses runtime type information and dispatch matrix
    • BRANCH

      public static final IROpcode BRANCH
      Unconditional branch/jump. Format: BRANCH target_label
    • BRANCH_TRUE

      public static final IROpcode BRANCH_TRUE
      Branch if condition is true. Format: BRANCH_TRUE condition, target_label
    • BRANCH_FALSE

      public static final IROpcode BRANCH_FALSE
      Branch if condition is false. Format: BRANCH_FALSE condition, target_label
    • RETURN

      public static final IROpcode RETURN
      Return from method/function. Format: RETURN [value]
    • ASSERT

      public static final IROpcode ASSERT
      Assert that condition is true. Format: ASSERT condition Traps/throws if condition is false.
    • THROW

      public static final IROpcode THROW
      Throw exception. Format: THROW exception_object
    • SETUP_HANDLER

      public static final IROpcode SETUP_HANDLER
      Setup exception handler for try block. Format: SETUP_HANDLER handler_label, exception_types...
    • CLEANUP

      public static final IROpcode CLEANUP
      Cleanup after exception handling. Format: CLEANUP
    • RETAIN

      public static final IROpcode RETAIN
      Increment object reference count. Format: RETAIN object JVM: no-op, LLVM: increment ref count
    • RELEASE

      public static final IROpcode RELEASE
      Decrement object reference count. Format: RELEASE object JVM: no-op, LLVM: decrement ref count, possible deallocation
    • SCOPE_ENTER

      public static final IROpcode SCOPE_ENTER
      Enter new memory management scope. Format: SCOPE_ENTER scope_id Creates cleanup boundary for exception safety
    • SCOPE_EXIT

      public static final IROpcode SCOPE_EXIT
      Exit memory management scope. Format: SCOPE_EXIT scope_id Automatically RELEASE all registered objects in scope
    • SCOPE_REGISTER

      public static final IROpcode SCOPE_REGISTER
      Register object for automatic cleanup in scope. Format: SCOPE_REGISTER object, scope_id Object will be RELEASE'd when scope exits
  • Method Details

    • values

      public static IROpcode[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static IROpcode valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null