Class EnumIteratorImplInstr

java.lang.Object
org.ek9lang.compiler.ir.instructions.IRInstr
org.ek9lang.compiler.ir.instructions.EnumIteratorImplInstr
All Implemented Interfaces:
INode

public final class EnumIteratorImplInstr extends IRInstr
High-level IR instruction for generating enum iterator implementation.

This instruction abstracts the creation of a concrete iterator class for enumerations. Instead of generating detailed IR instructions for List creation, element addition, etc., this instruction tells the backend to generate an efficient iterator implementation appropriate for the target.

The backend is responsible for:

  • Generating public static fields for each enum value on the enum class
  • Initializing them in the class initializer with correct _ordinal and _name
  • Generating an anonymous iterator class extending the parameterized Iterator type
  • Implementing hasNext(), next(), and _isSet() methods
  • Returning an instance of this anonymous iterator

JVM backend generates an anonymous inner class with static field references. LLVM backend generates struct + functions + static data section.

  • Method Details

    • enumIteratorImpl

      public static EnumIteratorImplInstr enumIteratorImpl(EnumIteratorImplDetails details)
      Create an enum iterator implementation instruction.
      Parameters:
      details - The enum iterator implementation details
    • getEnumTypeName

      public String getEnumTypeName()
      Get the fully qualified enumeration type name.
    • getSuperTypeName

      public String getSuperTypeName()
      Get the fully qualified super type name (parameterized Iterator wrapper).
    • getEnumValues

      public List<String> getEnumValues()
      Get the enum values in declaration order.
    • getEnumValueCount

      public int getEnumValueCount()
      Get the number of enum values.
    • toString

      public String toString()
      Overrides:
      toString in class IRInstr