Class PrimitiveToEk9Conversion

java.lang.Object
org.ek9lang.compiler.phase7.synthesis.support.PrimitiveToEk9Conversion

public final class PrimitiveToEk9Conversion extends Object
THE single builder for the "wrap a primitive/Java value into its EK9 object via a static _of factory" IR sequence — Integer._of(int), String._of(java.lang.String), Boolean._of(boolean) and the like.

Reuse this; do NOT re-derive the CALL_STATIC _of + SCOPE_REGISTER sequence inline — it was hand-rolled identically across the enum synthesis generators (Equals/Compare/HashCode/String/Json/IsSet/IncrementDecrement), varying only in the wrapper type name and the _of parameter type. The factory hands back a fresh object at +1 (Contract 2), so the result is registered and NEVER retained. Emits:

  resultVar = CALL_STATIC ek9Type._of(primitiveVar)
  SCOPE_REGISTER resultVar, scopeId

Hold an instance.

  • Constructor Details

    • PrimitiveToEk9Conversion

      public PrimitiveToEk9Conversion()
  • Method Details

    • convert

      public List<IRInstr> convert(String resultVar, String primitiveVar, String ek9TypeName, String ofParamType, SynthesisScope ctx)
      Build the ek9Type._of(primitiveVar) static-call sequence with ARC ownership: the _of factory hands back a fresh object at +1, so the scope owns it (DROP_AT_EXIT) and nothing retains it.
      Parameters:
      resultVar - temp receiving the wrapped EK9 object
      primitiveVar - the primitive/Java value passed to _of
      ek9TypeName - fully-qualified name of the EK9 wrapper type (call receiver + return type)
      ofParamType - the _of parameter type name (e.g. IRConstants.INTEGER)
      ctx - synthesis scope providing debug info + the scope id that owns the result
      Returns:
      the IR instructions for the conversion
    • ofCall

      public IRInstr ofCall(String resultVar, String primitiveVar, String ek9TypeName, String ofParamType, SynthesisScope ctx)
      THE ek9Type._of(primitiveVar) static call alone, for a caller that states the result's owner itself.