Record Class GuardVariableDetails
java.lang.Object
java.lang.Record
org.ek9lang.compiler.ir.data.GuardVariableDetails
public record GuardVariableDetails(List<String> guardVariables, List<IRInstr> guardScopeSetup, List<IRInstr> guardEntryCheck, String guardEntryCheckPrimitive, String guardEntryCheckResult, String guardScopeId, String conditionScopeId)
extends Record
Record containing guard variable management information for CONTROL_FLOW_CHAIN constructs.
Guard variables are used in EK9 control flow constructs like: - if/when with guards: "when var <- expr with condition" - switch with guards: "switch var := expr with var" - for loops with guards: "for var ?= expr then iterator" - while/do-while with guards: "while var <- expr then condition"
Provides SSA conversion hints to LLVM backend for proper phi node placement and scope management for guard variable lifetime.
For WHILE/DO-WHILE loops, the guard entry check is evaluated ONCE at loop entry. If the check fails, the entire loop is skipped. The condition is then evaluated on each iteration WITHOUT the guard check.
-
Constructor Summary
ConstructorsConstructorDescriptionGuardVariableDetails(List<String> guardVariables, List<IRInstr> guardScopeSetup, List<IRInstr> guardEntryCheck, String guardEntryCheckPrimitive, String guardEntryCheckResult, String guardScopeId, String conditionScopeId) Creates an instance of aGuardVariableDetailsrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theconditionScopeIdrecord component.static GuardVariableDetailscreate(List<String> guardVariables, List<IRInstr> guardScopeSetup, String guardScopeId, String conditionScopeId) Create guard variable details for IF/SWITCH (no entry check needed - evaluates with condition).static GuardVariableDetailscreateWithEntryCheck(List<String> guardVariables, List<IRInstr> guardScopeSetup, List<IRInstr> guardEntryCheck, String guardEntryCheckPrimitive, String guardEntryCheckResult, String guardScopeId) Create guard variable details for WHILE/DO-WHILE loops (with entry check).final booleanIndicates whether some other object is "equal to" this one.Returns the value of theguardEntryCheckrecord component.Returns the value of theguardEntryCheckPrimitiverecord component.Returns the value of theguardEntryCheckResultrecord component.Returns the value of theguardScopeIdrecord component.Returns the value of theguardScopeSetuprecord component.Returns the value of theguardVariablesrecord component.booleanCheck if this has a guard entry check (for WHILE/DO-WHILE loops).booleanCheck if this has a guard scope.booleanCheck if this has guard variables.final inthashCode()Returns a hash code value for this object.booleanCheck if this has a shared condition scope.booleanisEmpty()Check if this guard details object is empty (no guard features).static GuardVariableDetailsnone()Create empty guard variable details (no guards).toString()IR-optimized toString following EK9's bracket-only, no-indentation format.
-
Constructor Details
-
GuardVariableDetails
public GuardVariableDetails(List<String> guardVariables, List<IRInstr> guardScopeSetup, List<IRInstr> guardEntryCheck, String guardEntryCheckPrimitive, String guardEntryCheckResult, String guardScopeId, String conditionScopeId) Creates an instance of aGuardVariableDetailsrecord class.- Parameters:
guardVariables- the value for theguardVariablesrecord componentguardScopeSetup- the value for theguardScopeSetuprecord componentguardEntryCheck- the value for theguardEntryCheckrecord componentguardEntryCheckPrimitive- the value for theguardEntryCheckPrimitiverecord componentguardEntryCheckResult- the value for theguardEntryCheckResultrecord componentguardScopeId- the value for theguardScopeIdrecord componentconditionScopeId- the value for theconditionScopeIdrecord component
-
-
Method Details
-
none
Create empty guard variable details (no guards). -
create
-
createWithEntryCheck
public static GuardVariableDetails createWithEntryCheck(List<String> guardVariables, List<IRInstr> guardScopeSetup, List<IRInstr> guardEntryCheck, String guardEntryCheckPrimitive, String guardEntryCheckResult, String guardScopeId) Create guard variable details for WHILE/DO-WHILE loops (with entry check). The entry check is evaluated ONCE at loop entry. If it fails, the loop is skipped.- Parameters:
guardVariables- List of guard variable namesguardScopeSetup- Instructions to setup guard variablesguardEntryCheck- Instructions for guard check (IS_NULL + _isSet)guardEntryCheckPrimitive- Primitive boolean for branchingguardEntryCheckResult- EK9 Boolean result for condition_result in IF wrapperguardScopeId- Scope ID for guard variable lifetime
-
hasGuardVariables
public boolean hasGuardVariables()Check if this has guard variables. -
hasGuardScope
public boolean hasGuardScope()Check if this has a guard scope. -
hasGuardEntryCheck
public boolean hasGuardEntryCheck()Check if this has a guard entry check (for WHILE/DO-WHILE loops). -
isEmpty
public boolean isEmpty()Check if this guard details object is empty (no guard features). -
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
guardVariables
-
guardScopeSetup
-
guardEntryCheck
-
guardEntryCheckPrimitive
Returns the value of theguardEntryCheckPrimitiverecord component.- Returns:
- the value of the
guardEntryCheckPrimitiverecord component
-
guardEntryCheckResult
Returns the value of theguardEntryCheckResultrecord component.- Returns:
- the value of the
guardEntryCheckResultrecord component
-
guardScopeId
Returns the value of theguardScopeIdrecord component.- Returns:
- the value of the
guardScopeIdrecord component
-
conditionScopeId
Returns the value of theconditionScopeIdrecord component.- Returns:
- the value of the
conditionScopeIdrecord component
-