small corrections in opcodes.
This commit is contained in:
18
lopcodes.h
18
lopcodes.h
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lopcodes.h,v 1.22 1999/02/08 17:07:59 roberto Exp roberto $
|
** $Id: lopcodes.h,v 1.23 1999/02/08 18:54:19 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
|
||||||
*/
|
*/
|
||||||
@@ -21,11 +21,14 @@ ENDCODE,/* - - - */
|
|||||||
RETCODE,/* b - - */
|
RETCODE,/* b - - */
|
||||||
|
|
||||||
PUSHNIL,/* b - nil_0...nil_b */
|
PUSHNIL,/* b - nil_0...nil_b */
|
||||||
POP,/* b - - TOP-=(b+1) */
|
POP,/* b - - TOP-=b */
|
||||||
POPDUP,/* b v v TOP-=(b+1) */
|
POPDUP,/* b v v TOP-=b */
|
||||||
|
|
||||||
PUSHNUMBERW,/* w - (float)(w-NUMOFFSET) */
|
PUSHNUMBERW,/* w - (float)w */
|
||||||
PUSHNUMBER,/* b - (float)(b-NUMOFFSET) */
|
PUSHNUMBER,/* b - (float)b */
|
||||||
|
|
||||||
|
PUSHNEGW,/* w - (float)-w */
|
||||||
|
PUSHNEG,/* b - (float)-b */
|
||||||
|
|
||||||
PUSHCONSTANTW,/*w - CNST[w] */
|
PUSHCONSTANTW,/*w - CNST[w] */
|
||||||
PUSHCONSTANT,/* b - CNST[b] */
|
PUSHCONSTANT,/* b - CNST[b] */
|
||||||
@@ -57,7 +60,7 @@ SETGLOBALDUPW,/*w x x VAR[CNST[w]]=x */
|
|||||||
SETGLOBALDUP,/* b x x VAR[CNST[b]]=x */
|
SETGLOBALDUP,/* b x x VAR[CNST[b]]=x */
|
||||||
|
|
||||||
SETTABLEPOP,/* - v i t - t[i]=v */
|
SETTABLEPOP,/* - v i t - t[i]=v */
|
||||||
SETTABPPDUP,/* - v i t v t[i]=v */
|
SETTABLEPOPDUP,/* - v i t v 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 */
|
||||||
SETTABLEDUP,/* b v a_b...a_1 i t v a_b...a_1 i t t[i]=v */
|
SETTABLEDUP,/* b v a_b...a_1 i t v a_b...a_1 i t t[i]=v */
|
||||||
@@ -95,6 +98,7 @@ IFTUPJMP,/* b x - (x!=nil)? PC-=b */
|
|||||||
IFFUPJMPW,/* w x - (x==nil)? PC-=w */
|
IFFUPJMPW,/* w x - (x==nil)? PC-=w */
|
||||||
IFFUPJMP,/* b x - (x==nil)? PC-=b */
|
IFFUPJMP,/* b x - (x==nil)? PC-=b */
|
||||||
|
|
||||||
|
CLOSUREW,/* w c v_c...v_1 closure(CNST[w], v_c...v_1) */
|
||||||
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) */
|
||||||
|
|
||||||
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) */
|
||||||
@@ -107,8 +111,6 @@ LONGARG /* b (add b*(1<<16) to arg of next instruction) */
|
|||||||
} OpCode;
|
} OpCode;
|
||||||
|
|
||||||
|
|
||||||
#define NUMOFFSET 100 /* offset for immediate numbers */
|
|
||||||
|
|
||||||
#define RFIELDS_PER_FLUSH 32 /* records (SETMAP) */
|
#define RFIELDS_PER_FLUSH 32 /* records (SETMAP) */
|
||||||
#define LFIELDS_PER_FLUSH 64 /* FPF - lists (SETLIST) */
|
#define LFIELDS_PER_FLUSH 64 /* FPF - lists (SETLIST) */
|
||||||
|
|
||||||
|
|||||||
13
lparser.c
13
lparser.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lparser.c,v 1.17 1999/02/08 17:07:59 roberto Exp roberto $
|
** $Id: lparser.c,v 1.18 1999/02/08 18:54:19 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
|
||||||
*/
|
*/
|
||||||
@@ -267,9 +267,11 @@ static int real_constant (FuncState *fs, real r) {
|
|||||||
|
|
||||||
|
|
||||||
static void code_number (LexState *ls, real f) {
|
static void code_number (LexState *ls, real f) {
|
||||||
if (-NUMOFFSET <= f && f <= (real)(MAX_WORD-NUMOFFSET) &&
|
real af = (f<0) ? -f : f;
|
||||||
(int)f == f) /* f+NUMOFFSET has a short integer value? */
|
if (0 <= af && af <= (real)MAX_WORD && (int)af == af) {
|
||||||
code_oparg(ls, PUSHNUMBER, (int)f+NUMOFFSET, 1);
|
/* abs(f) has a short integer value */
|
||||||
|
code_oparg(ls, (f<0) ? PUSHNEG : PUSHNUMBER, (int)af, 1);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
code_constant(ls, real_constant(ls->fs, f));
|
code_constant(ls, real_constant(ls->fs, f));
|
||||||
}
|
}
|
||||||
@@ -474,7 +476,7 @@ static void lua_pushvar (LexState *ls, vardesc *var) {
|
|||||||
|
|
||||||
/* to be used by "storevar" and assignment */
|
/* to be used by "storevar" and assignment */
|
||||||
static OpCode set_pop[] = {SETLOCAL, SETGLOBAL, SETTABLEPOP, SETTABLE};
|
static OpCode set_pop[] = {SETLOCAL, SETGLOBAL, SETTABLEPOP, SETTABLE};
|
||||||
static OpCode set_dup[] = {SETLOCALDUP, SETGLOBALDUP, SETTABPPDUP,
|
static OpCode set_dup[] = {SETLOCALDUP, SETGLOBALDUP, SETTABLEPOPDUP,
|
||||||
SETTABLEDUP};
|
SETTABLEDUP};
|
||||||
|
|
||||||
|
|
||||||
@@ -563,6 +565,7 @@ static void init_state (LexState *ls, FuncState *fs, TaggedString *filename) {
|
|||||||
incr_top;
|
incr_top;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void close_func (LexState *ls) {
|
static void close_func (LexState *ls) {
|
||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
TProtoFunc *f = fs->f;
|
TProtoFunc *f = fs->f;
|
||||||
|
|||||||
16
lvm.c
16
lvm.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lvm.c,v 1.46 1999/02/08 17:07:59 roberto Exp roberto $
|
** $Id: lvm.c,v 1.47 1999/02/08 18:54:19 roberto Exp roberto $
|
||||||
** Lua virtual machine
|
** Lua virtual machine
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -355,7 +355,14 @@ StkId luaV_execute (Closure *cl, TProtoFunc *tf, StkId base) {
|
|||||||
case PUSHNUMBERW: aux += highbyte(*pc++);
|
case PUSHNUMBERW: aux += highbyte(*pc++);
|
||||||
case PUSHNUMBER: aux += *pc++;
|
case PUSHNUMBER: aux += *pc++;
|
||||||
ttype(S->top) = LUA_T_NUMBER;
|
ttype(S->top) = LUA_T_NUMBER;
|
||||||
nvalue(S->top) = aux-NUMOFFSET;
|
nvalue(S->top) = aux;
|
||||||
|
S->top++;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PUSHNEGW: aux += highbyte(*pc++);
|
||||||
|
case PUSHNEG: aux += *pc++;
|
||||||
|
ttype(S->top) = LUA_T_NUMBER;
|
||||||
|
nvalue(S->top) = -aux;
|
||||||
S->top++;
|
S->top++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -429,7 +436,7 @@ StkId luaV_execute (Closure *cl, TProtoFunc *tf, StkId base) {
|
|||||||
S->top -= 2; /* pop table and index */
|
S->top -= 2; /* pop table and index */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SETTABPPDUP: {
|
case SETTABLEPOPDUP: {
|
||||||
TObject temp = *(S->top-1);
|
TObject temp = *(S->top-1);
|
||||||
luaV_settable(S->top-3);
|
luaV_settable(S->top-3);
|
||||||
S->top--; /* pop index (temp goes into "table" position) */
|
S->top--; /* pop index (temp goes into "table" position) */
|
||||||
@@ -605,7 +612,8 @@ StkId luaV_execute (Closure *cl, TProtoFunc *tf, StkId base) {
|
|||||||
if (ttype(--S->top) == LUA_T_NIL) pc -= aux;
|
if (ttype(--S->top) == LUA_T_NIL) pc -= aux;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CLOSURE: aux = *pc++;
|
case CLOSUREW: aux += highbyte(*pc++);
|
||||||
|
case CLOSURE: aux += *pc++;
|
||||||
*S->top++ = consts[aux];
|
*S->top++ = consts[aux];
|
||||||
luaV_closure(*pc++);
|
luaV_closure(*pc++);
|
||||||
luaC_checkGC();
|
luaC_checkGC();
|
||||||
|
|||||||
Reference in New Issue
Block a user