Class TextFactoryDispatch

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

public final class TextFactoryDispatch extends Object
THE single decision point for lowering a text constructor call.

A TEXT base type (genus SymbolGenus.TEXT with no LANG squirrelled data) is abstract: it must never be constructed directly. Instead the call is dispatched at runtime through a synthesized static _textFactory(String) that returns the correct per-language variant (see TextSubsystemAsmGenerator).

EVERY site that lowers a text constructor call MUST route through here — both a standalone/assigned call (ConstructorCallProcessor) AND the start of an object-access chain (ObjectAccessInstrGenerator, e.g. SomeText("en").message(...)). If the two paths diverge they behave differently: the direct-construction path builds the abstract base instance, which is set but carries no message-method bodies, so a chained message call silently returns unset. That divergence was a real bug (inline text message calls returned blank). Call this helper; do not re-derive the genus/LANG check.

  • Method Details

    • redirectForTextBase

      public static Optional<CallDetails> redirectForTextBase(IScope constructorParentScope, String typeName, List<String> parameterTypes, List<String> argumentVariables, CallMetaDataDetails metaData)
      If constructorParentScope is a TEXT base type, return the static _textFactory CallDetails to emit (via CallInstr.callStatic) instead of a direct constructor call; otherwise Optional.empty() and the caller emits a normal constructor call.
      Parameters:
      constructorParentScope - the parent scope of the resolved constructor MethodSymbol
      typeName - the fully-qualified (resolved) text base type name
      parameterTypes - the constructor parameter types (the language String)
      argumentVariables - the evaluated argument temporaries (the language value)
      metaData - the call metadata for the emitted call