Class IsEscapingResultExpression
java.lang.Object
org.ek9lang.compiler.phase7.generator.IsEscapingResultExpression
- All Implemented Interfaces:
Predicate<EK9Parser.AssignmentExpressionContext>
final class IsEscapingResultExpression
extends Object
implements Predicate<EK9Parser.AssignmentExpressionContext>
True when the RHS hands back a temp that ALREADY carries a producer +1 (so this consumer must
SCOPE_REGISTER only, never a second RETAIN — a second RETAIN leaves two RETAINs against one
SCOPE_REGISTER = a +1 ARC leak on the LLVM backend). Two families qualify:
- the control-flow expression forms (switch/while/for/try) that
AssignmentExprInstrGenerator.processControlFlowExpressionSTOREs+RETAINs; and - the coalescing (
?: <? >?) and ternary (control<-then:else) expressions, which lower to aCONTROL_FLOW_CHAINwhose body-results are RETAIN'd to escape the chain's inner scope (seeControlFlowChainGenerator.produceEscapingResultandgenerateTernary). Detected onctx.expression()exactly asExprInstrGeneratorroutes them.
THE predicate for this choice: a try-with-resources resource initialiser asks it too
(TryCatchStatementGenerator), so the two consumers of an assignmentExpression cannot disagree about
which forms hand back a +1.
Hold an instance.
-
Constructor Details
-
IsEscapingResultExpression
IsEscapingResultExpression()
-
-
Method Details
-
test
- Specified by:
testin interfacePredicate<EK9Parser.AssignmentExpressionContext>
-