org.luaj.vm2
Class TailcallVarargs

java.lang.Object
  extended by org.luaj.vm2.Varargs
      extended by org.luaj.vm2.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:
Prototype, LuaJC

Constructor Summary
TailcallVarargs(LuaValue object, LuaValue methodname, Varargs args)
           
TailcallVarargs(LuaValue f, Varargs args)
           
 
Method Summary
 LuaValue arg(int i)
          Get the n-th argument value (1-based).
 LuaValue arg1()
          Get the first argument in the list.
 Varargs eval()
          Evaluate any pending tail call and return result.
 boolean isTailcall()
          Return true if this is a TailcallVarargs
 int narg()
          Get the number of arguments, or 0 if there are none.
 
Methods inherited from class org.luaj.vm2.Varargs
argcheck, checkboolean, checkclosure, checkdouble, checkfunction, checkint, checkinteger, checkjstring, checklong, checknotnil, checknumber, checkstring, checktable, checkthread, checkuserdata, checkuserdata, checkvalue, isfunction, isnil, isnoneornil, isnumber, isstring, istable, isthread, isuserdata, isvalue, optboolean, optclosure, optdouble, optfunction, optint, optinteger, optjstring, optlong, optnumber, optstring, opttable, optthread, optuserdata, optuserdata, optvalue, subargs, toboolean, tobyte, tochar, todouble, tofloat, toint, tojstring, tojstring, tolong, toshort, toString, touserdata, touserdata, type
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TailcallVarargs

public TailcallVarargs(LuaValue f,
                       Varargs args)

TailcallVarargs

public TailcallVarargs(LuaValue object,
                       LuaValue methodname,
                       Varargs args)
Method Detail

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:
Varargs.arg1(), LuaValue.NIL

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:
Varargs.arg(int), LuaValue.NIL

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.


Copyright © 2007-2008 Luaj.org. All Rights Reserved.