Interface Efun
An efun is a small Java adapter behind an LPC-callable function name. The compiler sees its
EfunSignature; generated bytecode resolves that signature by name and arity through a
RuntimeContext; and the implementation receives already-evaluated LPC argument values as
ordinary Java objects.
Efuns should keep their surface area engine-facing and stable. Mudlib compatibility layers may expose traditional driver names, but those names should delegate into these implementations rather than redefine engine concepts. The runtime context supplies the execution state an efun normally needs: current object, previous object, command Persona, output/session sinks, object loading, containment, scheduling, persistence, and host integration.
Implementations are looked up by exact arity. If an efun supports several argument counts,
register one Efun instance per supported arity.
-
Method Summary
Modifier and TypeMethodDescriptiondefault intarity()Returns the number of LPC arguments this implementation accepts.call(RuntimeContext context, Object[] args) Executes the function body.default Objectinvoke(RuntimeContext context, Object[] args) Checks arity and invokes this function.Returns the function signature exposed to the compiler and runtime lookup tables.default Symbolsymbol()Returns the compiler symbol associated with this function.
-
Method Details
-
signature
EfunSignature signature()Returns the function signature exposed to the compiler and runtime lookup tables.The signature's symbol contains both the LPC-facing name and the return type. Its parameter list is used for compile-time checking and runtime arity lookup.
- Returns:
- LPC-facing function signature
-
call
Executes the function body.Callers should normally use
invoke(RuntimeContext, Object[])so arity checking stays consistent. Implementations may assume the argument array length matchesarity().- Parameters:
context- active runtime context for the LPC executionargs- evaluated LPC argument values- Returns:
- LPC result value, or
nullfor void efuns
-
symbol
Returns the compiler symbol associated with this function.- Returns:
- signature symbol containing the LPC name and return type
-
arity
default int arity()Returns the number of LPC arguments this implementation accepts.- Returns:
- exact arity used for registry lookup and invocation checks
-
invoke
Checks arity and invokes this function.A
nullargument array is treated as zero arguments. Argument values are not coerced here; semantic analysis and generated bytecode are responsible for type-compatible calls before the efun is invoked.- Parameters:
context- active runtime context for the LPC executionargs- evaluated LPC argument values, ornullfor no arguments- Returns:
- LPC result value, or
nullfor void efuns - Throws:
IllegalArgumentException- if the supplied argument count differs from the signature
-