Class VariableOnlyDeclInstrGenerator
java.lang.Object
org.ek9lang.compiler.phase7.generator.AbstractGenerator
org.ek9lang.compiler.phase7.generator.AbstractVariableDeclGenerator
org.ek9lang.compiler.phase7.generator.VariableOnlyDeclInstrGenerator
- All Implemented Interfaces:
Function<EK9Parser.VariableOnlyDeclarationContext, List<IRInstr>>
public final class VariableOnlyDeclInstrGenerator
extends AbstractVariableDeclGenerator
implements Function<EK9Parser.VariableOnlyDeclarationContext, List<IRInstr>>
Creates IR instructions for variable only declarations.
Uses REFERENCE instructions for all variables - backend handles storage allocation.
Also handles injection-marked variables (the ! suffix) by generating LOAD_STATIC_FIELD
from the global _Application static struct (root-level singleton).
STACK-BASED: Now uses IRGenerationContext for scope management instead of parameter threading.
-
Field Summary
Fields inherited from class AbstractGenerator
stackContext, symbolTypeOrException, typeNameOrException, variableNameForIR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGenerate IR instructions for variable only declaration.A LOCAL declared without a value (x as T?as a block statement): the declaration, then its owner - the declaring scope owns the slot's CURRENT value, so whatever a later:=/:=?leaves in it is released when that scope exits, normally and on unwind (A10, EK9_IR_OWNERSHIP_MODEL.md §6 and §12).The declaration as its two halves (DeclarationParts): the variable's slot, then the coverage probe and an injection's load.Methods inherited from class AbstractVariableDeclGenerator
getDeclInstrsMethods inherited from class AbstractGenerator
addCoverageProbe, createTempVariable, createTempVariableFromContext, getRecordedSymbolOrException, processBlockStatements, processBlockStatements, resultVariableOrTemp
-
Constructor Details
-
VariableOnlyDeclInstrGenerator
-
-
Method Details
-
apply
Generate IR instructions for variable only declaration. Example: someVar as String? — Generates: REFERENCE only (no assignment) Example: logger as AbstractLogger! — Generates: REFERENCE + LOAD_STATIC_FIELD from _Application STACK-BASED: Gets scope ID from stack context instead of parameter threading.- Specified by:
applyin interfaceFunction<EK9Parser.VariableOnlyDeclarationContext, List<IRInstr>>
-
parts
The declaration as its two halves (DeclarationParts): the variable's slot, then the coverage probe and an injection's load. -
localDeclaration
A LOCAL declared without a value (x as T?as a block statement): the declaration, then its owner - the declaring scope owns the slot's CURRENT value, so whatever a later:=/:=?leaves in it is released when that scope exits, normally and on unwind (A10, EK9_IR_OWNERSHIP_MODEL.md §6 and §12). Each reassignment releases the value it replaces; a slot never assigned is still null, which the release skips. The owner is part of the declaration (SLOT_DECLARE x, T, s).Only a block statement is a local: a parameter is borrowed, the returning variable belongs to the caller and a property to its object, so those declarations go through
apply(EK9Parser.VariableOnlyDeclarationContext)alone. An injected local (!) already has its owner fromgenerateInjectionLoad(ISymbol, List).
-