Search in sources :

Example 16 with Prototype

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++;
}
Also used : Prototype(org.luaj.vm2.Prototype)

Example 17 with Prototype

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);
}
Also used : LocVars(org.luaj.vm2.LocVars)

Example 18 with Prototype

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");
}
Also used : LuaString(org.luaj.vm2.LuaString)

Aggregations

Prototype (org.luaj.vm2.Prototype)12 LuaString (org.luaj.vm2.LuaString)4 LuaPrint (org.luaj.vm2.log.LuaPrint)3 AerospikeException (com.aerospike.client.AerospikeException)2 BufferedInputStream (java.io.BufferedInputStream)2 FileInputStream (java.io.FileInputStream)2 InputStream (java.io.InputStream)2 LocVars (org.luaj.vm2.LocVars)2 LuaClosure (org.luaj.vm2.LuaClosure)2 LuaValue (org.luaj.vm2.LuaValue)2 File (java.io.File)1 Hashtable (java.util.Hashtable)1 LuaInteger (org.luaj.vm2.LuaInteger)1