Class OperatorMap

java.lang.Object
org.ek9lang.compiler.common.OperatorMap

public class OperatorMap extends Object
Enhanced mapping of EK9 operators to their metadata and method names. Provides bidirectional mapping with comprehensive operator details including purity, argument requirements, return value information, and side effect classification.

Side effect types:
- RETURN_MUTATION: Operations that return non-Void values
- THIS_MUTATION: Operations that mutate the object itself (assignment/mutator operators)
- POSSIBLE_MUTATION: Non-pure operations that may have indirect effects or mutations
- NO_MUTATION: Implied when no mutation side effects are present (empty set)

  • Constructor Details

    • OperatorMap

      public OperatorMap()
  • Method Details

    • getOperatorDetails

      public OperatorDetails getOperatorDetails(String ek9Operator)
      Get operator details by EK9 operator symbol.
    • getOperatorDetailsByMethod

      public OperatorDetails getOperatorDetailsByMethod(String methodName)
      Get operator details by method name.
    • hasOperator

      public boolean hasOperator(String ek9Operator)
      Check if an EK9 operator exists.
    • hasMethod

      public boolean hasMethod(String methodName)
      Check if a method name maps to an operator.
    • getForward

      public String getForward(String ek9Operator)
      Get method name for EK9 operator (backward compatibility).
    • getBackward

      public String getBackward(String methodName)
      Get EK9 operator for method name (backward compatibility).
    • checkForward

      public boolean checkForward(String ek9Operator)
      Check if EK9 operator exists (backward compatibility).
    • checkBackward

      public boolean checkBackward(String methodName)
      Check if method name maps to operator (backward compatibility).
    • expectsParameter

      public boolean expectsParameter(String ek9Operator)
      For operators that require a single parameter. Updated to use OperatorDetails metadata.
    • expectsZeroParameters

      public boolean expectsZeroParameters(String ek9Operator)
      Used on a class/record not expecting any parameters at all. Updated to use OperatorDetails metadata.
    • isPureOperator

      public boolean isPureOperator(String ek9Operator)
      Check if an operator is marked as pure.
    • hasReturn

      public boolean hasReturn(String ek9Operator)
      Check if an operator has a return value (not Void).
    • getSideEffects

      public Set<String> getSideEffects(String ek9Operator)
      Get the side effects for an EK9 operator. Centralizes all side effect determination logic based on operator characteristics.
    • getSideEffectsByMethod

      public Set<String> getSideEffectsByMethod(String methodName)
      Get the side effects for a method name (backward lookup). Convenience method for when you have the method name instead of the EK9 operator.
    • getForwardKeys

      public Iterable<String> getForwardKeys()
      Get all EK9 operator symbols (for testing).
    • getBackwardKeys

      public Iterable<String> getBackwardKeys()
      Get all method names (for testing).