mirror of https://github.com/rusefi/lua.git
opcodes with builtin parameters are too complicated for very little extra
performance.
This commit is contained in:
parent
50248e440a
commit
1a17da2ff9
84
lopcodes.h
84
lopcodes.h
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lopcodes.h,v 1.17 1998/03/25 18:52:29 roberto Exp roberto $
|
** $Id: lopcodes.h,v 1.18 1998/06/25 14:37:00 roberto Exp roberto $
|
||||||
** Opcodes for Lua virtual machine
|
** Opcodes for Lua virtual machine
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -8,10 +8,11 @@
|
||||||
#define lopcodes_h
|
#define lopcodes_h
|
||||||
|
|
||||||
|
|
||||||
|
#define NUMOFFSET 100
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** NOTICE: variants of the same opcode must be consecutive: First, those
|
** NOTICE: variants of the same opcode must be consecutive: First, those
|
||||||
** with byte parameter, then with built-in parameters, and last with
|
** with byte parameter, then with word parameter.
|
||||||
** word parameter.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,98 +22,34 @@ typedef enum {
|
||||||
ENDCODE,/* - - - */
|
ENDCODE,/* - - - */
|
||||||
|
|
||||||
PUSHNIL,/* b - nil_0...nil_b */
|
PUSHNIL,/* b - nil_0...nil_b */
|
||||||
PUSHNIL0,/* - - nil */
|
|
||||||
|
|
||||||
PUSHNUMBER,/* b - (float)b */
|
PUSHNUMBER,/* b - (float)(b-NUMOFFSET) */
|
||||||
PUSHNUMBER0,/* - - 0.0 */
|
PUSHNUMBERW,/* w - (float)(w-NUMOFFSET) */
|
||||||
PUSHNUMBER1,/* - - 1.0 */
|
|
||||||
PUSHNUMBER2,/* - - 2.0 */
|
|
||||||
PUSHNUMBERW,/* w - (float)w */
|
|
||||||
|
|
||||||
PUSHCONSTANT,/* b - CNST[b] */
|
PUSHCONSTANT,/* b - CNST[b] */
|
||||||
PUSHCONSTANT0,/*- - CNST[0] */
|
|
||||||
PUSHCONSTANT1,/*- - CNST[1] */
|
|
||||||
PUSHCONSTANT2,/*- - CNST[2] */
|
|
||||||
PUSHCONSTANT3,/*- - CNST[3] */
|
|
||||||
PUSHCONSTANT4,/*- - CNST[4] */
|
|
||||||
PUSHCONSTANT5,/*- - CNST[5] */
|
|
||||||
PUSHCONSTANT6,/*- - CNST[6] */
|
|
||||||
PUSHCONSTANT7,/*- - CNST[7] */
|
|
||||||
PUSHCONSTANTW,/*w - CNST[w] */
|
PUSHCONSTANTW,/*w - CNST[w] */
|
||||||
|
|
||||||
PUSHUPVALUE,/* b - Closure[b] */
|
PUSHUPVALUE,/* b - Closure[b] */
|
||||||
PUSHUPVALUE0,/* - - Closure[0] */
|
|
||||||
PUSHUPVALUE1,/* - - Closure[1] */
|
|
||||||
|
|
||||||
PUSHLOCAL,/* b - LOC[b] */
|
PUSHLOCAL,/* b - LOC[b] */
|
||||||
PUSHLOCAL0,/* - - LOC[0] */
|
|
||||||
PUSHLOCAL1,/* - - LOC[1] */
|
|
||||||
PUSHLOCAL2,/* - - LOC[2] */
|
|
||||||
PUSHLOCAL3,/* - - LOC[3] */
|
|
||||||
PUSHLOCAL4,/* - - LOC[4] */
|
|
||||||
PUSHLOCAL5,/* - - LOC[5] */
|
|
||||||
PUSHLOCAL6,/* - - LOC[6] */
|
|
||||||
PUSHLOCAL7,/* - - LOC[7] */
|
|
||||||
|
|
||||||
GETGLOBAL,/* b - VAR[CNST[b]] */
|
GETGLOBAL,/* b - VAR[CNST[b]] */
|
||||||
GETGLOBAL0,/* - - VAR[CNST[0]] */
|
|
||||||
GETGLOBAL1,/* - - VAR[CNST[1]] */
|
|
||||||
GETGLOBAL2,/* - - VAR[CNST[2]] */
|
|
||||||
GETGLOBAL3,/* - - VAR[CNST[3]] */
|
|
||||||
GETGLOBAL4,/* - - VAR[CNST[4]] */
|
|
||||||
GETGLOBAL5,/* - - VAR[CNST[5]] */
|
|
||||||
GETGLOBAL6,/* - - VAR[CNST[6]] */
|
|
||||||
GETGLOBAL7,/* - - VAR[CNST[7]] */
|
|
||||||
GETGLOBALW,/* w - VAR[CNST[w]] */
|
GETGLOBALW,/* w - VAR[CNST[w]] */
|
||||||
|
|
||||||
GETTABLE,/* - i t t[i] */
|
GETTABLE,/* - i t t[i] */
|
||||||
|
|
||||||
GETDOTTED,/* b t t[CNST[b]] */
|
GETDOTTED,/* b t t[CNST[b]] */
|
||||||
GETDOTTED0,/* - t t[CNST[0]] */
|
|
||||||
GETDOTTED1,/* - t t[CNST[1]] */
|
|
||||||
GETDOTTED2,/* - t t[CNST[2]] */
|
|
||||||
GETDOTTED3,/* - t t[CNST[3]] */
|
|
||||||
GETDOTTED4,/* - t t[CNST[4]] */
|
|
||||||
GETDOTTED5,/* - t t[CNST[5]] */
|
|
||||||
GETDOTTED6,/* - t t[CNST[6]] */
|
|
||||||
GETDOTTED7,/* - t t[CNST[7]] */
|
|
||||||
GETDOTTEDW,/* w t t[CNST[w]] */
|
GETDOTTEDW,/* w t t[CNST[w]] */
|
||||||
|
|
||||||
PUSHSELF,/* b t t t[CNST[b]] */
|
PUSHSELF,/* b t t t[CNST[b]] */
|
||||||
PUSHSELF0,/* - t t t[CNST[0]] */
|
|
||||||
PUSHSELF1,/* - t t t[CNST[1]] */
|
|
||||||
PUSHSELF2,/* - t t t[CNST[2]] */
|
|
||||||
PUSHSELF3,/* - t t t[CNST[3]] */
|
|
||||||
PUSHSELF4,/* - t t t[CNST[4]] */
|
|
||||||
PUSHSELF5,/* - t t t[CNST[5]] */
|
|
||||||
PUSHSELF6,/* - t t t[CNST[6]] */
|
|
||||||
PUSHSELF7,/* - t t t[CNST[7]] */
|
|
||||||
PUSHSELFW,/* w t t t[CNST[w]] */
|
PUSHSELFW,/* w t t t[CNST[w]] */
|
||||||
|
|
||||||
CREATEARRAY,/* b - newarray(size = b) */
|
CREATEARRAY,/* b - newarray(size = b) */
|
||||||
CREATEARRAY0,/* - - newarray(size = 0) */
|
|
||||||
CREATEARRAY1,/* - - newarray(size = 1) */
|
|
||||||
CREATEARRAYW,/* w - newarray(size = w) */
|
CREATEARRAYW,/* w - newarray(size = w) */
|
||||||
|
|
||||||
SETLOCAL,/* b x - LOC[b]=x */
|
SETLOCAL,/* b x - LOC[b]=x */
|
||||||
SETLOCAL0,/* - x - LOC[0]=x */
|
|
||||||
SETLOCAL1,/* - x - LOC[1]=x */
|
|
||||||
SETLOCAL2,/* - x - LOC[2]=x */
|
|
||||||
SETLOCAL3,/* - x - LOC[3]=x */
|
|
||||||
SETLOCAL4,/* - x - LOC[4]=x */
|
|
||||||
SETLOCAL5,/* - x - LOC[5]=x */
|
|
||||||
SETLOCAL6,/* - x - LOC[6]=x */
|
|
||||||
SETLOCAL7,/* - x - LOC[7]=x */
|
|
||||||
|
|
||||||
SETGLOBAL,/* b x - VAR[CNST[b]]=x */
|
SETGLOBAL,/* b x - VAR[CNST[b]]=x */
|
||||||
SETGLOBAL0,/* - x - VAR[CNST[0]]=x */
|
|
||||||
SETGLOBAL1,/* - x - VAR[CNST[1]]=x */
|
|
||||||
SETGLOBAL2,/* - x - VAR[CNST[2]]=x */
|
|
||||||
SETGLOBAL3,/* - x - VAR[CNST[3]]=x */
|
|
||||||
SETGLOBAL4,/* - x - VAR[CNST[4]]=x */
|
|
||||||
SETGLOBAL5,/* - x - VAR[CNST[5]]=x */
|
|
||||||
SETGLOBAL6,/* - x - VAR[CNST[6]]=x */
|
|
||||||
SETGLOBAL7,/* - x - VAR[CNST[7]]=x */
|
|
||||||
SETGLOBALW,/* w x - VAR[CNST[w]]=x */
|
SETGLOBALW,/* w x - VAR[CNST[w]]=x */
|
||||||
|
|
||||||
SETTABLE0,/* - v i t - t[i]=v */
|
SETTABLE0,/* - v i t - t[i]=v */
|
||||||
|
@ -120,11 +57,9 @@ SETTABLE0,/* - v i t - t[i]=v */
|
||||||
SETTABLE,/* b v a_b...a_1 i t a_b...a_1 i t t[i]=v */
|
SETTABLE,/* b v a_b...a_1 i t a_b...a_1 i t t[i]=v */
|
||||||
|
|
||||||
SETLIST,/* b c v_c...v_1 t - t[i+b*FPF]=v_i */
|
SETLIST,/* b c v_c...v_1 t - t[i+b*FPF]=v_i */
|
||||||
SETLIST0,/* b v_b...v_1 t - t[i]=v_i */
|
|
||||||
SETLISTW,/* w c v_c...v_1 t - t[i+w*FPF]=v_i */
|
SETLISTW,/* w c v_c...v_1 t - t[i+w*FPF]=v_i */
|
||||||
|
|
||||||
SETMAP,/* b v_b k_b ...v_0 k_0 t t t[k_i]=v_i */
|
SETMAP,/* b v_b k_b ...v_0 k_0 t t t[k_i]=v_i */
|
||||||
SETMAP0,/* - v_0 k_0 t t t[k_0]=v_0 */
|
|
||||||
|
|
||||||
EQOP,/* - y x (x==y)? 1 : nil */
|
EQOP,/* - y x (x==y)? 1 : nil */
|
||||||
NEQOP,/* - y x (x~=y)? 1 : nil */
|
NEQOP,/* - y x (x~=y)? 1 : nil */
|
||||||
|
@ -155,20 +90,15 @@ IFFUPJMP,/* b x - (x==nil)? PC-=b */
|
||||||
IFFUPJMPW,/* w x - (x==nil)? PC-=w */
|
IFFUPJMPW,/* w x - (x==nil)? PC-=w */
|
||||||
|
|
||||||
CLOSURE,/* b c v_c...v_1 closure(CNST[b], v_c...v_1) */
|
CLOSURE,/* b c v_c...v_1 closure(CNST[b], v_c...v_1) */
|
||||||
CLOSUREW,/* w c v_b...v_1 closure(CNST[w], v_c...v_1) */
|
|
||||||
|
|
||||||
CALLFUNC,/* b c v_c...v_1 f r_b...r_1 f(v1,...,v_c) */
|
CALLFUNC,/* b c v_c...v_1 f r_b...r_1 f(v1,...,v_c) */
|
||||||
CALLFUNC0,/* b v_b...v_1 f - f(v1,...,v_b) */
|
|
||||||
CALLFUNC1,/* b v_b...v_1 f r_1 f(v1,...,v_b) */
|
|
||||||
|
|
||||||
RETCODE,/* b - - */
|
RETCODE,/* b - - */
|
||||||
|
|
||||||
SETLINE,/* b - - LINE=b */
|
SETLINE,/* b - - LINE=b */
|
||||||
SETLINEW,/* w - - LINE=w */
|
SETLINEW,/* w - - LINE=w */
|
||||||
|
|
||||||
POP,/* b - - TOP-=(b+1) */
|
POP /* b - - TOP-=(b+1) */
|
||||||
POP0,/* - - - TOP-=1 */
|
|
||||||
POP1/* - - - TOP-=2 */
|
|
||||||
|
|
||||||
} OpCode;
|
} OpCode;
|
||||||
|
|
||||||
|
|
86
lparser.c
86
lparser.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lparser.c,v 1.11 1999/02/01 18:52:05 roberto Exp roberto $
|
** $Id: lparser.c,v 1.12 1999/02/02 13:47:31 roberto Exp roberto $
|
||||||
** LL(1) Parser and code generator for Lua
|
** LL(1) Parser and code generator for Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -153,24 +153,19 @@ static void deltastack (LexState *ls, int delta) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int code_oparg_at (LexState *ls, int pc, OpCode op, int builtin,
|
static int code_oparg_at (LexState *ls, int pc, OpCode op, int arg, int delta) {
|
||||||
int arg, int delta) {
|
|
||||||
Byte *code = ls->fs->f->code;
|
Byte *code = ls->fs->f->code;
|
||||||
deltastack(ls, delta);
|
deltastack(ls, delta);
|
||||||
if (arg < builtin) {
|
if (arg <= 255) {
|
||||||
code[pc] = (Byte)(op+1+arg);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else if (arg <= 255) {
|
|
||||||
code[pc] = (Byte)op;
|
code[pc] = (Byte)op;
|
||||||
code[pc+1] = (Byte)arg;
|
code[pc+1] = (Byte)arg;
|
||||||
return 2;
|
return 2; /* code size (opcode + 1 byte) */
|
||||||
}
|
}
|
||||||
else if (arg <= MAX_WORD) {
|
else if (arg <= MAX_WORD) {
|
||||||
code[pc] = (Byte)(op+1+builtin);
|
code[pc] = (Byte)(op+1);
|
||||||
code[pc+1] = (Byte)(arg>>8);
|
code[pc+1] = (Byte)(arg>>8);
|
||||||
code[pc+2] = (Byte)(arg&0xFF);
|
code[pc+2] = (Byte)(arg&0xFF);
|
||||||
return 3;
|
return 3; /* code size (opcode + 1 word) */
|
||||||
}
|
}
|
||||||
else luaX_error(ls, "code too long " MES_LIM("64K")
|
else luaX_error(ls, "code too long " MES_LIM("64K")
|
||||||
" (try turning off debug mode)");
|
" (try turning off debug mode)");
|
||||||
|
@ -178,25 +173,21 @@ static int code_oparg_at (LexState *ls, int pc, OpCode op, int builtin,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int fix_opcode (LexState *ls, int pc, OpCode op, int builtin, int arg) {
|
static int fix_opcode (LexState *ls, int pc, OpCode op, int arg) {
|
||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
TProtoFunc *f = fs->f;
|
TProtoFunc *f = fs->f;
|
||||||
if (arg < builtin) { /* close space */
|
if (arg > 255) { /* open space */
|
||||||
luaO_memdown(f->code+pc+1, f->code+pc+2, fs->pc-(pc+2));
|
|
||||||
fs->pc--;
|
|
||||||
}
|
|
||||||
else if (arg > 255) { /* open space */
|
|
||||||
check_pc(fs, 1);
|
check_pc(fs, 1);
|
||||||
luaO_memup(f->code+pc+1, f->code+pc, fs->pc-pc);
|
luaO_memup(f->code+pc+1, f->code+pc, fs->pc-pc);
|
||||||
fs->pc++;
|
fs->pc++;
|
||||||
}
|
}
|
||||||
return code_oparg_at(ls, pc, op, builtin, arg, 0) - 2;
|
return code_oparg_at(ls, pc, op, arg, 0) - 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void code_oparg (LexState *ls, OpCode op, int builtin, int arg,
|
|
||||||
int delta) {
|
static void code_oparg (LexState *ls, OpCode op, int arg, int delta) {
|
||||||
check_pc(ls->fs, 3); /* maximum code size */
|
check_pc(ls->fs, 3); /* maximum code size */
|
||||||
ls->fs->pc += code_oparg_at(ls, ls->fs->pc, op, builtin, arg, delta);
|
ls->fs->pc += code_oparg_at(ls, ls->fs->pc, op, arg, delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -207,7 +198,7 @@ static void code_opcode (LexState *ls, OpCode op, int delta) {
|
||||||
|
|
||||||
|
|
||||||
static void code_constant (LexState *ls, int c) {
|
static void code_constant (LexState *ls, int c) {
|
||||||
code_oparg(ls, PUSHCONSTANT, 8, c, 1);
|
code_oparg(ls, PUSHCONSTANT, c, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -261,8 +252,9 @@ static int real_constant (FuncState *fs, real r) {
|
||||||
|
|
||||||
static void code_number (LexState *ls, real f) {
|
static void code_number (LexState *ls, real f) {
|
||||||
int i;
|
int i;
|
||||||
if (0 <= f && f <= (real)MAX_WORD && (real)(i=(int)f) == f)
|
if (0 <= f+NUMOFFSET && f+NUMOFFSET <= (real)MAX_WORD &&
|
||||||
code_oparg(ls, PUSHNUMBER, 3, i, 1); /* f has a short integer value */
|
(real)(i=(int)f) == f) /* f+NUMOFFSET has a short integer value? */
|
||||||
|
code_oparg(ls, PUSHNUMBER, i+NUMOFFSET, 1);
|
||||||
else
|
else
|
||||||
code_constant(ls, real_constant(ls->fs, f));
|
code_constant(ls, real_constant(ls->fs, f));
|
||||||
}
|
}
|
||||||
|
@ -270,13 +262,13 @@ static void code_number (LexState *ls, real f) {
|
||||||
|
|
||||||
static void flush_record (LexState *ls, int n) {
|
static void flush_record (LexState *ls, int n) {
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
code_oparg(ls, SETMAP, 1, n-1, -2*n);
|
code_oparg(ls, SETMAP, n-1, -2*n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void flush_list (LexState *ls, int m, int n) {
|
static void flush_list (LexState *ls, int m, int n) {
|
||||||
if (n == 0) return;
|
if (n == 0) return;
|
||||||
code_oparg(ls, SETLIST, 1, m, -n);
|
code_oparg(ls, SETLIST, m, -n);
|
||||||
code_byte(ls->fs, (Byte)n);
|
code_byte(ls->fs, (Byte)n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,14 +277,12 @@ static void luaI_registerlocalvar (FuncState *fs, TaggedString *varname,
|
||||||
int line) {
|
int line) {
|
||||||
if (fs->maxvars != -1) { /* debug information? */
|
if (fs->maxvars != -1) { /* debug information? */
|
||||||
TProtoFunc *f = fs->f;
|
TProtoFunc *f = fs->f;
|
||||||
if (fs->nvars+2 > fs->maxvars)
|
if (fs->nvars+1 > fs->maxvars)
|
||||||
fs->maxvars = luaM_growvector(&f->locvars, fs->maxvars+2,
|
fs->maxvars = luaM_growvector(&f->locvars, fs->maxvars+1,
|
||||||
LocVar, "", MAX_WORD);
|
LocVar, "", MAX_WORD);
|
||||||
f->locvars[fs->nvars].varname = varname;
|
f->locvars[fs->nvars].varname = varname;
|
||||||
f->locvars[fs->nvars].line = line;
|
f->locvars[fs->nvars].line = line;
|
||||||
fs->nvars++;
|
fs->nvars++;
|
||||||
f->locvars[fs->nvars].line = -1; /* flag end of vector */
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,14 +359,14 @@ static void pushupvalue (LexState *ls, TaggedString *n) {
|
||||||
if (aux_localname(ls->fs, n) >= 0)
|
if (aux_localname(ls->fs, n) >= 0)
|
||||||
luaX_syntaxerror(ls, "cannot access an upvalue in current scope", n->str);
|
luaX_syntaxerror(ls, "cannot access an upvalue in current scope", n->str);
|
||||||
i = indexupvalue(ls, n);
|
i = indexupvalue(ls, n);
|
||||||
code_oparg(ls, PUSHUPVALUE, 2, i, 1);
|
code_oparg(ls, PUSHUPVALUE, i, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void check_debugline (LexState *ls) {
|
static void check_debugline (LexState *ls) {
|
||||||
if (lua_debug && ls->linenumber != ls->fs->lastsetline) {
|
if (lua_debug && ls->linenumber != ls->fs->lastsetline) {
|
||||||
code_oparg(ls, SETLINE, 0, ls->linenumber, 0);
|
code_oparg(ls, SETLINE, ls->linenumber, 0);
|
||||||
ls->fs->lastsetline = ls->linenumber;
|
ls->fs->lastsetline = ls->linenumber;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -384,9 +374,9 @@ static void check_debugline (LexState *ls) {
|
||||||
|
|
||||||
static void adjuststack (LexState *ls, int n) {
|
static void adjuststack (LexState *ls, int n) {
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
code_oparg(ls, POP, 2, n-1, -n);
|
code_oparg(ls, POP, n-1, -n);
|
||||||
else if (n < 0)
|
else if (n < 0)
|
||||||
code_oparg(ls, PUSHNIL, 1, (-n)-1, -n);
|
code_oparg(ls, PUSHNIL, (-n)-1, -n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -394,7 +384,7 @@ static void close_exp (LexState *ls, int pc, int nresults) {
|
||||||
if (pc > 0) { /* expression is an open function call */
|
if (pc > 0) { /* expression is an open function call */
|
||||||
Byte *code = ls->fs->f->code;
|
Byte *code = ls->fs->f->code;
|
||||||
Byte nparams = code[pc]; /* save nparams */
|
Byte nparams = code[pc]; /* save nparams */
|
||||||
pc += fix_opcode(ls, pc-2, CALLFUNC, 2, nresults);
|
pc += fix_opcode(ls, pc-2, CALLFUNC, nresults);
|
||||||
code[pc] = nparams; /* restore nparams */
|
code[pc] = nparams; /* restore nparams */
|
||||||
if (nresults != MULT_RET)
|
if (nresults != MULT_RET)
|
||||||
deltastack(ls, nresults); /* "push" results */
|
deltastack(ls, nresults); /* "push" results */
|
||||||
|
@ -442,13 +432,13 @@ static void code_args (LexState *ls, int nparams, int dots) {
|
||||||
static void lua_pushvar (LexState *ls, vardesc *var) {
|
static void lua_pushvar (LexState *ls, vardesc *var) {
|
||||||
switch (var->k) {
|
switch (var->k) {
|
||||||
case VLOCAL:
|
case VLOCAL:
|
||||||
code_oparg(ls, PUSHLOCAL, 8, var->info, 1);
|
code_oparg(ls, PUSHLOCAL, var->info, 1);
|
||||||
break;
|
break;
|
||||||
case VGLOBAL:
|
case VGLOBAL:
|
||||||
code_oparg(ls, GETGLOBAL, 8, var->info, 1);
|
code_oparg(ls, GETGLOBAL, var->info, 1);
|
||||||
break;
|
break;
|
||||||
case VDOT:
|
case VDOT:
|
||||||
code_oparg(ls, GETDOTTED, 8, var->info, 0);
|
code_oparg(ls, GETDOTTED, var->info, 0);
|
||||||
break;
|
break;
|
||||||
case VINDEXED:
|
case VINDEXED:
|
||||||
code_opcode(ls, GETTABLE, -1);
|
code_opcode(ls, GETTABLE, -1);
|
||||||
|
@ -465,10 +455,10 @@ static void lua_pushvar (LexState *ls, vardesc *var) {
|
||||||
static void storevar (LexState *ls, vardesc *var) {
|
static void storevar (LexState *ls, vardesc *var) {
|
||||||
switch (var->k) {
|
switch (var->k) {
|
||||||
case VLOCAL:
|
case VLOCAL:
|
||||||
code_oparg(ls, SETLOCAL, 8, var->info, -1);
|
code_oparg(ls, SETLOCAL, var->info, -1);
|
||||||
break;
|
break;
|
||||||
case VGLOBAL:
|
case VGLOBAL:
|
||||||
code_oparg(ls, SETGLOBAL, 8, var->info, -1);
|
code_oparg(ls, SETGLOBAL, var->info, -1);
|
||||||
break;
|
break;
|
||||||
case VINDEXED:
|
case VINDEXED:
|
||||||
code_opcode(ls, SETTABLE0, -3);
|
code_opcode(ls, SETTABLE0, -3);
|
||||||
|
@ -481,14 +471,14 @@ static void storevar (LexState *ls, vardesc *var) {
|
||||||
|
|
||||||
static int fix_jump (LexState *ls, int pc, OpCode op, int n) {
|
static int fix_jump (LexState *ls, int pc, OpCode op, int n) {
|
||||||
/* jump is relative to position following jump instruction */
|
/* jump is relative to position following jump instruction */
|
||||||
return fix_opcode(ls, pc, op, 0, n-(pc+JMPSIZE));
|
return fix_opcode(ls, pc, op, n-(pc+JMPSIZE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void fix_upjmp (LexState *ls, OpCode op, int pos) {
|
static void fix_upjmp (LexState *ls, OpCode op, int pos) {
|
||||||
int delta = ls->fs->pc+JMPSIZE - pos; /* jump is relative */
|
int delta = ls->fs->pc+JMPSIZE - pos; /* jump is relative */
|
||||||
if (delta > 255) delta++;
|
if (delta > 255) delta++;
|
||||||
code_oparg(ls, op, 0, delta, 0);
|
code_oparg(ls, op, delta, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -516,7 +506,7 @@ static void func_onstack (LexState *ls, FuncState *func) {
|
||||||
else {
|
else {
|
||||||
for (i=0; i<func->nupvalues; i++)
|
for (i=0; i<func->nupvalues; i++)
|
||||||
lua_pushvar(ls, &func->upvalues[i]);
|
lua_pushvar(ls, &func->upvalues[i]);
|
||||||
code_oparg(ls, CLOSURE, 0, c, -func->nupvalues+1);
|
code_oparg(ls, CLOSURE, c, -func->nupvalues+1);
|
||||||
code_byte(fs, (Byte)func->nupvalues);
|
code_byte(fs, (Byte)func->nupvalues);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -862,7 +852,7 @@ static void ifpart (LexState *ls, int isexp, int line) {
|
||||||
}
|
}
|
||||||
else { /* is exp */
|
else { /* is exp */
|
||||||
if (elsepart) exp1(ls);
|
if (elsepart) exp1(ls);
|
||||||
else code_oparg(ls, PUSHNIL, 1, 0, 1); /* empty else exp */
|
else adjuststack(ls, -1); /* empty else exp -> push nil */
|
||||||
}
|
}
|
||||||
check_match(ls, END, IF, line);
|
check_match(ls, END, IF, line);
|
||||||
}
|
}
|
||||||
|
@ -878,7 +868,7 @@ static void ret (LexState *ls) {
|
||||||
next(ls);
|
next(ls);
|
||||||
explist(ls, &e);
|
explist(ls, &e);
|
||||||
close_exp(ls, e.pc, MULT_RET);
|
close_exp(ls, e.pc, MULT_RET);
|
||||||
code_oparg(ls, RETCODE, 0, ls->fs->nlocalvar, 0);
|
code_oparg(ls, RETCODE, ls->fs->nlocalvar, 0);
|
||||||
ls->fs->stacksize = ls->fs->nlocalvar; /* removes all temp values */
|
ls->fs->stacksize = ls->fs->nlocalvar; /* removes all temp values */
|
||||||
optional(ls, ';');
|
optional(ls, ';');
|
||||||
}
|
}
|
||||||
|
@ -1078,7 +1068,7 @@ static void var_or_func_tail (LexState *ls, vardesc *v) {
|
||||||
case ':': /* var_or_func_tail -> ':' NAME funcparams */
|
case ':': /* var_or_func_tail -> ':' NAME funcparams */
|
||||||
next(ls);
|
next(ls);
|
||||||
lua_pushvar(ls, v); /* 'v' must be on stack */
|
lua_pushvar(ls, v); /* 'v' must be on stack */
|
||||||
code_oparg(ls, PUSHSELF, 8, checkname(ls), 1);
|
code_oparg(ls, PUSHSELF, checkname(ls), 1);
|
||||||
v->k = VEXP;
|
v->k = VEXP;
|
||||||
v->info = funcparams(ls, 1);
|
v->info = funcparams(ls, 1);
|
||||||
break;
|
break;
|
||||||
|
@ -1242,7 +1232,7 @@ static int assignment (LexState *ls, vardesc *v, int nvars) {
|
||||||
storevar(ls, v);
|
storevar(ls, v);
|
||||||
}
|
}
|
||||||
else { /* indexed var with values in between*/
|
else { /* indexed var with values in between*/
|
||||||
code_oparg(ls, SETTABLE, 0, left+(nvars-1), -1);
|
code_oparg(ls, SETTABLE, left+(nvars-1), -1);
|
||||||
left += 2; /* table/index are not popped, because they aren't on top */
|
left += 2; /* table/index are not popped, because they aren't on top */
|
||||||
}
|
}
|
||||||
return left;
|
return left;
|
||||||
|
@ -1267,7 +1257,7 @@ static void constructor (LexState *ls) {
|
||||||
nelems += other_cd.n;
|
nelems += other_cd.n;
|
||||||
}
|
}
|
||||||
check_match(ls, '}', '{', line);
|
check_match(ls, '}', '{', line);
|
||||||
fix_opcode(ls, pc, CREATEARRAY, 2, nelems);
|
fix_opcode(ls, pc, CREATEARRAY, nelems);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void part (LexState *ls, constdesc *cd) {
|
static void part (LexState *ls, constdesc *cd) {
|
||||||
|
|
235
lvm.c
235
lvm.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lvm.c,v 1.40 1999/01/20 20:22:06 roberto Exp roberto $
|
** $Id: lvm.c,v 1.41 1999/01/25 17:39:28 roberto Exp roberto $
|
||||||
** Lua virtual machine
|
** Lua virtual machine
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -31,9 +31,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define skip_word(pc) (pc+=2)
|
#define highbyte(x) ((x)<<8)
|
||||||
#define get_word(pc) ((*(pc)<<8)+(*((pc)+1)))
|
|
||||||
#define next_word(pc) (pc+=2, get_word(pc-2))
|
|
||||||
|
|
||||||
|
|
||||||
/* Extra stack size to run a function: LUA_T_LINE(1), TM calls(2), ... */
|
/* Extra stack size to run a function: LUA_T_LINE(1), TM calls(2), ... */
|
||||||
|
@ -315,10 +313,9 @@ static void adjust_varargs (StkId first_extra_arg)
|
||||||
** [stack+base,top). Returns n such that the the results are between
|
** [stack+base,top). Returns n such that the the results are between
|
||||||
** [stack+n,top).
|
** [stack+n,top).
|
||||||
*/
|
*/
|
||||||
StkId luaV_execute (Closure *cl, TProtoFunc *tf, StkId base)
|
StkId luaV_execute (Closure *cl, TProtoFunc *tf, StkId base) {
|
||||||
{
|
|
||||||
struct Stack *S = &L->stack; /* to optimize */
|
struct Stack *S = &L->stack; /* to optimize */
|
||||||
Byte *pc = tf->code;
|
register Byte *pc = tf->code;
|
||||||
TObject *consts = tf->consts;
|
TObject *consts = tf->consts;
|
||||||
if (lua_callhook)
|
if (lua_callhook)
|
||||||
luaD_callHook(base, tf, 0);
|
luaD_callHook(base, tf, 0);
|
||||||
|
@ -330,54 +327,28 @@ StkId luaV_execute (Closure *cl, TProtoFunc *tf, StkId base)
|
||||||
adjust_varargs(base+(*pc++)-ZEROVARARG);
|
adjust_varargs(base+(*pc++)-ZEROVARARG);
|
||||||
}
|
}
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int aux;
|
register int aux = 0;
|
||||||
switch ((OpCode)(aux = *pc++)) {
|
switch ((OpCode)*pc++) {
|
||||||
|
|
||||||
case PUSHNIL0:
|
case PUSHNIL: aux = *pc++;
|
||||||
ttype(S->top++) = LUA_T_NIL;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PUSHNIL:
|
|
||||||
aux = *pc++;
|
|
||||||
do {
|
do {
|
||||||
ttype(S->top++) = LUA_T_NIL;
|
ttype(S->top++) = LUA_T_NIL;
|
||||||
} while (aux--);
|
} while (aux--);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PUSHNUMBER:
|
case PUSHNUMBERW: aux = highbyte(*pc++);
|
||||||
aux = *pc++; goto pushnumber;
|
case PUSHNUMBER: aux += *pc++;
|
||||||
|
|
||||||
case PUSHNUMBERW:
|
|
||||||
aux = next_word(pc); goto pushnumber;
|
|
||||||
|
|
||||||
case PUSHNUMBER0: case PUSHNUMBER1: case PUSHNUMBER2:
|
|
||||||
aux -= PUSHNUMBER0;
|
|
||||||
pushnumber:
|
|
||||||
ttype(S->top) = LUA_T_NUMBER;
|
ttype(S->top) = LUA_T_NUMBER;
|
||||||
nvalue(S->top) = aux;
|
nvalue(S->top) = aux-NUMOFFSET;
|
||||||
S->top++;
|
S->top++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PUSHLOCAL:
|
case PUSHLOCAL: aux = *pc++;
|
||||||
aux = *pc++; goto pushlocal;
|
|
||||||
|
|
||||||
case PUSHLOCAL0: case PUSHLOCAL1: case PUSHLOCAL2: case PUSHLOCAL3:
|
|
||||||
case PUSHLOCAL4: case PUSHLOCAL5: case PUSHLOCAL6: case PUSHLOCAL7:
|
|
||||||
aux -= PUSHLOCAL0;
|
|
||||||
pushlocal:
|
|
||||||
*S->top++ = *((S->stack+base) + aux);
|
*S->top++ = *((S->stack+base) + aux);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GETGLOBALW:
|
case GETGLOBALW: aux = highbyte(*pc++);
|
||||||
aux = next_word(pc); goto getglobal;
|
case GETGLOBAL: aux += *pc++;
|
||||||
|
|
||||||
case GETGLOBAL:
|
|
||||||
aux = *pc++; goto getglobal;
|
|
||||||
|
|
||||||
case GETGLOBAL0: case GETGLOBAL1: case GETGLOBAL2: case GETGLOBAL3:
|
|
||||||
case GETGLOBAL4: case GETGLOBAL5: case GETGLOBAL6: case GETGLOBAL7:
|
|
||||||
aux -= GETGLOBAL0;
|
|
||||||
getglobal:
|
|
||||||
luaV_getglobal(tsvalue(&consts[aux]));
|
luaV_getglobal(tsvalue(&consts[aux]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -385,30 +356,14 @@ StkId luaV_execute (Closure *cl, TProtoFunc *tf, StkId base)
|
||||||
luaV_gettable();
|
luaV_gettable();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GETDOTTEDW:
|
case GETDOTTEDW: aux = highbyte(*pc++);
|
||||||
aux = next_word(pc); goto getdotted;
|
case GETDOTTED: aux += *pc++;
|
||||||
|
|
||||||
case GETDOTTED:
|
|
||||||
aux = *pc++; goto getdotted;
|
|
||||||
|
|
||||||
case GETDOTTED0: case GETDOTTED1: case GETDOTTED2: case GETDOTTED3:
|
|
||||||
case GETDOTTED4: case GETDOTTED5: case GETDOTTED6: case GETDOTTED7:
|
|
||||||
aux -= GETDOTTED0;
|
|
||||||
getdotted:
|
|
||||||
*S->top++ = consts[aux];
|
*S->top++ = consts[aux];
|
||||||
luaV_gettable();
|
luaV_gettable();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PUSHSELFW:
|
case PUSHSELFW: aux = highbyte(*pc++);
|
||||||
aux = next_word(pc); goto pushself;
|
case PUSHSELF: aux += *pc++; {
|
||||||
|
|
||||||
case PUSHSELF:
|
|
||||||
aux = *pc++; goto pushself;
|
|
||||||
|
|
||||||
case PUSHSELF0: case PUSHSELF1: case PUSHSELF2: case PUSHSELF3:
|
|
||||||
case PUSHSELF4: case PUSHSELF5: case PUSHSELF6: case PUSHSELF7:
|
|
||||||
aux -= PUSHSELF0;
|
|
||||||
pushself: {
|
|
||||||
TObject receiver = *(S->top-1);
|
TObject receiver = *(S->top-1);
|
||||||
*S->top++ = consts[aux];
|
*S->top++ = consts[aux];
|
||||||
luaV_gettable();
|
luaV_gettable();
|
||||||
|
@ -416,49 +371,21 @@ StkId luaV_execute (Closure *cl, TProtoFunc *tf, StkId base)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case PUSHCONSTANTW:
|
case PUSHCONSTANTW: aux = highbyte(*pc++);
|
||||||
aux = next_word(pc); goto pushconstant;
|
case PUSHCONSTANT: aux += *pc++;
|
||||||
|
|
||||||
case PUSHCONSTANT:
|
|
||||||
aux = *pc++; goto pushconstant;
|
|
||||||
|
|
||||||
case PUSHCONSTANT0: case PUSHCONSTANT1: case PUSHCONSTANT2:
|
|
||||||
case PUSHCONSTANT3: case PUSHCONSTANT4: case PUSHCONSTANT5:
|
|
||||||
case PUSHCONSTANT6: case PUSHCONSTANT7:
|
|
||||||
aux -= PUSHCONSTANT0;
|
|
||||||
pushconstant:
|
|
||||||
*S->top++ = consts[aux];
|
*S->top++ = consts[aux];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PUSHUPVALUE:
|
case PUSHUPVALUE: aux = *pc++;
|
||||||
aux = *pc++; goto pushupvalue;
|
|
||||||
|
|
||||||
case PUSHUPVALUE0: case PUSHUPVALUE1:
|
|
||||||
aux -= PUSHUPVALUE0;
|
|
||||||
pushupvalue:
|
|
||||||
*S->top++ = cl->consts[aux+1];
|
*S->top++ = cl->consts[aux+1];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SETLOCAL:
|
case SETLOCAL: aux = *pc++;
|
||||||
aux = *pc++; goto setlocal;
|
|
||||||
|
|
||||||
case SETLOCAL0: case SETLOCAL1: case SETLOCAL2: case SETLOCAL3:
|
|
||||||
case SETLOCAL4: case SETLOCAL5: case SETLOCAL6: case SETLOCAL7:
|
|
||||||
aux -= SETLOCAL0;
|
|
||||||
setlocal:
|
|
||||||
*((S->stack+base) + aux) = *(--S->top);
|
*((S->stack+base) + aux) = *(--S->top);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SETGLOBALW:
|
case SETGLOBALW: aux = highbyte(*pc++);
|
||||||
aux = next_word(pc); goto setglobal;
|
case SETGLOBAL: aux += *pc++;
|
||||||
|
|
||||||
case SETGLOBAL:
|
|
||||||
aux = *pc++; goto setglobal;
|
|
||||||
|
|
||||||
case SETGLOBAL0: case SETGLOBAL1: case SETGLOBAL2: case SETGLOBAL3:
|
|
||||||
case SETGLOBAL4: case SETGLOBAL5: case SETGLOBAL6: case SETGLOBAL7:
|
|
||||||
aux -= SETGLOBAL0;
|
|
||||||
setglobal:
|
|
||||||
luaV_setglobal(tsvalue(&consts[aux]));
|
luaV_setglobal(tsvalue(&consts[aux]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -470,28 +397,17 @@ StkId luaV_execute (Closure *cl, TProtoFunc *tf, StkId base)
|
||||||
luaV_settable(S->top-3-(*pc++), 1);
|
luaV_settable(S->top-3-(*pc++), 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SETLISTW:
|
case SETLISTW: aux = highbyte(*pc++);
|
||||||
aux = next_word(pc); aux *= LFIELDS_PER_FLUSH; goto setlist;
|
case SETLIST: aux += *pc++; {
|
||||||
|
|
||||||
case SETLIST:
|
|
||||||
aux = *(pc++) * LFIELDS_PER_FLUSH; goto setlist;
|
|
||||||
|
|
||||||
case SETLIST0:
|
|
||||||
aux = 0;
|
|
||||||
setlist: {
|
|
||||||
int n = *(pc++);
|
int n = *(pc++);
|
||||||
TObject *arr = S->top-n-1;
|
TObject *arr = S->top-n-1;
|
||||||
|
aux *= LFIELDS_PER_FLUSH;
|
||||||
for (; n; n--)
|
for (; n; n--)
|
||||||
luaH_setint(avalue(arr), n+aux, --S->top);
|
luaH_setint(avalue(arr), n+aux, --S->top);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SETMAP0:
|
case SETMAP: aux = *pc++; {
|
||||||
aux = 0; goto setmap;
|
|
||||||
|
|
||||||
case SETMAP:
|
|
||||||
aux = *pc++;
|
|
||||||
setmap: {
|
|
||||||
TObject *arr = S->top-(2*aux)-3;
|
TObject *arr = S->top-(2*aux)-3;
|
||||||
do {
|
do {
|
||||||
luaH_set(avalue(arr), S->top-2, S->top-1);
|
luaH_set(avalue(arr), S->top-2, S->top-1);
|
||||||
|
@ -500,34 +416,23 @@ StkId luaV_execute (Closure *cl, TProtoFunc *tf, StkId base)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case POP:
|
case POP: aux = *pc++;
|
||||||
aux = *pc++; goto pop;
|
|
||||||
|
|
||||||
case POP0: case POP1:
|
|
||||||
aux -= POP0;
|
|
||||||
pop:
|
|
||||||
S->top -= (aux+1);
|
S->top -= (aux+1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CREATEARRAYW:
|
case CREATEARRAYW: aux = highbyte(*pc++);
|
||||||
aux = next_word(pc); goto createarray;
|
case CREATEARRAY: aux += *pc++;
|
||||||
|
|
||||||
case CREATEARRAY0: case CREATEARRAY1:
|
|
||||||
aux -= CREATEARRAY0; goto createarray;
|
|
||||||
|
|
||||||
case CREATEARRAY:
|
|
||||||
aux = *pc++;
|
|
||||||
createarray:
|
|
||||||
luaC_checkGC();
|
luaC_checkGC();
|
||||||
avalue(S->top) = luaH_new(aux);
|
avalue(S->top) = luaH_new(aux);
|
||||||
ttype(S->top) = LUA_T_ARRAY;
|
ttype(S->top) = LUA_T_ARRAY;
|
||||||
S->top++;
|
S->top++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EQOP: case NEQOP: {
|
case NEQOP: aux = 1;
|
||||||
|
case EQOP: {
|
||||||
int res = luaO_equalObj(S->top-2, S->top-1);
|
int res = luaO_equalObj(S->top-2, S->top-1);
|
||||||
|
if (aux) res = !res;
|
||||||
S->top--;
|
S->top--;
|
||||||
if (aux == NEQOP) res = !res;
|
|
||||||
ttype(S->top-1) = res ? LUA_T_NUMBER : LUA_T_NIL;
|
ttype(S->top-1) = res ? LUA_T_NUMBER : LUA_T_NIL;
|
||||||
nvalue(S->top-1) = 1;
|
nvalue(S->top-1) = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -630,98 +535,60 @@ StkId luaV_execute (Closure *cl, TProtoFunc *tf, StkId base)
|
||||||
nvalue(S->top-1) = 1;
|
nvalue(S->top-1) = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ONTJMPW:
|
case ONTJMPW: aux = highbyte(*pc++);
|
||||||
aux = next_word(pc); goto ontjmp;
|
case ONTJMP: aux += *pc++;
|
||||||
|
|
||||||
case ONTJMP:
|
|
||||||
aux = *pc++;
|
|
||||||
ontjmp:
|
|
||||||
if (ttype(S->top-1) != LUA_T_NIL) pc += aux;
|
if (ttype(S->top-1) != LUA_T_NIL) pc += aux;
|
||||||
else S->top--;
|
else S->top--;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ONFJMPW:
|
case ONFJMPW: aux = highbyte(*pc++);
|
||||||
aux = next_word(pc); goto onfjmp;
|
case ONFJMP: aux += *pc++;
|
||||||
|
|
||||||
case ONFJMP:
|
|
||||||
aux = *pc++;
|
|
||||||
onfjmp:
|
|
||||||
if (ttype(S->top-1) == LUA_T_NIL) pc += aux;
|
if (ttype(S->top-1) == LUA_T_NIL) pc += aux;
|
||||||
else S->top--;
|
else S->top--;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JMPW:
|
case JMPW: aux = highbyte(*pc++);
|
||||||
aux = next_word(pc); goto jmp;
|
case JMP: aux += *pc++;
|
||||||
|
|
||||||
case JMP:
|
|
||||||
aux = *pc++;
|
|
||||||
jmp:
|
|
||||||
pc += aux;
|
pc += aux;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IFFJMPW:
|
case IFFJMPW: aux = highbyte(*pc++);
|
||||||
aux = next_word(pc); goto iffjmp;
|
case IFFJMP: aux += *pc++;
|
||||||
|
|
||||||
case IFFJMP:
|
|
||||||
aux = *pc++;
|
|
||||||
iffjmp:
|
|
||||||
if (ttype(--S->top) == LUA_T_NIL) pc += aux;
|
if (ttype(--S->top) == LUA_T_NIL) pc += aux;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IFTUPJMPW:
|
case IFTUPJMPW: aux = highbyte(*pc++);
|
||||||
aux = next_word(pc); goto iftupjmp;
|
case IFTUPJMP: aux += *pc++;
|
||||||
|
|
||||||
case IFTUPJMP:
|
|
||||||
aux = *pc++;
|
|
||||||
iftupjmp:
|
|
||||||
if (ttype(--S->top) != LUA_T_NIL) pc -= aux;
|
if (ttype(--S->top) != LUA_T_NIL) pc -= aux;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IFFUPJMPW:
|
case IFFUPJMPW: aux = highbyte(*pc++);
|
||||||
aux = next_word(pc); goto iffupjmp;
|
case IFFUPJMP: aux += *pc++;
|
||||||
|
|
||||||
case IFFUPJMP:
|
|
||||||
aux = *pc++;
|
|
||||||
iffupjmp:
|
|
||||||
if (ttype(--S->top) == LUA_T_NIL) pc -= aux;
|
if (ttype(--S->top) == LUA_T_NIL) pc -= aux;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CLOSUREW:
|
case CLOSURE: aux = *pc++;
|
||||||
aux = next_word(pc); goto closure;
|
|
||||||
|
|
||||||
case CLOSURE:
|
|
||||||
aux = *pc++;
|
|
||||||
closure:
|
|
||||||
*S->top++ = consts[aux];
|
*S->top++ = consts[aux];
|
||||||
luaV_closure(*pc++);
|
luaV_closure(*pc++);
|
||||||
luaC_checkGC();
|
luaC_checkGC();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CALLFUNC:
|
case CALLFUNC: aux = *pc++; {
|
||||||
aux = *pc++; goto callfunc;
|
|
||||||
|
|
||||||
case CALLFUNC0: case CALLFUNC1:
|
|
||||||
aux -= CALLFUNC0;
|
|
||||||
callfunc: {
|
|
||||||
StkId newBase = (S->top-S->stack)-(*pc++);
|
StkId newBase = (S->top-S->stack)-(*pc++);
|
||||||
luaD_call(newBase, aux);
|
luaD_call(newBase, aux);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ENDCODE:
|
case ENDCODE: aux = 1;
|
||||||
S->top = S->stack + base;
|
S->top = S->stack + base;
|
||||||
/* goes through */
|
/* goes through */
|
||||||
case RETCODE:
|
case RETCODE:
|
||||||
if (lua_callhook)
|
if (lua_callhook)
|
||||||
luaD_callHook(base, NULL, 1);
|
luaD_callHook(base, NULL, 1);
|
||||||
return (base + ((aux==RETCODE) ? *pc : 0));
|
return base + (aux ? 0 : *pc);
|
||||||
|
|
||||||
case SETLINEW:
|
case SETLINEW: aux = highbyte(*pc++);
|
||||||
aux = next_word(pc); goto setline;
|
case SETLINE: aux += *pc++;
|
||||||
|
|
||||||
case SETLINE:
|
|
||||||
aux = *pc++;
|
|
||||||
setline:
|
|
||||||
if ((S->stack+base-1)->ttype != LUA_T_LINE) {
|
if ((S->stack+base-1)->ttype != LUA_T_LINE) {
|
||||||
/* open space for LINE value */
|
/* open space for LINE value */
|
||||||
luaD_openstack((S->top-S->stack)-base);
|
luaD_openstack((S->top-S->stack)-base);
|
||||||
|
|
Loading…
Reference in New Issue