Class CloseStatementGenerator
java.lang.Object
org.ek9lang.compiler.phase7.generator.AbstractGenerator
org.ek9lang.compiler.phase7.generator.CloseStatementGenerator
- All Implemented Interfaces:
Function<EK9Parser.CloseStatementContext, List<IRInstr>>
public final class CloseStatementGenerator
extends AbstractGenerator
implements Function<EK9Parser.CloseStatementContext, List<IRInstr>>
Generates IR for close statements.
Grammar support: closeStatement: CLOSE expression
The close statement is syntactic sugar for calling the _close() operator on an expression.
This enables the pattern: close resource instead of resource.close().
The close operator is used for releasing external resources (sockets, database connections, file handles, etc.). It does NOT free the object's memory - that is handled by: - GC for JVM bytecode backend - ARC (RETAIN/RELEASE) for LLVM backend
Key behaviors: - Evaluates the expression to get the resource reference - Generates CALL resource._close() with void return - The close operator is pure, takes no arguments, and returns void
- See Also:
-
Field Summary
Fields inherited from class AbstractGenerator
debugInfoCreator, instructionBuilder, MAX_MESSAGE_LENGTH, stackContext, typeNameOrException -
Constructor Summary
ConstructorsConstructorDescriptionCloseStatementGenerator(IRGenerationContext stackContext, GeneratorSet generators) Constructor accepting injected GeneratorSet for access to sub-generators. -
Method Summary
Methods inherited from class AbstractGenerator
createTempVariable, createTempVariableFromContext, extractReturnType, getRecordedSymbolOrException, processBlockStatements, truncateMessage, truncateMessage, validateNoPreFlowStatement, validateStatementFormOnly
-
Constructor Details
-
CloseStatementGenerator
CloseStatementGenerator(IRGenerationContext stackContext, GeneratorSet generators) Constructor accepting injected GeneratorSet for access to sub-generators.
-
-
Method Details
-
apply
- Specified by:
applyin interfaceFunction<EK9Parser.CloseStatementContext, List<IRInstr>>
-