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.
-
Field Summary
Fields inherited from class AbstractDfnGenerator
generators, notImplicitSuper, operationDfnGenerator, stackContext, voidStr -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapply(FunctionSymbol functionSymbol, EK9Parser.DynamicFunctionDeclarationContext ctx) Methods inherited from class AbstractDfnGenerator
createDebugInfoCreator, createInitOperation, createInstanceInitOperation, getParsedModule, newPerConstructContext, newSyntheticInitOperation, processAsMethodOrOperator, processPropertiesForInstanceInit, processSyntheticConstructorMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BiFunction
andThen
-
Constructor Details
-
DynamicFunctionDfnGenerator
-
-
Method Details
-
apply
public IRConstruct apply(FunctionSymbol functionSymbol, EK9Parser.DynamicFunctionDeclarationContext ctx) - Specified by:
applyin interfaceBiFunction<FunctionSymbol, EK9Parser.DynamicFunctionDeclarationContext, IRConstruct>
-