Interface Efun


public interface Efun
Runtime implementation of one LPC-facing engine function.

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 Type
    Method
    Description
    default int
    Returns the number of LPC arguments this implementation accepts.
    call(RuntimeContext context, Object[] args)
    Executes the function body.
    default Object
    invoke(RuntimeContext context, Object[] args)
    Checks arity and invokes this function.
    Returns the function signature exposed to the compiler and runtime lookup tables.
    default Symbol
    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

      Object call(RuntimeContext context, Object[] args)
      Executes the function body.

      Callers should normally use invoke(RuntimeContext, Object[]) so arity checking stays consistent. Implementations may assume the argument array length matches arity().

      Parameters:
      context - active runtime context for the LPC execution
      args - evaluated LPC argument values
      Returns:
      LPC result value, or null for void efuns
    • symbol

      default Symbol 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

      default Object invoke(RuntimeContext context, Object[] args)
      Checks arity and invokes this function.

      A null argument 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 execution
      args - evaluated LPC argument values, or null for no arguments
      Returns:
      LPC result value, or null for void efuns
      Throws:
      IllegalArgumentException - if the supplied argument count differs from the signature