Search in sources :

Example 6 with BlockCnt

use of org.luaj.vm2.compiler.FuncState.BlockCnt in project LuaViewSDK by alibaba.

the class LexState method block.

void block() {
    /* block -> chunk */
    FuncState fs = this.fs;
    BlockCnt bl = new BlockCnt();
    fs.enterblock(bl, false);
    this.statlist();
    fs.leaveblock();
}
Also used : BlockCnt(org.luaj.vm2.compiler.FuncState.BlockCnt)

Example 7 with BlockCnt

use of org.luaj.vm2.compiler.FuncState.BlockCnt in project LuaViewSDK by alibaba.

the class LexState method mainfunc.

/*
	** compiles the main function, which is a regular vararg function with an
	** upvalue named LUA_ENV
	*/
public void mainfunc(FuncState funcstate) {
    BlockCnt bl = new BlockCnt();
    open_func(funcstate, bl);
    fs.f.is_vararg = 1;
    /* main function is always vararg */
    expdesc v = new expdesc();
    v.init(VLOCAL, 0);
    /* create and... */
    fs.newupvalue(envn, v);
    /* ...set environment upvalue */
    next();
    /* read first token */
    statlist();
    /* parse main body */
    check(TK_EOS);
    close_func();
}
Also used : BlockCnt(org.luaj.vm2.compiler.FuncState.BlockCnt)

Example 8 with BlockCnt

use of org.luaj.vm2.compiler.FuncState.BlockCnt in project LuaViewSDK by alibaba.

the class LexState method body.

void body(expdesc e, boolean needself, int line) {
    /* body -> `(' parlist `)' chunk END */
    FuncState new_fs = new FuncState();
    BlockCnt bl = new BlockCnt();
    new_fs.f = addprototype();
    new_fs.f.linedefined = line;
    open_func(new_fs, bl);
    this.checknext('(');
    if (needself) {
        new_localvarliteral("self");
        adjustlocalvars(1);
    }
    this.parlist();
    this.checknext(')');
    this.statlist();
    new_fs.f.lastlinedefined = this.linenumber;
    this.check_match(TK_END, TK_FUNCTION, line);
    this.codeclosure(e);
    this.close_func();
}
Also used : BlockCnt(org.luaj.vm2.compiler.FuncState.BlockCnt)

Example 9 with BlockCnt

use of org.luaj.vm2.compiler.FuncState.BlockCnt in project LuaViewSDK by alibaba.

the class LexState method findlabel.

/*
	 ** try to close a goto with existing labels; this solves backward jumps
	 */
boolean findlabel(int g) {
    int i;
    BlockCnt bl = fs.bl;
    Dyndata dyd = this.dyd;
    Labeldesc gt = dyd.gt[g];
    /* check labels in current block for a match */
    for (i = bl.firstlabel; i < dyd.n_label; i++) {
        Labeldesc lb = dyd.label[i];
        if (lb.name.eq_b(gt.name)) {
            /* correct label? */
            if (gt.nactvar > lb.nactvar && (bl.upval || dyd.n_label > bl.firstlabel))
                fs.patchclose(gt.pc, lb.nactvar);
            closegoto(g, lb);
            /* close it */
            return true;
        }
    }
    return false;
/* label not found; cannot close goto */
}
Also used : BlockCnt(org.luaj.vm2.compiler.FuncState.BlockCnt)

Aggregations

BlockCnt (org.luaj.vm2.compiler.FuncState.BlockCnt)9 LuaString (org.luaj.vm2.LuaString)1