Class SanitizedParameterPrologue
The RECEIVING callable cleans its own parameters: every body the compiler generates (function, method, operator, constructor, program, text method, dynamic function) emits this prologue right after declaring its parameters. Every route into the body - a direct call, an operator, a stream stage, a dispatcher handler, a switch case, a callback from built-in Java code, the command line - therefore arrives cleaned, because there is no route that does not enter the body. Cleaning at call sites could never be complete: a callback from Java has no EK9 call site at all.
For each parameter marked SANITIZED_REQUIRED (the as sanitized String modifier) it emits:
_tempN = SANITIZE param SCOPE_REGISTER _tempN, scope STORE param, _tempN
SANITIZE yields the receiver's own copy (+1) of a safe String, or an unset String when a threat is found, so the caller's String is never shared with the callee. The temp is scope-registered, which balances that +1 at scope exit. The parameter is then rebound to the temp with a bare STORE: there is NO RELEASE of the parameter (the caller owns the argument, so releasing it would be a use-after-free on LLVM) and NO RETAIN (the scope registration already owns the copy). This is the only place IR stores to a parameter.
Bodies the compiler synthesises to FORWARD a call (a 'by' delegation, an aspect proxy, a text base, a bodyless dynamic function) must NOT call this: the body they forward to cleans the parameter, and a second prologue would only scan the input twice.
-
Method Summary
Modifier and TypeMethodDescriptionof(IRGenerationContext stackContext, List<ISymbol> parameters) Create the prologue that cleans everySANITIZED_REQUIREDparameter in place, each instruction attributed to the parameter's own declaration.of(IRGenerationContext stackContext, List<ISymbol> parameters, DebugInfo debugInfo) Create the prologue with every instruction attributed todebugInfo.
-
Method Details
-
of
Create the prologue that cleans everySANITIZED_REQUIREDparameter in place, each instruction attributed to the parameter's own declaration. Use this when the body declares the parameters itself. Must be added to the body after the parameters are declared and before anything reads them.- Parameters:
stackContext- the IR generation context (temp names + current body scope)parameters- the parameters the body declares- Returns:
- the prologue instructions, empty when no parameter is sanitized
-
of
public static List<IRInstr> of(IRGenerationContext stackContext, List<ISymbol> parameters, DebugInfo debugInfo) Create the prologue with every instruction attributed todebugInfo. Use this when the parameters are declared elsewhere - a dynamic function takes them from its super function, whose declaration may be in another source file (or built in), so its tokens must not become this body's line numbers.- Parameters:
stackContext- the IR generation context (temp names + current body scope)parameters- the parameters the body declaresdebugInfo- the source location for the prologue- Returns:
- the prologue instructions, empty when no parameter is sanitized
-