use of org.luaj.vm2.LuaValue in project LuaViewSDK by alibaba.
the class DebugLib method onCall.
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);
}
use of org.luaj.vm2.LuaValue in project LuaViewSDK by alibaba.
the class PackageLib method call.
public LuaValue call(LuaValue modname, LuaValue env) {
globals = env.checkglobals();
globals.set("require", new require());
package_ = new LuaTable();
package_.set(_LOADED, new LuaTable());
package_.set(_PRELOAD, new LuaTable());
package_.set(_PATH, LuaValue.valueOf(DEFAULT_LUA_PATH));
package_.set(_LOADLIB, new loadlib());
package_.set(_SEARCHPATH, new searchpath());
LuaTable searchers = new LuaTable();
searchers.set(1, preload_searcher = new preload_searcher());
searchers.set(2, lua_searcher = new lua_searcher());
searchers.set(3, java_searcher = new java_searcher());
package_.set(_SEARCHERS, searchers);
package_.get(_LOADED).set("package", package_);
env.set("package", package_);
globals.package_ = this;
return env;
}
use of org.luaj.vm2.LuaValue in project LuaViewSDK by alibaba.
the class IoLib method freadnumber.
public static LuaValue freadnumber(File f) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
freadchars(f, " \t\r\n", null);
freadchars(f, "-+", baos);
// freadchars(f,"0",baos);
// freadchars(f,"xX",baos);
freadchars(f, "0123456789", baos);
freadchars(f, ".", baos);
freadchars(f, "0123456789", baos);
// freadchars(f,"eEfFgG",baos);
// freadchars(f,"+-",baos);
// freadchars(f,"0123456789",baos);
String s = baos.toString();
return s.length() > 0 ? valueOf(Double.parseDouble(s)) : NIL;
}
use of org.luaj.vm2.LuaValue in project LuaViewSDK by alibaba.
the class MathLib method call.
public LuaValue call(LuaValue modname, LuaValue env) {
LuaTable math = new LuaTable(0, 30);
math.set("abs", new abs());
math.set("ceil", new ceil());
math.set("cos", new cos());
math.set("deg", new deg());
math.set("exp", new exp(this));
math.set("floor", new floor());
math.set("fmod", new fmod());
math.set("frexp", new frexp());
math.set("huge", LuaDouble.POSINF);
math.set("ldexp", new ldexp());
math.set("max", new max());
math.set("min", new min());
math.set("modf", new modf());
math.set("pi", Math.PI);
math.set("pow", new pow());
random r;
math.set("random", r = new random());
math.set("randomseed", new randomseed(r));
math.set("rad", new rad());
math.set("sin", new sin());
math.set("sqrt", new sqrt());
math.set("tan", new tan());
env.set("math", math);
env.get("package").get("loaded").set("math", math);
return math;
}
use of org.luaj.vm2.LuaValue in project LuaViewSDK by alibaba.
the class FuncState method addk.
int addk(LuaValue v) {
if (this.h == null) {
this.h = new Hashtable();
} else if (this.h.containsKey(v)) {
return ((Integer) h.get(v)).intValue();
}
final int idx = this.nk;
this.h.put(v, new Integer(idx));
final Prototype f = this.f;
if (f.k == null || nk + 1 >= f.k.length)
f.k = realloc(f.k, nk * 2 + 1);
f.k[this.nk++] = v;
return idx;
}
Aggregations