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.processControlFlowExpression STOREs+RETAINs; and
  • the coalescing (?: <? >?) and ternary (control<-then:else) expressions, which lower to a CONTROL_FLOW_CHAIN whose body-results are RETAIN'd to escape the chain's inner scope (see ControlFlowChainGenerator.produceEscapingResult and generateTernary). Detected on ctx.expression() exactly as ExprInstrGenerator routes 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.