Class LuaClosure
- All Implemented Interfaces:
com.esotericsoftware.kryo.KryoSerializable
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class com.prineside.luaj.LuaValue
LuaValue.NillableSerializer, LuaValue.None
Nested classes/interfaces inherited from class com.prineside.luaj.Varargs
Varargs.ArrayVarargs
-
Field Summary
FieldsFields inherited from class com.prineside.luaj.LuaFunction
s_metatable
Fields inherited from class com.prineside.luaj.LuaValue
ADD, CALL, CONCAT, DIV, EMPTYSTRING, ENV, EQ, FALSE, INDEX, LE, LEN, LT, METATABLE, MINUSONE, MOD, MODE, MUL, NEWINDEX, NIL, NILLABLE_SERIALIZER, NILS, NONE, NOVALS, ONE, POW, SUB, TBOOLEAN, TFUNCTION, TINT, TLIGHTUSERDATA, TNIL, TNONE, TNUMBER, TOSTRING, TRUE, TSTRING, TTABLE, TTHREAD, TUSERDATA, TVALUE, TYPE_NAMES, UNM, ZERO
-
Constructor Summary
ConstructorsConstructorDescriptionLuaClosure
(Prototype p, LuaValue env) Create a closure around a Prototype with a specific environment. -
Method Summary
Modifier and TypeMethodDescriptionfinal LuaValue
call()
Callthis
with 0 arguments, including metatag processing, and return only the first return value.final LuaValue
Callthis
with 1 argument, including metatag processing, and return only the first return value.final LuaValue
Callthis
with 2 arguments, including metatag processing, and return only the first return value.final LuaValue
Callthis
with 3 arguments, including metatag processing, and return only the first return value.Check that the value is aLuaClosure
, or throwLuaError
if notvoid
void
initupvalue1
(LuaValue env) Hook for implementations such as LuaJC to load the environment of the main chunk into the first upvalue location.final Varargs
Should not return args (must be new varargs)boolean
Check ifthis
is afunction
that is a closure, meaning interprets lua bytecode for its executionname()
Return a human-readable name for this function.final Varargs
Callback used during tail call processing to invoke the function once.optclosure
(LuaClosure defval) Check that optional argument is a closure and return asLuaClosure
void
read
(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input) Convert to human readable String for any type.void
write
(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Output output) Methods inherited from class com.prineside.luaj.LuaFunction
checkfunction, classnamestub, getmetatable, isfunction, optfunction, strvalue, type, typename
Methods inherited from class com.prineside.luaj.LuaValue
add, add, add, and, arg, arg1, argerror, assert_, buffer, call, cBool, cDouble, cFloat, checkboolean, checkdouble, checkglobals, checkint, checkjstring, checklong, checknotnil, checknumber, checknumber, checkstring, checktable, checkthread, checkuserdata, checkuserdata, cInt, cNcDouble, cNcFloat, cNcInt, cObject, comparemt, concat, concat, concatmt, concatTo, concatTo, concatTo, cRegObject, cVarargs, cVarargs, cVarargs, cVarargs, cVarargs, cVarargs, cVarargs, cVarargs, div, div, div, divInto, eq, eq_b, eqmtcall, equals, error, get, get, get, gt, gt, gt, gt_b, gt_b, gt_b, gteq, gteq, gteq, gteq_b, gteq_b, gteq_b, inext, invoke, invoke, invoke, invokemethod, invokemethod, invokemethod, invokemethod, isboolean, isint, isinttype, islong, isnil, isnumber, isRegObject, isstring, istable, isthread, isuserdata, isuserdata, isvalidkey, len, length, listOf, listOf, load, lt, lt, lt, lt_b, lt_b, lt_b, lteq, lteq, lteq, lteq_b, lteq_b, lteq_b, markAsConst, metatag, method, method, method, method, method, method, mod, mod, mod, modFrom, mul, mul, mul, narg, neg, neq, neq_b, next, not, optboolean, optdouble, optint, optjstring, optlong, optnumber, optstring, opttable, optthread, optuserdata, optuserdata, optvalue, or, pow, pow, pow, powWith, powWith, presize, raweq, raweq, raweq, raweq, raweq, rawget, rawget, rawget, rawlen, rawset, rawset, rawset, rawset, rawset, rawset, rawset, rawsetlist, set, set, set, set, set, set, set, setmetatable, strcmp, strcmp, strongvalue, sub, sub, sub, subargs, subFrom, subFrom, tableOf, tableOf, tableOf, tableOf, tableOf, tableOf, tailcallOf, testfor_b, toboolean, tobyte, tochar, todouble, tofloat, toint, tolong, tonumber, toshort, tostring, toString, touserdata, touserdata, userdataOf, userdataOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf
Methods inherited from class com.prineside.luaj.Varargs
argcheck, checkboolean, checkclosure, checkdouble, checkfunction, checkint, checkjstring, checklong, checknotnil, checknumber, checkstring, checktable, checkthread, checkuserdata, checkuserdata, checkvalue, dealias, eval, isfunction, isnil, isnoneornil, isnumber, isstring, istable, isTailcall, isthread, isuserdata, isvalue, optboolean, optclosure, optdouble, optfunction, optint, optjstring, optlong, optnumber, optstring, opttable, optthread, optuserdata, optuserdata, optvalue, toboolean, tobyte, tochar, todouble, tofloat, toint, tojstring, tolong, toshort, touserdata, touserdata, type
-
Field Details
-
p
-
upValues
-
-
Constructor Details
-
LuaClosure
Create a closure around a Prototype with a specific environment. If the prototype has upvalues, the environment will be written into the first upvalue.- Parameters:
p
- the Prototype to construct this Closure for.env
- the environment to associate with the closure.
-
-
Method Details
-
write
public void write(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Output output) - Specified by:
write
in interfacecom.esotericsoftware.kryo.KryoSerializable
-
read
public void read(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input) - Specified by:
read
in interfacecom.esotericsoftware.kryo.KryoSerializable
-
initupvalue1
Description copied from class:LuaValue
Hook for implementations such as LuaJC to load the environment of the main chunk into the first upvalue location. If the function has no upvalues or is not a main chunk, calling this will be no effect.- Overrides:
initupvalue1
in classLuaValue
- Parameters:
env
- The environment to load into the first upvalue, if there is one.
-
isclosure
public boolean isclosure()Description copied from class:LuaValue
Check ifthis
is afunction
that is a closure, meaning interprets lua bytecode for its execution -
optclosure
Description copied from class:LuaValue
Check that optional argument is a closure and return asLuaClosure
A
LuaClosure
is aLuaFunction
that executes lua byteccode.- Overrides:
optclosure
in classLuaValue
- Parameters:
defval
-LuaClosure
to return ifthis
is nil or none- Returns:
this
cast toLuaClosure
if a function,defval
if nil or none, throwsLuaError
otherwise- See Also:
-
checkclosure
Description copied from class:LuaValue
Check that the value is aLuaClosure
, or throwLuaError
if notLuaClosure
is a subclass ofLuaFunction
that interprets lua bytecode.- Overrides:
checkclosure
in classLuaValue
- Returns:
this
cast asLuaClosure
- See Also:
-
tojstring
Description copied from class:LuaValue
Convert to human readable String for any type.- Overrides:
tojstring
in classLuaFunction
- Returns:
- String for use by human readers based on type.
- See Also:
-
freeStack
-
call
Description copied from class:LuaValue
Callthis
with 0 arguments, including metatag processing, and return only the first return value.If
this
is aLuaFunction
, call it, and return only its first return value, dropping any others. Otherwise, look for theLuaValue.CALL
metatag and call that.If the return value is a
Varargs
, only the 1st value will be returned. To get multiple values, useLuaValue.invoke()
instead.To call
this
as a method call, useLuaValue.method(LuaValue)
instead.- Overrides:
call
in classLuaValue
- Returns:
- First return value
(this())
, orLuaValue.NIL
if there were none. - See Also:
-
call
Description copied from class:LuaValue
Callthis
with 1 argument, including metatag processing, and return only the first return value.If
this
is aLuaFunction
, call it, and return only its first return value, dropping any others. Otherwise, look for theLuaValue.CALL
metatag and call that.If the return value is a
Varargs
, only the 1st value will be returned. To get multiple values, useLuaValue.invoke()
instead.To call
this
as a method call, useLuaValue.method(LuaValue)
instead.- Overrides:
call
in classLuaValue
- Parameters:
arg
- First argument to supply to the called function- Returns:
- First return value
(this(arg))
, orLuaValue.NIL
if there were none. - See Also:
-
call
Description copied from class:LuaValue
Callthis
with 2 arguments, including metatag processing, and return only the first return value.If
this
is aLuaFunction
, call it, and return only its first return value, dropping any others. Otherwise, look for theLuaValue.CALL
metatag and call that.If the return value is a
Varargs
, only the 1st value will be returned. To get multiple values, useLuaValue.invoke()
instead.To call
this
as a method call, useLuaValue.method(LuaValue)
instead.- Overrides:
call
in classLuaValue
- Parameters:
arg1
- First argument to supply to the called functionarg2
- Second argument to supply to the called function- Returns:
- First return value
(this(arg1,arg2))
, orLuaValue.NIL
if there were none. - See Also:
-
call
Description copied from class:LuaValue
Callthis
with 3 arguments, including metatag processing, and return only the first return value.If
this
is aLuaFunction
, call it, and return only its first return value, dropping any others. Otherwise, look for theLuaValue.CALL
metatag and call that.If the return value is a
Varargs
, only the 1st value will be returned. To get multiple values, useLuaValue.invoke()
instead.To call
this
as a method call, useLuaValue.method(LuaValue)
instead.- Overrides:
call
in classLuaValue
- Parameters:
arg1
- First argument to supply to the called functionarg2
- Second argument to supply to the called functionarg3
- Second argument to supply to the called function- Returns:
- First return value
(this(arg1,arg2,arg3))
, orLuaValue.NIL
if there were none. - See Also:
-
invoke
Description copied from class:LuaValue
Should not return args (must be new varargs) -
onInvoke
Description copied from class:LuaValue
Callback used during tail call processing to invoke the function once.This may return a
TailcallVarargs
to be evaluated by the client.This should not be called directly, instead use one of the call invocation functions.
-
name
Description copied from class:LuaFunction
Return a human-readable name for this function. Returns the last part of the class name by default. Is overridden by LuaClosure to return the source file and line, and by LibFunctions to return the name.- Overrides:
name
in classLuaFunction
- Returns:
- common name for this function.
-