Class OperationFactory

java.lang.Object
org.ek9lang.compiler.support.CommonFactory
org.ek9lang.compiler.support.OperationFactory

class OperationFactory extends CommonFactory
  • Constructor Details

    • OperationFactory

      OperationFactory(ParsedModule parsedModule)
  • Method Details

    • newOperator

      Create a new aggregate that represents an EK9 operator, uses a method for this.
    • addMissingDefaultOperators

      public boolean addMissingDefaultOperators(EK9Parser.DefaultOperatorContext ctx, IAggregateSymbol aggregate)
      A bit of a beast this method. Check if operator is not present if so add one in. But as it is used in very early phase of compilation not all types will be known. So here this method just uses the raw name of the method.
    • completeBareDefaultOperators

      public void completeBareDefaultOperators(EK9Parser.DefaultOperatorContext ctx, IAggregateSymbol aggregate)
      Completes a bare 'default operator' once types are known - THE second half of addMissingDefaultOperators(EK9Parser.DefaultOperatorContext, IAggregateSymbol). Phase 1 can only compare names, so an operator of the same NAME but taking a different argument (a Point's ==(Integer)) hid the default ==(Point): 'first == second' did not compile, and a defaulted <> relying on it crashed code generation (front-end audit FE74, F2).

      Here each default the type still lacks is generated when none of the type's OWN operators of that name accepts the default's arguments - exactly phase 1's rule, by signature instead of by name. An operator of the type itself that already accepts it (a user's ==(Any)) is never taken over, and inherited operators are ignored, as in phase 1 - so the result does not depend on the order types are processed in. The test is DefaultOperatorCoverage, which the editors share.

    • completeSameness

      public void completeSameness(IAggregateSymbol aggregate, IToken bareToken)
      THE completion of a type's sameness once types are known (B18 - a type defines sameness once; Steve, 2026-09-30). Runs at the end of EXPLICIT_TYPE_SYMBOL_DEFINITION, supers and traits first, before any call is resolved, so a < b finds the generated operator.
      1. A bare default operator gives the type defaulted sameness - a <=>, retracted later if a field cannot be ordered, leaving field-wise == - unless the type already inherits sameness (it is sealed where it is declared) or the author declared their own.
      2. The comparisons are then ALWAYS generated from the sameness: from <=>, == <> < <= > >=; from == alone, <>; and #? with DEFAULTED sameness (hand-written sameness needs the author's #?, E07184). They are never written or requested (E07181), are marked GENERATED_FROM_SAMENESS, and carry DEFAULTED_BARE when the sameness itself is bare so they are retracted with it.
      Parameters:
      aggregate - the type to complete
      bareToken - the bare default operator of this type, if it has one
    • newMethod

      public MethodSymbol newMethod(EK9Parser.MethodDeclarationContext ctx, IScopedSymbol scopedSymbol)
      Create a new method that represents an EK9 class/component method.
    • newMethod

      public MethodSymbol newMethod(EK9Parser.MethodDeclarationContext ctx, String methodName, IScopedSymbol scopedSymbol)
      Create a new method with a specific name.
    • newType

      Create a new aggregate that represents an EK9 type, constrained or enumeration.
    • newAny

    • addMethodsToAny

      public void addMethodsToAny(AggregateSymbol anyTypeSymbol)
    • newOperationCall

      public CallSymbol newOperationCall(EK9Parser.OperationCallContext ctx, IScope scope)
      New call but modelled as an operator if marked as such.
    • newCaseExpressionCall

      public CallSymbol newCaseExpressionCall(EK9Parser.CaseExpressionContext ctx, IScope scope)
      New CallSymbol for switch case expression operator. Every case expression represents an implicit operator call on the switch variable. If no explicit operator is provided, we infer equality (==).
    • newOperatorCall

      public CallSymbol newOperatorCall(String operator, EK9Parser.ExpressionContext ctx, IScope scope)
      Create a CallSymbol for an operator in an expression. Same pattern as newCaseExpressionCall but for general binary/unary operators.