Class AssignExpressionToSymbol

java.lang.Object
org.ek9lang.compiler.phase7.generator.AbstractGenerator
org.ek9lang.compiler.phase7.generator.AssignExpressionToSymbol
All Implemented Interfaces:
BiFunction<ISymbol, EK9Parser.AssignmentExpressionContext, List<IRInstr>>

final class AssignExpressionToSymbol extends AbstractGenerator implements BiFunction<ISymbol, EK9Parser.AssignmentExpressionContext, List<IRInstr>>
  • Constructor Details

  • Method Details

    • apply

    • isEscapingResultExpression

      static boolean isEscapingResultExpression(EK9Parser.AssignmentExpressionContext ctx)
      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.