Class IRInstructionBuilder
java.lang.Object
org.ek9lang.compiler.phase7.generation.IRInstructionBuilder
Stateful instruction builder that uses the IR generation context automatically.
This builder eliminates the need for manual BasicDetails construction and scope/debug info management by using the current stack context from IRGenerationContext automatically.
All instruction creation methods use the current scope and debug information from the stack, ensuring consistency and eliminating parameter threading.
-
Constructor Summary
ConstructorsConstructorDescriptionIRInstructionBuilder
(IRGenerationContext context) Create a new instruction builder with stack-based context access. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addInstruction
(IRInstr instruction) Add a raw instruction to the current context.void
addInstructions
(List<IRInstr> instructions) Add multiple raw instructions to the current context.createCall
(CallContext callContext) Create a call instruction using current context.createDebugInfo
(org.antlr.v4.runtime.Token token) Create debug info from an ANTLR token.createDebugInfo
(org.antlr.v4.runtime.tree.ParseTree ctx) createDebugInfo
(Ek9Token token) Create debug info from a token.createDebugInfo
(IToken token) Create debug info from an EK9 IToken.createLabel
(String labelPrefix) Create a label instruction using current context.Create a temporary variable name.Extract all built instructions and clear the builder.Get the IRGenerationContext for scope and debug management.Get the original IRContext for legacy generator compatibility.void
loadLiteral
(String variableName, String literalValue, String literalType) Load literal instruction using current context.void
manageVariable
(String variableName) Create a memory retain and register for memory management current context.void
returnValue
(String variableName, DebugInfo debugInfo) void
-
Constructor Details
-
IRInstructionBuilder
Create a new instruction builder with stack-based context access. This enables generators to access the current IRContext without parameter threading.
-
-
Method Details
-
createDebugInfo
-
createDebugInfo
-
createDebugInfo
Create debug info from an ANTLR token. -
createDebugInfo
-
createTempVariable
Create a temporary variable name. -
createLabel
Create a label instruction using current context. -
loadLiteral
-
createCall
Create a call instruction using current context. -
manageVariable
Create a memory retain and register for memory management current context. -
getContext
Get the IRGenerationContext for scope and debug management. This allows helpers to access the stack-based context when needed. -
getIRContext
Get the original IRContext for legacy generator compatibility. This provides access to parsed module, compiler flags, and other context without parameter threading through the call stack. -
returnVoid
public void returnVoid() -
returnValue
-
addInstruction
Add a raw instruction to the current context. -
addInstructions
-
extractInstructions
-