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);
}
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] */
}
}
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 */
}
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]);
}
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;
}
Aggregations