本文整理汇总了Java中org.luaj.vm2.LuaClosure类的典型用法代码示例。如果您正苦于以下问题:Java LuaClosure类的具体用法?Java LuaClosure怎么用?Java LuaClosure使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LuaClosure类属于org.luaj.vm2包,在下文中一共展示了LuaClosure类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onDestroyClosure
import org.luaj.vm2.LuaClosure; //导入依赖的package包/类
public static void onDestroyClosure(LuaClosure closure) {
if (closure != null) {
if (closure.upValues != null) {
UpValue upValue = null;
for (int i = 0; i < closure.upValues.length; i++) {
upValue = closure.upValues[i];
// if (upValue != null && upValue.array != null) {
// for (LuaValue value : upValue.array) {//destroy upvalues
// if (value instanceof BaseUserdata) {//userdata destory
// ((BaseUserdata) value).onDestroy();
// } else if (value instanceof LuaTable) {//destroy table
// onDestroyTable((LuaTable) value);
// }
// }
// }
closure.upValues[i] = null;
}
closure.upValues = null;
}
}
}
示例2: _setupvalue
import org.luaj.vm2.LuaClosure; //导入依赖的package包/类
static LuaValue _setupvalue(Varargs args)
{
LuaValue func = args.checkfunction(1);
int up = args.checkint(2);
LuaValue value = args.arg(3);
if(func instanceof LuaClosure)
{
LuaClosure c = (LuaClosure)func;
LuaString name = findupvalue(c, up);
if(name != null)
{
c._upValues[up - 1].setValue(value);
return name;
}
}
return NIL;
}
示例3: invoke
import org.luaj.vm2.LuaClosure; //导入依赖的package包/类
public Varargs invoke(Varargs args) {
LuaValue func = args.checkfunction(1);
int up = args.checkint(2);
if (func instanceof LuaClosure) {
LuaClosure c = (LuaClosure) func;
LuaString name = findupvalue(c, up);
if (name != null) {
return varargsOf(name, c.upValues[up - 1].getValue());
}
}
return NIL;
}
示例4: onCall
import org.luaj.vm2.LuaClosure; //导入依赖的package包/类
public void onCall(LuaClosure c, Varargs varargs, LuaValue[] stack) {
LuaThread t = globals.running;
callstack().onCall(c, varargs, stack);
if (t.inhook) return;
if (t.hookcall && t.hookfunc != null)
callHook(CALL, NIL);
}
示例5: findupvalue
import org.luaj.vm2.LuaClosure; //导入依赖的package包/类
static LuaString findupvalue(LuaClosure c, int up) {
if (c.upValues != null && up > 0 && up <= c.upValues.length) {
if (c.p.upvalues != null && up <= c.p.upvalues.length)
return c.p.upvalues[up - 1].name;
else
return LuaString.valueOf("." + up);
}
return null;
}
示例6: dump
import org.luaj.vm2.LuaClosure; //导入依赖的package包/类
/**
* string.dump (function)
*
* Returns a string containing a binary representation of the given function,
* so that a later loadstring on this string returns a copy of the function.
* function must be a Lua function without upvalues.
*
* TODO: port dumping code as optional add-on
*/
static LuaValue dump(LuaValue arg) {
LuaValue f = arg.checkfunction();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
DumpState.dump(((LuaClosure) f).p, baos, true);
return LuaString.valueOf(baos.toByteArray());
} catch (IOException e) {
return error(e.getMessage());
}
}
示例7: invoke
import org.luaj.vm2.LuaClosure; //导入依赖的package包/类
public Varargs invoke(Varargs args) {
LuaValue func = args.checkfunction(1);
int up = args.checkint(2);
if ( func instanceof LuaClosure ) {
LuaClosure c = (LuaClosure) func;
LuaString name = findupvalue(c, up);
if ( name != null ) {
return varargsOf(name, c.upValues[up-1].getValue() );
}
}
return NIL;
}
示例8: findupvalue
import org.luaj.vm2.LuaClosure; //导入依赖的package包/类
static LuaString findupvalue(LuaClosure c, int up) {
if ( c.upValues != null && up > 0 && up <= c.upValues.length ) {
if ( c.p.upvalues != null && up <= c.p.upvalues.length )
return c.p.upvalues[up-1].name;
else
return LuaString.valueOf( "."+up );
}
return null;
}
示例9: call
import org.luaj.vm2.LuaClosure; //导入依赖的package包/类
public LuaValue call(LuaValue arg) {
LuaValue f = arg.checkfunction();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
DumpState.dump( ((LuaClosure)f).p, baos, true );
return LuaString.valueUsing(baos.toByteArray());
} catch (IOException e) {
return error( e.getMessage() );
}
}
示例10: onCall
import org.luaj.vm2.LuaClosure; //导入依赖的package包/类
public void onCall(LuaClosure c, Varargs varargs, LuaValue[] stack) {
LuaThread t = globals.running;
if (t.inhook) return;
callstack().onCall(c, varargs, stack);
if (t.hookcall && t.hookfunc != null)
callHook(CALL, NIL);
}
示例11: dump
import org.luaj.vm2.LuaClosure; //导入依赖的package包/类
/**
* string.dump (function)
*
* Returns a string containing a binary representation of the given function,
* so that a later loadstring on this string returns a copy of the function.
* function must be a Lua function without upvalues.
*
* TODO: port dumping code as optional add-on
*/
static LuaValue dump( LuaValue arg ) {
LuaValue f = arg.checkfunction();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
DumpState.dump( ((LuaClosure)f).p, baos, true );
return LuaString.valueOf(baos.toByteArray());
} catch (IOException e) {
return error( e.getMessage() );
}
}
示例12: _executeImpl
import org.luaj.vm2.LuaClosure; //导入依赖的package包/类
@Override
public boolean _executeImpl(Processor processor) {
EnvironmentProcessor target = (EnvironmentProcessor)processor;
LuaValue[] args;
if (_args != null) {
args = new LuaValue[] { LuaValue.userdataOf(this), LuaValue.valueOf(_function), _args };
} else {
args = new LuaValue[] { LuaValue.userdataOf(this), LuaValue.valueOf(_function) };
}
LuaClosure f = new LuaClosure(_prototype, target.getGlobals());
f.invoke(LuaTable.listOf(args));
return true;
}
示例13: dump
import org.luaj.vm2.LuaClosure; //导入依赖的package包/类
/**
* string.dump (function)
*
* Returns a string containing a binary representation of the given function,
* so that a later loadstring on this string returns a copy of the function.
* function must be a Lua function without upvalues.
*
* TODO: port dumping code as optional add-on
*/
static LuaValue dump(LuaValue arg)
{
LuaValue f = arg.checkfunction();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try
{
DumpState.dump(((LuaClosure)f)._p, baos, true);
return LuaString.valueOf(baos.toByteArray());
}
catch(IOException e)
{
return error(e.getMessage());
}
}
示例14: findupvalue
import org.luaj.vm2.LuaClosure; //导入依赖的package包/类
static LuaString findupvalue(LuaClosure c, int up)
{
if(c._upValues != null && up > 0 && up <= c._upValues.length)
{
if(c._p.upvalues != null && up <= c._p.upvalues.length)
return c._p.upvalues[up - 1];
return LuaString.valueOf("." + up);
}
return null;
}
示例15: _getupvalue
import org.luaj.vm2.LuaClosure; //导入依赖的package包/类
static Varargs _getupvalue(Varargs args)
{
LuaValue func = args.checkfunction(1);
int up = args.checkint(2);
if(func instanceof LuaClosure)
{
LuaClosure c = (LuaClosure)func;
LuaString name = findupvalue(c, up);
if(name != null)
{
return varargsOf(name, c._upValues[up - 1].getValue());
}
}
return NIL;
}