Class CaptureStores

java.lang.Object
org.ek9lang.compiler.phase7.support.CaptureStores

public final class CaptureStores extends Object
THE stores of a dynamic class's or dynamic function's captured values into its fields (DFN-6): each captured variable, in order, is a property of the construct - a slot its OBJECT owns - and takes its own reference to the value captured: SLOT_ASSIGN this.x, x [copy, init] (VariableMemoryManagement.propertyAssigned(String, String, boolean, DebugInfo)), lowered to STORE this.x, x; RETAIN this.x.

The reference is taken THROUGH THE FIELD just stored, never RETAIN x: the stores go before the constructor's _i_init call (initialisers may read a capture), and in an explicit constructor that is BEFORE the body declares its parameter x. A native back end resolves a RETAIN x there to x's slot, not yet stored - so the field took no reference and the body's own this.x = x then freed the caller's value (tupleDynamicClassBasic / CustomConstructor, family 6).

Both dynamic-construct generators emit their capture constructor's stores through here; where in the constructor they go stays each generator's own decision.
  • Method Details

    • of

      public static List<IRInstr> of(List<ISymbol> capturedVars, DebugInfo debugInfo)
      Parameters:
      capturedVars - the construct's captured variables, in capture order
      debugInfo - debug information for each instruction
      Returns:
      the store of every captured variable into its property