Class DictLiteralInstr

java.lang.Object
org.ek9lang.compiler.ir.instructions.IRInstr
org.ek9lang.compiler.ir.instructions.DictLiteralInstr
All Implemented Interfaces:
CompositeInstr, INode

public final class DictLiteralInstr extends IRInstr implements CompositeInstr
IR instruction for dict literal construction with pre-sized allocation.

Contains structured data for building a dict from pre-evaluated key/value temps. All key and value expressions have been evaluated into temp variables by Phase 7 before this instruction is created.

Backends can choose optimal construction strategy:

  • JVM: new LinkedHashMap(N, 1.0f) + per-entry _putDirect(key, value)
  • LLVM: single allocation with known size
  • Method Details

    • create

      public static DictLiteralInstr create(String result, List<IRInstr> setupInstructions, DictLiteralDetails details, String scopeId, DebugInfo debugInfo)
      Create a dict literal instruction.
      Parameters:
      result - Variable to store the resulting Dict
      setupInstructions - Instructions to evaluate keys/values and manage memory
      details - Dict literal details (type, entries, count)
      scopeId - Scope for memory management
      debugInfo - Source location information
      Returns:
      DictLiteralInstr
    • nestedLists

      public List<CompositeInstr.NestedList> nestedLists()
      Description copied from interface: CompositeInstr
      Every nested list, in the order the IR text renders them. Absent (null) lists are omitted.
      Specified by:
      nestedLists in interface CompositeInstr
    • withNestedLists

      public IRInstr withNestedLists(UnaryOperator<List<IRInstr>> rewrite)
      Description copied from interface: CompositeInstr
      A copy with every nested list replaced by rewrite of it - exactly the lists CompositeInstr.nestedLists() reports, in that order; this when no list changed.
      Specified by:
      withNestedLists in interface CompositeInstr
    • getSetupInstructions

      public List<IRInstr> getSetupInstructions()
      Get the setup instructions (key/value evaluation + memory management).
    • getDetails

      public DictLiteralDetails getDetails()
      Get the dict literal details.
    • getScopeId

      public String getScopeId()
      Get the scope ID for memory management.
    • toString

      public String toString()
      Overrides:
      toString in class IRInstr