Class SanitizationInjector

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

public final class SanitizationInjector extends Object
THE single source for point-of-use argument sanitisation in IR generation — call this, do not re-derive the loop.

For each call parameter marked SANITIZED_REQUIRED (the as sanitized String modifier), emits SanitizeInstr to produce a NEW sanitised object, RETAIN + SCOPE_REGISTER it for LLVM ARC (the JVM backend ignores the memory ops — GC handles memory), and replaces the matching argument variable in-place with the sanitised temp.

This consolidates five previously-divergent copies (CallInstrGenerator ×2, ObjectAccessInstrGenerator, ConstructorCallProcessor, FunctionCallProcessor). The loop is bounded by BOTH parameters.size() and arguments.size(): a parameter with no matching argument is skipped rather than driving an arguments.get(i) out-of-bounds — three of the former copies omitted that bound. Only a parameter that both HAS a supplied argument and is marked sanitised is ever rewritten, so this is behaviour-identical to the guarded copies and strictly safer than the unguarded ones.

  • Method Details

    • inject

      public static void inject(IRGenerationContext stackContext, List<ISymbol> parameters, List<String> arguments, List<IRInstr> instructions)
      Inject SANITIZE (+ ARC memory ops) for every SANITIZED_REQUIRED parameter that has a supplied argument, rewriting that argument in arguments to the sanitised temp.
      Parameters:
      stackContext - the IR generation context (temp names + current scope)
      parameters - the resolved call parameters to check for the sanitisation marker
      arguments - the argument variable names (modified in place)
      instructions - the instruction list to inject into