Class NotEqualsGenerator
java.lang.Object
org.ek9lang.compiler.phase7.synthesis.AbstractSyntheticGenerator
org.ek9lang.compiler.phase7.synthesis.NotEqualsGenerator
Generates synthetic IR for the _neq (<>) operator.
The not-equals operator is implemented by delegating to _eq and negating the result. This follows the principle that <> should always be the logical negation of ==.
The generated code follows this pattern:
Boolean _neq(T other): result = this._eq(other) // If eq returned unset, we return unset if !result._isSet() -> return unset // Negate the result: if eq was true, return false; if eq was false, return true if result._true() -> return false return true
Key semantic requirements:
- If _eq returns unset (either operand unset), return unset
- If _eq returns true (objects equal), return false
- If _eq returns false (objects not equal), return true
This approach ensures consistency: (a == b) and (a <> b) are always logical opposites, and both handle unset values identically.
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractSyntheticGenerator
AbstractSyntheticGenerator.ScopeSetup -
Field Summary
Fields inherited from class AbstractSyntheticGenerator
stackContext -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongenerate(MethodSymbol operatorSymbol, AggregateSymbol aggregateSymbol) Generate the _neq operator IR for the given aggregate.Methods inherited from class AbstractSyntheticGenerator
aggregateHasOperator, createDebugInfo, createSynthesisScope, generateAnyFieldSetGuard, generateBinaryOperatorGuards, generateBooleanBranch, generateBooleanReturnBlock, generateConstructorCall, generateConstructorCall, generateConstructorCall, generateConstructorCallWithArgs, generateFieldLoad, generateFieldLoad, generateFieldSetStatusCheck, generateIsSetGuard, generateIsSetGuard, generateLabelName, generateMethodCall, generateMethodCall, generateMethodCall, generateMethodCall, generateMethodCall, generateResultReturnBlock, generateResultReturnBlock, generateStringLiteralLoad, generateTempName, generateThisIsSetGuard, generateThisIsSetGuard, generateUnsetReturnBlock, generateUnsetReturnBlockWithLabel, generateUnsetReturnBlockWithLabel, getBitsTypeName, getBooleanTypeName, getIntegerTypeName, getReturnBlockHelper, getStringTypeName, getSuperTypeName, getSyntheticFields, getTypeName, getVoidTypeName, initializeScope, isAnyType, superHasOperator
-
Constructor Details
-
NotEqualsGenerator
NotEqualsGenerator(IRGenerationContext stackContext)
-
-
Method Details
-
generate
Generate the _neq operator IR for the given aggregate.- Parameters:
operatorSymbol- The _neq operator method symbolaggregateSymbol- The aggregate containing the operator- Returns:
- List of IR instructions implementing the operator
-