Class BooleanCondition
java.lang.Object
org.ek9lang.compiler.phase7.support.BooleanCondition
THE step from an evaluated condition to what a branch reads - use this, do not re-derive it.
A condition is a Boolean, or a type that promotes to one with #^ (front-end rationalisation D1, Steve
2026-10-02): every place a condition is read - if / else if, while, do/while,
a ternary, a guard's condition, require and assert. Phase 3 accepts the promotable type; this
inserts its _promote() call through THE value promotion (CollectionElementPromoter and
PromotionCallGenerator, never a new copy), then reads the primitive with _true(). Before it the
condition's own type reached Boolean._true() and the class failed verification at load (VerifyError).
A condition that is already a Boolean is untouched: no instruction and no temporary are added, so the IR of every existing Boolean condition is unchanged.
-
Constructor Summary
ConstructorsConstructorDescriptionBooleanCondition(IRGenerationContext stackContext, PromotionCallGenerator promotionCallGenerator, PrimitiveBooleanExtractor primitiveBooleanExtractor) -
Method Summary
Modifier and TypeMethodDescriptionasBoolean(EK9Parser.ExpressionContext condition, String conditionVariable, DebugInfo debugInfo, List<IRInstr> instructions) The Boolean holding the condition: the evaluated variable itself, or - for a type that promotes to Boolean - the result of its_promote(), appended toinstructions(scope-local, released with the scope).primitiveOf(String booleanVariable, DebugInfo debugInfo, List<IRInstr> instructions) The primitive boolean a branch reads from a variable already holding a Boolean (asBoolean(EK9Parser.ExpressionContext, String, DebugInfo, List)):_true(), appended toinstructions.toPrimitive(EK9Parser.ExpressionContext condition, String conditionVariable, DebugInfo debugInfo, List<IRInstr> instructions) The primitive boolean a branch reads: the condition as a Boolean (asBoolean(EK9Parser.ExpressionContext, String, DebugInfo, List)), then_true().
-
Constructor Details
-
BooleanCondition
public BooleanCondition(IRGenerationContext stackContext, PromotionCallGenerator promotionCallGenerator, PrimitiveBooleanExtractor primitiveBooleanExtractor)
-
-
Method Details
-
asBoolean
public String asBoolean(EK9Parser.ExpressionContext condition, String conditionVariable, DebugInfo debugInfo, List<IRInstr> instructions) The Boolean holding the condition: the evaluated variable itself, or - for a type that promotes to Boolean - the result of its_promote(), appended toinstructions(scope-local, released with the scope).- Parameters:
condition- the condition expression, whose resolved type decidesconditionVariable- the variable holding its evaluated valuedebugInfo- debug info for any promotioninstructions- where any promotion is appended- Returns:
- the variable holding the condition as a Boolean
-
toPrimitive
public String toPrimitive(EK9Parser.ExpressionContext condition, String conditionVariable, DebugInfo debugInfo, List<IRInstr> instructions) The primitive boolean a branch reads: the condition as a Boolean (asBoolean(EK9Parser.ExpressionContext, String, DebugInfo, List)), then_true().- Returns:
- the variable holding the primitive boolean
-
primitiveOf
The primitive boolean a branch reads from a variable already holding a Boolean (asBoolean(EK9Parser.ExpressionContext, String, DebugInfo, List)):_true(), appended toinstructions. The second half oftoPrimitive(EK9Parser.ExpressionContext, String, DebugInfo, List), for a site that puts something between the two (a condition that owns closeable temporaries closes them in between).- Returns:
- the variable holding the primitive boolean
-