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] (OwnershipStatements.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, and both put them before _i_init, while the constructor's body is built: a dynamic function's through processSyntheticConstructor (DFN-6 step 2, IR tidy W3.3b), a dynamic class's in THE capture constructor (support/IsCaptureConstructor) - the synthetic one the same way, an explicit one by OperationDfnGenerator just after its super(...) call (or first, when it has none or delegates with this(...)). Each captured value comes from the capture constructor's parameter AT ITS POSITION: an explicit capture constructor (the tuple's 'interface') names its parameters as it wishes.

  • Constructor Details

    • CaptureStores

      public CaptureStores()
  • Method Details

    • of

      public List<IRInstr> of(List<ISymbol> capturedVars, DebugInfo debugInfo)
      The stores of a construct whose capture constructor's parameters are its captured variables themselves (a dynamic function's, or a dynamic class's synthetic one).
      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
    • of

      public List<IRInstr> of(List<ISymbol> capturedVars, List<ISymbol> parameters, DebugInfo debugInfo)
      The stores of each captured variable's property from the capture constructor's parameter at the same position.
      Parameters:
      capturedVars - the construct's captured variables, in capture order
      parameters - the capture constructor's parameters, one per captured variable, in the same order
      debugInfo - debug information for each instruction
      Returns:
      the store of every captured variable into its property