Class DispatchTableGenerator
java.lang.Object
org.ek9lang.compiler.phase7.DispatchTableGenerator
Generates precomputed dispatch tables for dispatcher methods during Phase 7 IR generation.
For each dispatcher method, this generator:
- Gets the handler methods from
OperationInstr.getDispatchImplementations() - Finds concrete reachable types via
ConcreteSubtypeFinder - Computes assignment costs for each concrete type against each handler
- Picks the winning handler (lowest cost) for each concrete type
- Creates a
DispatchTableInstrand 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 Summary
ConstructorsConstructorDescriptionDispatchTableGenerator(SharedThreadContext<CompilableProgram> compilableProgramAccess) -
Method Summary
Modifier and TypeMethodDescription(package private) voidgenerateAndPrepend(OperationInstr dispatcherOperation, AggregateSymbol aggregateSymbol) Generate dispatch table for a dispatcher operation and prepend to its body.
-
Constructor Details
-
Method Details
-
generateAndPrepend
Generate dispatch table for a dispatcher operation and prepend to its body.
-