Class InputVarietyDenominatorCalculator

java.lang.Object
org.ek9lang.compiler.support.inputvariety.InputVarietyDenominatorCalculator

public final class InputVarietyDenominatorCalculator extends Object
Computes a public construct's input-variation InputVarietyDenominator — the pairwise opportunity space of its parameters (design §4.1). Cheap: O(k²) over already-derived per-parameter varieties, cheaper than cyclomatic complexity.

This is the static, every-build half of the metric (§2 commitment 1) — the denominator is a construct-local property cached like COMPLEXITY. The dynamic numerator is a later stage.

Mirrors the Counter → Acceptable*OrError shape of the existing complexity metrics (§11.2): this is the counter; the phase-5 listener wiring + squirrel + optional gate come next.

  • Constructor Details

    • InputVarietyDenominatorCalculator

      public InputVarietyDenominatorCalculator()
    • InputVarietyDenominatorCalculator

      public InputVarietyDenominatorCalculator(EquivalenceClassModel equivalenceClassModel)
  • Method Details

    • forParameterTypes

      public InputVarietyDenominator forParameterTypes(List<ISymbol> parameterTypes)
      The denominator for a construct whose parameters have the given resolved type symbols, in declaration order. Each type is mapped to its variety via EquivalenceClassModel, then combined pairwise.
    • forInstanceMethod

      public InputVarietyDenominator forInstanceMethod(ISymbol receiverType, List<ISymbol> parameterTypes)
      The figures for an instance method / operator, treating the receiver type as an implicit parameter p0 (design §4.5): its leaf dimensions are prepended to the argument leaves, so a no-arg instance method (e.g. pop()) is scored against its receiver's states rather than being exempt. Constructors and functions have no receiver and use forParameterTypes(List). Both sides flatten via EquivalenceClassModel.leavesOf(ISymbol) so a record contributes leaves, never a product — this is what stops the receiver 81 × arg 81 compounding structurally.
    • pairwise

      public InputVarietyDenominator pairwise(List<TypeVariety> leafVarieties)
      The figures over a flattened list of leaf varieties. Pure — unit-testable without symbols. k == 0 → exempt. The floor is always Σ leaf class-counts (1-wise each-choice). The ceiling (pairwiseDenominator) is: k == 1 → the single leaf's class count; k >= 2 → Σ over leaf pairs (i<j) of classCount(li) × classCount(lj).