Class RuntimeFunctionLiteral
java.lang.Object
io.github.protasm.jvmud.compiler.runtime.RuntimeFunctionLiteral
- All Implemented Interfaces:
RuntimeCallable
Runtime representation for an LPC function literal.
The compiler can currently parse, type-check, and pass these values through normal LPC value paths. Executable values either call a generated inline-closure helper or invoke a named method on the object that created the reference.
-
Constructor Summary
ConstructorsConstructorDescriptionRuntimeFunctionLiteral(String signature) RuntimeFunctionLiteral(String signature, int arity) RuntimeFunctionLiteral(String signature, int arity, Object target, String methodName) RuntimeFunctionLiteral(String signature, int arity, Object target, String methodName, Object[] captures) Creates an executable inline callable bound to a generated helper method and captured local values from the lexical point where the LPC closure literal was evaluated.RuntimeFunctionLiteral(String signature, int arity, Object target, String methodName, Object[] captures, Class<?> helperOwner) Creates an executable inline callable whose helper lives on a specific generated class. -
Method Summary
Modifier and TypeMethodDescriptionintarity()call(RuntimeContext runtime, Object... args) Invokes the callable in an LPC runtime context.booleanstatic RuntimeFunctionLiteralnamedFunction(String methodName, Object target) Creates a callable for a quoted LPC function symbol such as#'helper.toString()
-
Constructor Details
-
RuntimeFunctionLiteral
-
RuntimeFunctionLiteral
-
RuntimeFunctionLiteral
-
RuntimeFunctionLiteral
public RuntimeFunctionLiteral(String signature, int arity, Object target, String methodName, Object[] captures) Creates an executable inline callable bound to a generated helper method and captured local values from the lexical point where the LPC closure literal was evaluated.- Parameters:
signature- display signature for diagnosticsarity- number of LPC callback arguments expected by the closure bodytarget- generated object that owns the helper methodmethodName- generated helper method namecaptures- boxed outer-local values captured by the closure literal
-
RuntimeFunctionLiteral
public RuntimeFunctionLiteral(String signature, int arity, Object target, String methodName, Object[] captures, Class<?> helperOwner) Creates an executable inline callable whose helper lives on a specific generated class.Inherited LPC methods still run with
thisbound to the most-derived object. Binding the helper lookup to the class that emitted the method keeps synthetic helper names from colliding with helpers generated by descendants or flattened parents.- Parameters:
signature- display signature for diagnosticsarity- number of LPC callback arguments expected by the closure bodytarget- generated object that owns the runtime receivermethodName- generated helper method namecaptures- boxed outer-local values captured by the closure literalhelperOwner- generated class that declaredmethodName
-
-
Method Details
-
namedFunction
Creates a callable for a quoted LPC function symbol such as#'helper.The callable is bound to the generated object that produced it and accepts whatever arguments the consuming efun passes at runtime.
- Parameters:
methodName- LPC method name to invoketarget- generated object that owns the method- Returns:
- executable named-method callable
-
signature
-
arity
public int arity() -
executable
public boolean executable() -
call
Description copied from interface:RuntimeCallableInvokes the callable in an LPC runtime context.- Specified by:
callin interfaceRuntimeCallable- Parameters:
runtime- active runtime context for callbacks that need object/session stateargs- LPC callback arguments- Returns:
- callback result as a JVMud runtime value
-
toString
-