Class EfunRegistry
The registry is owned by a runtime context rather than by global process state, so each hosted
mudlib/runtime can choose which efuns it exposes. Built-in JVMud efuns are registered from
CoreEfuns; embedders and tests may register additional implementations before compiled
LPC code executes.
Lookup is by function name and compatible arity. Exact fixed-arity signatures are preferred over varargs signatures. Registering two equally good implementations is allowed at insertion time but treated as a configuration error when that overload is looked up, which prevents the runtime from silently invoking the wrong function.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the matching function for name and arity.voidRegisters an engine function implementation.signatures(String name) Returns all registered signatures for a function name.
-
Constructor Details
-
EfunRegistry
public EfunRegistry()
-
-
Method Details
-
register
Registers an engine function implementation.- Parameters:
efun- implementation to add to this registry- Throws:
NullPointerException- ifefunisnull
-
lookup
Returns the matching function for name and arity.- Parameters:
name- LPC-facing function namearity- actual number of LPC arguments in the call- Returns:
- matching efun, or
nullwhen none is registered - Throws:
IllegalStateException- if more than one implementation is the best match for the arity
-
signatures
Returns all registered signatures for a function name.This is useful for diagnostics and compiler error messages that need to show the overloads available for an unresolved or incorrectly-called efun.
- Parameters:
name- LPC-facing function name- Returns:
- immutable list of signatures currently registered for
name
-