Class TailcallVarargs

java.lang.Object
com.prineside.luaj.Varargs
com.prineside.luaj.TailcallVarargs

public class TailcallVarargs extends Varargs
Subclass of Varargs that represents a lua tail call in a Java library function execution environment.

Since Java doesn't have direct support for tail calls, any lua function whose Prototype contains the Lua.OP_TAILCALL bytecode needs a mechanism for tail calls when converting lua-bytecode to java-bytecode.

The tail call holds the next function and arguments, and the client a call to eval() executes the function repeatedly until the tail calls are completed.

Normally, users of luaj need not concern themselves with the details of this mechanism, as it is built into the core execution framework.

See Also:
  • Constructor Details

  • Method Details

    • isTailcall

      public boolean isTailcall()
      Description copied from class: Varargs
      Return true if this is a TailcallVarargs
      Overrides:
      isTailcall in class Varargs
      Returns:
      true if a tail call, false otherwise
    • eval

      public Varargs eval()
      Description copied from class: Varargs
      Evaluate any pending tail call and return result.
      Overrides:
      eval in class Varargs
      Returns:
      the evaluated tail call result
    • arg

      public LuaValue arg(int i)
      Description copied from class: Varargs
      Get the n-th argument value (1-based).
      Specified by:
      arg in class Varargs
      Parameters:
      i - the index of the argument to get, 1 is the first argument
      Returns:
      Value at position i, or LuaValue.NIL if there is none.
      See Also:
    • arg1

      public LuaValue arg1()
      Description copied from class: Varargs
      Get the first argument in the list.
      Specified by:
      arg1 in class Varargs
      Returns:
      LuaValue which is first in the list, or LuaValue.NIL if there are no values.
      See Also:
    • narg

      public int narg()
      Description copied from class: Varargs
      Get the number of arguments, or 0 if there are none.
      Specified by:
      narg in class Varargs
      Returns:
      number of arguments.
    • subargs

      public Varargs subargs(int start)
      Description copied from class: Varargs
      Create a Varargs instance containing arguments starting at index start
      Specified by:
      subargs in class Varargs
      Parameters:
      start - the index from which to include arguments, where 1 is the first argument.
      Returns:
      Varargs containing argument { start, start+1, ... , narg-start-1 }