Class NotEqualsGenerator

java.lang.Object
org.ek9lang.compiler.phase7.synthesis.AbstractSyntheticGenerator
org.ek9lang.compiler.phase7.synthesis.NotEqualsGenerator

final class NotEqualsGenerator extends AbstractSyntheticGenerator
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.

  • Constructor Details

  • Method Details

    • generate

      List<IRInstr> generate(MethodSymbol operatorSymbol, AggregateSymbol aggregateSymbol)
      Generate the _neq operator IR for the given aggregate.
      Parameters:
      operatorSymbol - The _neq operator method symbol
      aggregateSymbol - The aggregate containing the operator
      Returns:
      List of IR instructions implementing the operator