lua/lopcodes.h

149 lines
4.1 KiB
C
Raw Normal View History

1997-09-16 12:25:59 -07:00
/*
1997-10-06 07:51:11 -07:00
** $Id: lopcodes.h,v 1.6 1997/10/01 20:05:34 roberto Exp roberto $
1997-09-16 12:25:59 -07:00
** Opcodes for Lua virtual machine
** See Copyright Notice in lua.h
*/
#ifndef lopcodes_h
#define lopcodes_h
/*
** NOTICE: variants of the same opcode (like PUSH0, PUSHBYTE, PUSHWORD) must
** be consecutive: First, those with built-in parameters, then with byte
** parameter and last with word parameter.
*/
1997-09-16 12:25:59 -07:00
typedef enum {
/* name parm before after side effect
-----------------------------------------------------------------------------*/
1997-10-06 07:51:11 -07:00
ENDCODE,/* - - - */
1997-09-16 12:25:59 -07:00
1997-10-06 07:51:11 -07:00
PUSHNIL,/* - - nil */
1997-09-16 12:25:59 -07:00
PUSHNILS,/* b - nil_1...nil_b */
1997-10-06 07:51:11 -07:00
PUSH0,/* - - 0.0 */
PUSH1,/* - - 1.0 */
PUSH2,/* - - 2.0 */
1997-09-16 12:25:59 -07:00
PUSHBYTE,/* b - (float)b */
PUSHWORD,/* w - (float)w */
1997-10-06 07:51:11 -07:00
PUSHCONSTANT0,/*- - CNST[0] */
PUSHCONSTANT1,/*- - CNST[1] */
PUSHCONSTANT2,/*- - CNST[2] */
PUSHCONSTANT3,/*- - CNST[3] */
PUSHCONSTANT4,/*- - CNST[4] */
PUSHCONSTANT5,/*- - CNST[5] */
PUSHCONSTANT6,/*- - CNST[6] */
PUSHCONSTANT7,/*- - CNST[7] */
PUSHCONSTANT8,/*- - CNST[8] */
PUSHCONSTANT9,/*- - CNST[9] */
1997-09-16 12:25:59 -07:00
PUSHCONSTANTB,/*b - CNST[b] */
PUSHCONSTANT,/* w - CNST[w] */
1997-10-06 07:51:11 -07:00
PUSHUPVALUE0,/* - - Closure[0] */
PUSHUPVALUE1,/* - - Closure[1] */
1997-09-16 12:25:59 -07:00
PUSHUPVALUE,/* b - Closure[b] */
1997-10-06 07:51:11 -07:00
PUSHLOCAL0,/* - - LOC[0] */
PUSHLOCAL1,/* - - LOC[1] */
PUSHLOCAL2,/* - - LOC[2] */
PUSHLOCAL3,/* - - LOC[3] */
PUSHLOCAL4,/* - - LOC[4] */
PUSHLOCAL5,/* - - LOC[5] */
PUSHLOCAL6,/* - - LOC[6] */
PUSHLOCAL7,/* - - LOC[7] */
PUSHLOCAL8,/* - - LOC[8] */
PUSHLOCAL9,/* - - LOC[9] */
1997-09-16 12:25:59 -07:00
PUSHLOCAL,/* b - LOC[b] */
1997-10-06 07:51:11 -07:00
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]] */
GETGLOBAL8,/* - - VAR[CNST[8]] */
GETGLOBAL9,/* - - VAR[CNST[9]] */
GETGLOBALB,/* b - VAR[CNST[b]] */
GETGLOBAL,/* w - VAR[CNST[w]] */
1997-10-06 07:51:11 -07:00
GETTABLE,/* - i t t[i] */
PUSHSELFB,/* b t t t[CNST[b]] */
1997-09-16 12:25:59 -07:00
PUSHSELF,/* w t t t[CNST[w]] */
CREATEARRAYB,/* b - newarray(size = b) */
1997-09-16 12:25:59 -07:00
CREATEARRAY,/* w - newarray(size = w) */
1997-10-06 07:51:11 -07:00
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 */
SETLOCAL8,/* - x - LOC[8]=x */
SETLOCAL9,/* - x - LOC[9]=x */
1997-09-16 12:25:59 -07:00
SETLOCAL,/* b x - LOC[b]=x */
SETGLOBALB,/* b x - VAR[CNST[b]]=x */
SETGLOBAL,/* w x - VAR[CNST[w]]=x */
1997-10-06 07:51:11 -07:00
SETTABLE0,/* - v i t - t[i]=v */
1997-09-16 12:25:59 -07:00
SETTABLE,/* b v a_b...a_1 i t a_b...a_1 i t t[i]=v */
1997-09-16 12:25:59 -07:00
SETLIST0,/* b v_b...v_1 t - t[i]=v_i */
SETLIST,/* b c v_b...v_1 t - t[i+c*FPF]=v_i */
SETMAP,/* b v_b k_b ...v_1 k_1 t t t[k_i]=v_i */
1997-10-06 07:51:11 -07:00
EQOP,/* - y x (x==y)? 1 : nil */
NEQOP,/* - y x (x~=y)? 1 : nil */
LTOP,/* - y x (x<y)? 1 : nil */
LEOP,/* - y x (x<y)? 1 : nil */
GTOP,/* - y x (x>y)? 1 : nil */
GEOP,/* - y x (x>=y)? 1 : nil */
ADDOP,/* - y x x+y */
SUBOP,/* - y x x-y */
MULTOP,/* - y x x*y */
DIVOP,/* - y x x/y */
POWOP,/* - y x x^y */
CONCOP,/* - y x x..y */
MINUSOP,/* - x -x */
NOTOP,/* - x (x==nil)? 1 : nil */
1997-09-24 12:43:11 -07:00
ONTJMP,/* b x (x!=nil)? x : - (x!=nil)? PC+=b */
ONFJMP,/* b x (x==nil)? x : - (x==nil)? PC+=b */
JMPB,/* b - - PC+=b */
1997-09-16 12:25:59 -07:00
JMP,/* w - - PC+=w */
IFFJMPB,/* b x - (x==nil)? PC+=b */
1997-09-16 12:25:59 -07:00
IFFJMP,/* w x - (x==nil)? PC+=w */
IFTUPJMPB,/* b x - (x!=nil)? PC-=b */
IFTUPJMP,/* w x - (x!=nil)? PC-=w */
1997-09-24 12:43:11 -07:00
IFFUPJMPB,/* b x - (x==nil)? PC-=b */
1997-09-16 12:25:59 -07:00
IFFUPJMP,/* w x - (x==nil)? PC-=w */
CLOSUREB,/* b v_1...v_n c(CNST[b]) */
CLOSURE,/* w v_1...v_n c(CNST[w]) */
1997-09-16 12:25:59 -07:00
CALLFUNC,/* b c v_b...v_1 f r_c...r_1 f(v1,...,v_b) */
RETCODE,/* b - - */
SETLINE,/* w - - LINE=w */
1997-10-06 07:51:11 -07:00
POP1,/* - - - TOP-=1 */
POP2,/* - - - TOP-=2 */
1997-09-16 12:25:59 -07:00
POPS,/* b - - TOP-=b */
ARGS,/* b - - TOP=BASE+b */
VARARGS/* b v_x...v_1 {v_1...v_x;n=x} TOP=BASE+b+1 */
} OpCode;
#define RFIELDS_PER_FLUSH 32 /* records (SETMAP) */
#define LFIELDS_PER_FLUSH 64 /* lists (SETLIST) */
#endif