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 + RETAIN + 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. Emits:

  resultVar = CALL_STATIC ek9Type._of(primitiveVar)
  RETAIN resultVar
  SCOPE_REGISTER resultVar, scopeId
  • Method Details

    • convert

      public static List<IRInstr> convert(String resultVar, String primitiveVar, String ek9TypeName, String ofParamType, SynthesisScope ctx)
      Build the ek9Type._of(primitiveVar) static-call sequence with ARC registration.
      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 for SCOPE_REGISTER
      Returns:
      the IR instructions for the conversion