Class CloseChain
java.lang.Object
org.ek9lang.compiler.phase7.generator.AbstractGenerator
org.ek9lang.compiler.phase7.generator.CloseChain
THE generated close chain in IR - use it, never build a property close by hand (Steve, 2026-10-06: "if you hold
it, you close it"; the C++/Swift destructor model). What is closed is
CloseSteps's decision, read by the
phase-5 call graph too; how it is closed is ResourceCloser's, the same shape B region try-with-resources
and the statement-owned temporaries use (every close runs, the first EK9 Exception is kept, later ones are
suppressed onto it, a Panic aborts the rest).
closeOperator(List, IAggregateSymbol, DebugInfo)- a type'soperator close: the body (empty fordefault operator close) runs first with everything still open, then - as its finally - each closeable field it holds is closed if present, last acquired first, then the super class's close is called NON-virtually. Used byOperationDfnGeneratorfor a hand-written close andsynthesis/CloseGeneratorfor the default one, for every construct kind and every parameterisation of a generic.constructionFailure(List, IAggregateSymbol, DebugInfo)- a constructor that fails with an EK9 Exception after its object's own construction call (super(...)/this(...), or the implicit super) runs the same closes - the fields acquired so far, then the super part, which that call completed - and rethrows (D10, partial construction).
Nothing at all is emitted when CloseSteps.Steps.isEmpty(): a leaf resource's close and its constructors
are exactly as written.
-
Field Summary
Fields inherited from class AbstractGenerator
constantCopyOnAccessLoader, debugInfoCreator, instructionBuilder, MAX_MESSAGE_LENGTH, stackContext, synthesisedCallMetaData, typeNameOrException -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncloseOperator(List<IRInstr> body, IAggregateSymbol aggregate, DebugInfo debugInfo) The body of a type's close followed, on every path, by its generated chain.constructionFailure(List<IRInstr> body, IAggregateSymbol aggregate, DebugInfo debugInfo) A constructor's work after its construction call, with the chain run only if it fails.constructionFailureInOwnScope(List<IRInstr> body, IAggregateSymbol aggregate, DebugInfo debugInfo) constructionFailure(List, IAggregateSymbol, DebugInfo)in a scope of its own (SCOPE_ENTER/SCOPE_EXITaround it), so what the region registers has an entered scope to be released by: a generated constructor has no body scope, and a written one's region sits after its body scope has been left (or, after an explicitsuper(...), inside it).booleanisEmpty(IAggregateSymbol aggregate) True when a close of this type generates nothing.
-
Constructor Details
-
CloseChain
-
-
Method Details
-
isEmpty
True when a close of this type generates nothing. -
closeOperator
public List<IRInstr> closeOperator(List<IRInstr> body, IAggregateSymbol aggregate, DebugInfo debugInfo) The body of a type's close followed, on every path, by its generated chain.- Parameters:
body- the body's instructions (empty fordefault operator close)aggregate- the type whose close this isdebugInfo- where the generated closes are attributed
-
constructionFailure
public List<IRInstr> constructionFailure(List<IRInstr> body, IAggregateSymbol aggregate, DebugInfo debugInfo) A constructor's work after its construction call, with the chain run only if it fails.- Parameters:
body- the instructions after the construction call (_i_initand the constructor body)aggregate- the type being constructeddebugInfo- where the generated closes are attributed
-
constructionFailureInOwnScope
public List<IRInstr> constructionFailureInOwnScope(List<IRInstr> body, IAggregateSymbol aggregate, DebugInfo debugInfo) constructionFailure(List, IAggregateSymbol, DebugInfo)in a scope of its own (SCOPE_ENTER/SCOPE_EXITaround it), so what the region registers has an entered scope to be released by: a generated constructor has no body scope, and a written one's region sits after its body scope has been left (or, after an explicitsuper(...), inside it).
-