lua/lopcodes.h

139 lines
3.4 KiB
C
Raw Normal View History

1997-09-16 12:25:59 -07:00
/*
** $Id: lopcodes.h,v 1.38 2000/01/28 16:53:00 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 must be consecutive: First, those
** with word parameter, then with byte parameter.
*/
1997-09-16 12:25:59 -07:00
typedef enum {
/* name parm before after side effect
-----------------------------------------------------------------------------*/
1999-03-05 13:16:07 -08:00
ENDCODE,/* - - (return) */
RETCODE,/* b - (return) */
CALL,/* b c v_n-v_1 f(at c) r_b-r_1 f(v1,...,v_n) */
1999-03-05 13:16:07 -08:00
TAILCALL,/* b c v_c-v_1 f (return) f(v1,...,v_c) */
1997-09-16 12:25:59 -07:00
PUSHNIL,/* b - nil_0-nil_b */
POP,/* b a_b-a_1 - */
2000-01-28 08:53:00 -08:00
PUSHINTW,/* w - (float)w */
PUSHINT,/* b - (float)b */
1999-02-09 07:59:10 -08:00
2000-01-28 08:53:00 -08:00
PUSHINTNEGW,/* w - (float)-w */
PUSHINTNEG,/* b - (float)-b */
2000-01-28 08:53:00 -08:00
PUSHSTRINGW,/* w - KSTR[w] */
PUSHSTRING,/* b - KSTR[b] */
PUSHNUMBERW,/* w - KNUM[w] */
PUSHNUMBER,/* b - KNUM[b] */
1999-02-25 13:07:26 -08:00
PUSHUPVALUE,/* b - Closure[b] */
1999-02-25 13:07:26 -08:00
PUSHLOCAL,/* b - LOC[b] */
1999-02-25 13:07:26 -08:00
GETGLOBALW,/* w - VAR[CNST[w]] */
GETGLOBAL,/* b - VAR[CNST[b]] */
1999-02-25 13:07:26 -08:00
GETTABLE,/* - i t t[i] */
1999-02-25 13:07:26 -08:00
GETDOTTEDW,/* w t t[CNST[w]] */
GETDOTTED,/* b t t[CNST[b]] */
1999-02-25 13:07:26 -08:00
PUSHSELFW,/* w t t t[CNST[w]] */
PUSHSELF,/* b t t t[CNST[b]] */
1999-02-25 13:07:26 -08:00
CREATEARRAYW,/* w - newarray(size = w) */
CREATEARRAY,/* b - newarray(size = b) */
1997-09-16 12:25:59 -07:00
1999-02-25 13:07:26 -08:00
SETLOCAL,/* b x - LOC[b]=x */
1999-02-25 13:07:26 -08:00
SETGLOBALW,/* w x - VAR[CNST[w]]=x */
SETGLOBAL,/* b x - VAR[CNST[b]]=x */
1999-02-25 13:07:26 -08:00
SETTABLEPOP,/* - v i t - t[i]=v */
SETTABLE,/* b v a_b-a_1 i t a_b-a_1 i t t[i]=v */
SETLISTW,/* w c v_c-v_1 t t t[i+w*FPF]=v_i */
SETLIST,/* b c v_c-v_1 t t t[i+b*FPF]=v_i */
SETMAP,/* b v_b k_b - v_0 k_0 t t t[k_i]=v_i */
1997-09-16 12:25:59 -07:00
1999-02-25 13:07:26 -08:00
NEQOP,/* - y x (x~=y)? 1 : nil */
EQOP,/* - 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-10-06 07:51:11 -07:00
1999-02-25 13:07:26 -08:00
ONTJMPW,/* w x (x!=nil)? x : - (x!=nil)? PC+=w */
ONTJMP,/* b x (x!=nil)? x : - (x!=nil)? PC+=b */
ONFJMPW,/* w x (x==nil)? x : - (x==nil)? PC+=w */
ONFJMP,/* b x (x==nil)? x : - (x==nil)? PC+=b */
JMPW,/* w - - PC+=w */
JMP,/* b - - PC+=b */
IFFJMPW,/* w x - (x==nil)? PC+=w */
IFFJMP,/* b x - (x==nil)? PC+=b */
IFTUPJMPW,/* w x - (x!=nil)? PC-=w */
IFTUPJMP,/* b x - (x!=nil)? PC-=b */
IFFUPJMPW,/* w x - (x==nil)? PC-=w */
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) */
1999-02-25 13:07:26 -08:00
SETLINEW,/* w - - LINE=w */
SETLINE,/* b - - LINE=b */
1999-02-25 13:07:26 -08:00
LONGARGW,/* w (add w*(1<<16) to arg of next instruction) */
LONGARG /* b (add b*(1<<16) to arg of next instruction) */
1998-01-12 05:35:37 -08:00
1997-09-16 12:25:59 -07:00
} OpCode;
#define RFIELDS_PER_FLUSH 32 /* records (SETMAP) */
#define LFIELDS_PER_FLUSH 64 /* FPF - lists (SETLIST) */
1997-09-16 12:25:59 -07:00
1999-06-17 10:04:03 -07:00
#define ZEROVARARG 128
1997-09-16 12:25:59 -07:00
/* maximum value of an arg of 3 bytes; must fit in an "int" */
#if MAX_INT < (1<<24)
#define MAX_ARG MAX_INT
#else
#define MAX_ARG ((1<<24)-1)
#endif
1999-12-27 09:33:22 -08:00
/* maximum value of a word of 2 bytes; cannot be larger than MAX_ARG */
#if MAX_ARG < (1<<16)
#define MAX_WORD MAX_ARG
#else
#define MAX_WORD ((1<<16)-1)
#endif
/* maximum value of a byte */
#define MAX_BYTE ((1<<8)-1)
1997-09-16 12:25:59 -07:00
#endif