Class EfunRegistry

java.lang.Object
io.github.protasm.jvmud.compiler.efun.EfunRegistry

public final class EfunRegistry extends Object
Instance-scoped registry for LPC-facing engine functions.

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 exact arity. Multiple arities for the same name are valid and are how overloaded efuns are represented. Registering two implementations with the same name and arity 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 Details

    • EfunRegistry

      public EfunRegistry()
  • Method Details

    • register

      public void register(Efun efun)
      Registers an engine function implementation.
      Parameters:
      efun - implementation to add to this registry
      Throws:
      NullPointerException - if efun is null
    • lookup

      public Efun lookup(String name, int arity)
      Returns the matching function for name and arity.
      Parameters:
      name - LPC-facing function name
      arity - exact number of LPC arguments in the call
      Returns:
      matching efun, or null when none is registered
      Throws:
      IllegalStateException - if more than one implementation matches the same name and arity
    • signatures

      public List<EfunSignature> signatures(String name)
      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