Class ConstrainedTypeInstrs

java.lang.Object
org.ek9lang.compiler.phase7.ConstrainedTypeInstrs

final class ConstrainedTypeInstrs extends Object
The instructions every part of a constrained type's generation shares (ConstraintLowering, ConstrainedConstruction, ConstrainedDelegation): the delegate and _viable field loads and stores, the base value's copy, the _isSet of a base value and the call metadata of the base and constrained constructors. Each is emitted the one way here.
  • Field Details

  • Constructor Details

  • Method Details

    • shape

    • baseConstructorMetaData

      CallMetaDataDetails baseConstructorMetaData(List<ISymbol> argumentTypes)
      Metadata for a constructor of the BASE type - every constrained-type lowering that materialises a base value (unset delegate, conversion, copy) calls one of these.
    • constrainedConstructorMetaData

      CallMetaDataDetails constrainedConstructorMetaData()
      Metadata for the constrained type's own wrapping constructor CT(base).
    • booleanType

      ISymbol booleanType()
    • booleanOperatorMetaData

      CallMetaDataDetails booleanOperatorMetaData(String methodName)
      Metadata for the Boolean _and/_or that chains constraint results. These carry a virtual flag (unlike BooleanOperatorCallDetails), so the descriptor stays inline at its sites; only the metadata is shared.
    • baseMetaData

      CallMetaDataDetails baseMetaData(String methodName, List<ISymbol> argumentTypes)
      Metadata for the BASE type's methodName taking argumentTypes.
    • constructorCall

      String constructorCall(List<IRInstr> instructions, String typeName, List<String> parameterTypes, List<String> arguments, CallMetaDataDetails metaData, DebugInfo debugInfo)
      THE constructor call on a type made here: CALL typeName.<init>(arguments) - its +1 result's owner is the caller's to state.
    • isSetOf

      String isSetOf(List<IRInstr> instructions, String subjectVar, String scopeId, DebugInfo debugInfo)
      subject._isSet() on a BASE value, through THE ? call (IsSetCallDetailsCreator): its +1 Boolean is dropped at scopeId's exit (registered only - as a branch condition it is not kept).
    • definingTypeOf

      ISymbol definingTypeOf(String methodName, List<ISymbol> argumentTypes)
      The type that DECLARES the base method a call forwards to, via THE shared DefiningType - so the descriptor owner here is derived exactly as at every other phase-7 call site (Base.balanceOf, never Derived.balanceOf).

      🔑 Since FE11 a constrained type over a class in a HIERARCHY carries operators its base only INHERITS (_eq(Base), _gt(Integer), ...), and its constrain as > 0 check calls the base's > - which may also be inherited. Naming the constraining type for those produced calls to Derived._eq(Base): a method Derived does not declare. The JVM found it by virtual lookup; natively it is a DIRECT call to a symbol no object file defines, so linking failed. Callers must take isTraitCall from the SAME returned type (the CallTargetResolution invariant). Falls back to the constraining type when nothing resolves.

    • copyBaseValue

      String copyBaseValue(List<IRInstr> instructions, String sourceVar, DebugInfo debugInfo)
      Produce the constrained type's own copy of a base-type value, on both boundaries - storing a constructor argument (copy-in) and returning a promoted value (copy-out) - so a later in-place change to the caller's value does not reach the constrained value and bypass its constraint.

      The copy is the base's public copy constructor Base(source), which phase-2 PopulateConstrainedTypeOrError requires (E06131, decision D10). It copies exactly as deeply as that constructor does - the built-in value types copy their value; a developer's record or class copies what its copy constructor's author wrote. There is no other mechanism: the old fallback, Base() then :=:, was a shallow copy nobody wrote and is gone.

      The copy is a fresh (+1) value and its owner is the caller's to state: a field's pre-take, or a move into the return variable - one helper with two destinations (J13) states neither.

      Returns:
      the temp holding the fresh, independent copy
    • loadDelegate

      String loadDelegate(List<IRInstr> instructions, String objectVar, String scopeId, DebugInfo debugInfo)
      The delegate of objectVar (a value of this constrained type), borrowed for the scope: THE delegate load (DelegateLoad).
    • storeDelegate

      void storeDelegate(List<IRInstr> instructions, String value, DebugInfo debugInfo)
      THE first store into this._delegate (in _i_init, or a constructor): the field takes its own reference to a value its scope owns - FIELD_ASSIGN [copy, init].
    • storeViable

      void storeViable(List<IRInstr> instructions, String scopeId, DebugInfo debugInfo)
      THE store of this._viable = true: after a value has been accepted by the constraint check (a breach Panics before reaching here). Shared by the parameterised constructor and the mutating delegations.
    • storeFirstViable

      void storeFirstViable(List<IRInstr> instructions, String value, DebugInfo debugInfo)
      THE first store into this._viable (in _i_init): FIELD_ASSIGN [copy, init] of a value its scope owns.
    • viableField

      FieldTarget viableField(String objectVar)
      The _viable field of objectVar, by its index.
    • createBasicBlock

      BasicBlockInstr createBasicBlock(List<IRInstr> instructions)