Class SamenessOverrideGenerator

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

final class SamenessOverrideGenerator extends AbstractSyntheticGenerator
Generates the body of an override of an inherited ==(Super) or <=>(Super) on a type with its own sameness (D24 rule 3, Sameness.overriddenSignatures(IAggregateSymbol, ISymbol), Contract 22): the OBJECT decides which comparison runs, never the reference (N07).
  _isOwner = INSTANCEOF other, Owner [SUBTYPE]
  BRANCH_FALSE _isOwner, different_type
  _narrowed = CAST other -> Owner ; RETAIN ; SCOPE_REGISTER
  _result = CALL (Owner)this._eq|_cmp(_narrowed) ; SCOPE_REGISTER
  STORE rtn, _result ; RETAIN rtn ; BRANCH return_result
  different_type: rtn = false ('==') or unset ('<=>'); return
The narrowed value takes the RETAIN and SCOPE_REGISTER of the polymorphic copy's narrowing (Contract 20), the result and return blocks those of every generated comparison - the override needs no ARC of its own beyond them.
  • Constructor Details

  • Method Details

    • isOverride

      static boolean isOverride(MethodSymbol operatorSymbol, AggregateSymbol aggregateSymbol)
      Is this synthetic == or <=> one of the detached overrides - does it take a type other than its owner? A generated sameness always takes exactly its owner.
    • generate

      List<IRInstr> generate(MethodSymbol operatorSymbol, AggregateSymbol aggregateSymbol)