use of org.luaj.vm2.Prototype in project LuaViewSDK by alibaba.
the class FuncState method code.
int code(int instruction, int line) {
Prototype f = this.f;
this.dischargejpc();
/* put new instruction in code array */
if (f.code == null || this.pc + 1 > f.code.length)
f.code = LuaC.realloc(f.code, this.pc * 2 + 1);
f.code[this.pc] = instruction;
/* save corresponding line information */
if (f.lineinfo == null || this.pc + 1 > f.lineinfo.length)
f.lineinfo = LuaC.realloc(f.lineinfo, this.pc * 2 + 1);
f.lineinfo[this.pc] = line;
return this.pc++;
}
use of org.luaj.vm2.Prototype in project LuaViewSDK by alibaba.
the class DumpState method dumpDebug.
void dumpDebug(final Prototype f) throws IOException {
int i, n;
if (strip)
dumpInt(0);
else
dumpString(f.source);
n = strip ? 0 : f.lineinfo.length;
dumpInt(n);
for (i = 0; i < n; i++) dumpInt(f.lineinfo[i]);
n = strip ? 0 : f.locvars.length;
dumpInt(n);
for (i = 0; i < n; i++) {
LocVars lvi = f.locvars[i];
dumpString(lvi.varname);
dumpInt(lvi.startpc);
dumpInt(lvi.endpc);
}
n = strip ? 0 : f.upvalues.length;
dumpInt(n);
for (i = 0; i < n; i++) dumpString(f.upvalues[i].name);
}
use of org.luaj.vm2.Prototype in project LuaViewSDK by alibaba.
the class LuaPrint method buildHeader.
void buildHeader(Prototype f) {
String s = String.valueOf(f.source);
if (s.startsWith("@") || s.startsWith("="))
s = s.substring(1);
else if ("\033Lua".equals(s))
s = "(bstring)";
else
s = "(string)";
String a = (f.linedefined == 0) ? "main" : "function";
ps.append("\n%" + a + " <" + s + ":" + f.linedefined + "," + f.lastlinedefined + "> (" + f.code.length + " instructions, " + f.code.length * 4 + " bytes at " + id(f) + ")\n");
ps.append(f.numparams + " param, " + f.maxstacksize + " slot, " + f.upvalues.length + " upvalue, ");
ps.append(f.locvars.length + " local, " + f.k.length + " constant, " + f.p.length + " function\n");
}
Aggregations