Class DispatchTableGenerator

java.lang.Object
org.ek9lang.compiler.phase7.DispatchTableGenerator

final class DispatchTableGenerator extends Object
Generates precomputed dispatch tables for dispatcher methods during Phase 7 IR generation.

For each dispatcher method, this generator:

  1. Gets the handler methods from OperationInstr.getDispatchImplementations()
  2. Finds concrete reachable types via ConcreteSubtypeFinder
  3. Computes assignment costs for each concrete type against each handler
  4. Picks the winning handler (lowest cost) for each concrete type
  5. Creates a DispatchTableInstr and prepends it to the method body

Phase 5 has already validated no ambiguity (no ties at equal cost), so the winning handler for each concrete type is guaranteed to be unique.

  • Constructor Details

  • Method Details

    • generateAndPrepend

      void generateAndPrepend(OperationInstr dispatcherOperation, AggregateSymbol aggregateSymbol)
      Generate dispatch table for a dispatcher operation and prepend to its body.