Class DirectionCheckBuilder
java.lang.Object
org.ek9lang.compiler.phase7.support.DirectionCheckBuilder
- All Implemented Interfaces:
Function<DirectionCheckParams, ConditionEvaluationResult>
public final class DirectionCheckBuilder
extends Object
implements Function<DirectionCheckParams, ConditionEvaluationResult>
CONCERN: Direction check evaluation for polymorphic for-range loops.
RESPONSIBILITY: Build direction check IR (direction < 0 or direction > 0).
REUSABILITY: FOR_RANGE_POLYMORPHIC ascending/descending case generation.
Domain-specific helper that eliminates the symmetric duplication between: - generateDirectionLessThanZero (direction < 0) - generateDirectionGreaterThanZero (direction > 0)
The only difference between these methods was the comparison operator ("<" vs ">"). This helper makes that difference explicit via DirectionCheckParams.
Pattern: 1. Load literal 0 2. Call direction < 0 (or > 0) 3. Extract primitive boolean result All wrapped in proper scope management and memory management.
-
Constructor Summary
ConstructorsConstructorDescriptionDirectionCheckBuilder(ScopedInstructionExecutor scopedInstructionExecutor, ManagedLiteralLoader managedLiteralLoader, ComparisonEvaluator comparisonEvaluator) -
Method Summary
Modifier and TypeMethodDescriptionapply(DirectionCheckParams params) Build direction check IR with scoped execution.
-
Constructor Details
-
DirectionCheckBuilder
public DirectionCheckBuilder(ScopedInstructionExecutor scopedInstructionExecutor, ManagedLiteralLoader managedLiteralLoader, ComparisonEvaluator comparisonEvaluator)
-
-
Method Details
-
apply
Build direction check IR with scoped execution.Handles: 1. Scope enter/exit for all temporary variables 2. Load literal 0 with memory management 3. Compare direction < 0 (or > 0) with memory management 4. Extract primitive boolean for branching
- Specified by:
applyin interfaceFunction<DirectionCheckParams, ConditionEvaluationResult>- Parameters:
params- Direction check parameters- Returns:
- Result containing instructions and primitive boolean variable name
-