Class DynamicFunctionDfnGenerator

java.lang.Object
org.ek9lang.compiler.phase7.AbstractDfnGenerator
org.ek9lang.compiler.phase7.DynamicFunctionDfnGenerator
All Implemented Interfaces:
BiFunction<FunctionSymbol, EK9Parser.DynamicFunctionDeclarationContext, IRConstruct>

public final class DynamicFunctionDfnGenerator extends AbstractDfnGenerator implements BiFunction<FunctionSymbol, EK9Parser.DynamicFunctionDeclarationContext, IRConstruct>
Creates the appropriate IR Construct for a dynamic function (anonymous closure). Dynamic functions capture variables from their enclosing scope and extend an abstract function.

Unlike named functions (handled by FunctionDfnGenerator), dynamic functions:

  • Have a constructor that accepts captured variables as parameters
  • Store captured variables into private fields via i_init
  • Get their _call method parameters from the super function signature
  • Are instantiated at the call site (not singletons)

The captured variables are already resolved by Phase 1 (DefinitionListener) into a CaptureScope on the FunctionSymbol. FieldsFromCapture converts these into IR field declarations.