Search in sources :

Example 11 with LuaString

use of org.luaj.vm2.LuaString in project LuaViewSDK by alibaba.

the class LexState method anchor_token.

/*----------------------------------------------------------------------
	name		args	description
	------------------------------------------------------------------------*/
void anchor_token() {
    /* last token from outer function must be EOS */
    LuaC._assert(fs != null || t.token == TK_EOS);
    if (t.token == TK_NAME || t.token == TK_STRING) {
        LuaString ts = t.seminfo.ts;
        // TODO: is this necessary?
        L.cachedLuaString(t.seminfo.ts);
    }
}
Also used : LuaString(org.luaj.vm2.LuaString)

Example 12 with LuaString

use of org.luaj.vm2.LuaString in project LuaViewSDK by alibaba.

the class LexState method closegoto.

void closegoto(int g, Labeldesc label) {
    FuncState fs = this.fs;
    Labeldesc[] gl = this.dyd.gt;
    Labeldesc gt = gl[g];
    LuaC._assert(gt.name.eq_b(label.name));
    if (gt.nactvar < label.nactvar) {
        LuaString vname = fs.getlocvar(gt.nactvar).varname;
        String msg = L.pushfstring("<goto " + gt.name + "> at line " + gt.line + " jumps into the scope of local '" + vname.tojstring() + "'");
        semerror(msg);
    }
    fs.patchlist(gt.pc, label.pc);
    /* remove goto from pending list */
    System.arraycopy(gl, g + 1, gl, g, this.dyd.n_gt - g - 1);
    gl[--this.dyd.n_gt] = null;
}
Also used : LuaString(org.luaj.vm2.LuaString) LuaString(org.luaj.vm2.LuaString)

Example 13 with LuaString

use of org.luaj.vm2.LuaString in project LuaViewSDK by alibaba.

the class LexState method registerlocalvar.

int registerlocalvar(LuaString varname) {
    FuncState fs = this.fs;
    Prototype f = fs.f;
    if (f.locvars == null || fs.nlocvars + 1 > f.locvars.length)
        f.locvars = LuaC.realloc(f.locvars, fs.nlocvars * 2 + 1);
    f.locvars[fs.nlocvars] = new LocVars(varname, 0, 0);
    return fs.nlocvars++;
}
Also used : Prototype(org.luaj.vm2.Prototype) LocVars(org.luaj.vm2.LocVars)

Example 14 with LuaString

use of org.luaj.vm2.LuaString in project LuaViewSDK by alibaba.

the class FuncState method checkrepeated.

// =============================================================
// from lparser.c
// =============================================================
/* check for repeated labels on the same block */
void checkrepeated(LexState.Labeldesc[] ll, int ll_n, LuaString label) {
    int i;
    for (i = bl.firstlabel; i < ll_n; i++) {
        if (label.eq_b(ll[i].name)) {
            String msg = ls.L.pushfstring("label '" + label + " already defined on line " + ll[i].line);
            ls.semerror(msg);
        }
    }
}
Also used : LuaString(org.luaj.vm2.LuaString)

Example 15 with LuaString

use of org.luaj.vm2.LuaString in project LuaViewSDK by alibaba.

the class FuncState method newupvalue.

int newupvalue(LuaString name, expdesc v) {
    checklimit(nups + 1, LUAI_MAXUPVAL, "upvalues");
    if (f.upvalues == null || nups + 1 > f.upvalues.length)
        f.upvalues = realloc(f.upvalues, nups > 0 ? nups * 2 : 1);
    f.upvalues[nups] = new Upvaldesc(name, v.k == LexState.VLOCAL, v.u.info);
    return nups++;
}
Also used : Upvaldesc(org.luaj.vm2.Upvaldesc)

Aggregations

LuaString (org.luaj.vm2.LuaString)25 LuaValue (org.luaj.vm2.LuaValue)5 Prototype (org.luaj.vm2.Prototype)3 Buffer (org.luaj.vm2.Buffer)2 LuaPrint (org.luaj.vm2.log.LuaPrint)2 LocVars (org.luaj.vm2.LocVars)1 Upvaldesc (org.luaj.vm2.Upvaldesc)1 BlockCnt (org.luaj.vm2.compiler.FuncState.BlockCnt)1