Search in sources :

Example 21 with LuaString

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

the class IoLib method ioread.

private Varargs ioread(File f, Varargs args) throws IOException {
    int i, n = args.narg();
    LuaValue[] v = new LuaValue[n];
    LuaValue ai, vi;
    LuaString fmt;
    for (i = 0; i < n; ) {
        item: switch((ai = args.arg(i + 1)).type()) {
            case LuaValue.TNUMBER:
                vi = freadbytes(f, ai.toint());
                break item;
            case LuaValue.TSTRING:
                fmt = ai.checkstring();
                if (fmt.m_length == 2 && fmt.m_bytes[fmt.m_offset] == '*') {
                    switch(fmt.m_bytes[fmt.m_offset + 1]) {
                        case 'n':
                            vi = freadnumber(f);
                            break item;
                        case 'l':
                            vi = freadline(f);
                            break item;
                        case 'a':
                            vi = freadall(f);
                            break item;
                    }
                }
            default:
                return argerror(i + 1, "(invalid format)");
        }
        if ((v[i++] = vi).isnil())
            break;
    }
    return i == 0 ? NIL : varargsOf(v, 0, i);
}
Also used : LuaString(org.luaj.vm2.LuaString) LuaValue(org.luaj.vm2.LuaValue)

Example 22 with LuaString

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

the class LexState method singlevar.

void singlevar(expdesc var) {
    LuaString varname = this.str_checkname();
    FuncState fs = this.fs;
    if (FuncState.singlevaraux(fs, varname, var, 1) == VVOID) {
        /* global name? */
        expdesc key = new expdesc();
        FuncState.singlevaraux(fs, this.envn, var, 1);
        /* get environment variable */
        LuaC._assert(var.k == VLOCAL || var.k == VUPVAL);
        this.codestring(key, varname);
        /* key is variable name */
        fs.indexed(var, key);
    /* env[varname] */
    }
}
Also used : LuaString(org.luaj.vm2.LuaString)

Example 23 with LuaString

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

the class LexState method gotostat.

void gotostat(int pc) {
    int line = linenumber;
    LuaString label;
    int g;
    if (testnext(TK_GOTO))
        label = str_checkname();
    else {
        next();
        /* skip break */
        label = LuaString.valueOf("break");
    }
    g = newlabelentry(dyd.gt = LuaC.grow(dyd.gt, dyd.n_gt + 1), dyd.n_gt++, label, line, pc);
    findlabel(g);
/* close it if label already defined */
}
Also used : LuaString(org.luaj.vm2.LuaString)

Example 24 with LuaString

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

the class LexState method breaklabel.

/*
	** create a label named "break" to resolve break statements
	*/
void breaklabel() {
    LuaString n = LuaString.valueOf("break");
    int l = newlabelentry(dyd.label = LuaC.grow(dyd.label, dyd.n_label + 1), dyd.n_label++, n, 0, fs.pc);
    findgotos(dyd.label[l]);
}
Also used : LuaString(org.luaj.vm2.LuaString)

Example 25 with LuaString

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

the class LexState method str_checkname.

LuaString str_checkname() {
    LuaString ts;
    check(TK_NAME);
    ts = t.seminfo.ts;
    next();
    return ts;
}
Also used : LuaString(org.luaj.vm2.LuaString)

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