2001-06-28 23:58:57 +04:00
|
|
|
/*
|
2014-11-02 22:19:04 +03:00
|
|
|
** $Id: lopcodes.c,v 1.53 2013/12/30 20:47:58 roberto Exp roberto $
|
2012-05-14 17:34:18 +04:00
|
|
|
** Opcodes for Lua virtual machine
|
2001-06-28 23:58:57 +04:00
|
|
|
** See Copyright Notice in lua.h
|
|
|
|
*/
|
|
|
|
|
2002-12-04 20:38:31 +03:00
|
|
|
#define lopcodes_c
|
2004-05-01 00:13:38 +04:00
|
|
|
#define LUA_CORE
|
2002-12-04 20:38:31 +03:00
|
|
|
|
2014-11-02 22:19:04 +03:00
|
|
|
#include "lprefix.h"
|
|
|
|
|
2001-06-28 23:58:57 +04:00
|
|
|
|
|
|
|
#include "lopcodes.h"
|
|
|
|
|
|
|
|
|
2003-05-14 16:09:12 +04:00
|
|
|
/* ORDER OP */
|
|
|
|
|
2009-11-19 22:06:52 +03:00
|
|
|
LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = {
|
2001-11-28 23:13:13 +03:00
|
|
|
"MOVE",
|
|
|
|
"LOADK",
|
2011-04-07 22:14:12 +04:00
|
|
|
"LOADKX",
|
2001-12-12 01:48:44 +03:00
|
|
|
"LOADBOOL",
|
2001-11-28 23:13:13 +03:00
|
|
|
"LOADNIL",
|
|
|
|
"GETUPVAL",
|
2010-02-26 23:40:29 +03:00
|
|
|
"GETTABUP",
|
2001-11-28 23:13:13 +03:00
|
|
|
"GETTABLE",
|
2010-02-26 23:40:29 +03:00
|
|
|
"SETTABUP",
|
2001-11-28 23:13:13 +03:00
|
|
|
"SETUPVAL",
|
|
|
|
"SETTABLE",
|
|
|
|
"NEWTABLE",
|
|
|
|
"SELF",
|
|
|
|
"ADD",
|
|
|
|
"SUB",
|
|
|
|
"MUL",
|
2005-03-08 21:00:16 +03:00
|
|
|
"MOD",
|
2001-11-28 23:13:13 +03:00
|
|
|
"POW",
|
2013-12-16 23:06:52 +04:00
|
|
|
"DIV",
|
|
|
|
"IDIV",
|
2013-12-18 18:12:03 +04:00
|
|
|
"BAND",
|
|
|
|
"BOR",
|
|
|
|
"BXOR",
|
2013-12-31 00:47:58 +04:00
|
|
|
"SHL",
|
|
|
|
"SHR",
|
2001-11-28 23:13:13 +03:00
|
|
|
"UNM",
|
2013-12-31 00:47:58 +04:00
|
|
|
"BNOT",
|
2001-11-28 23:13:13 +03:00
|
|
|
"NOT",
|
2005-05-20 19:53:42 +04:00
|
|
|
"LEN",
|
2001-11-28 23:13:13 +03:00
|
|
|
"CONCAT",
|
|
|
|
"JMP",
|
2002-05-06 19:51:41 +04:00
|
|
|
"EQ",
|
2002-06-12 18:56:22 +04:00
|
|
|
"LT",
|
|
|
|
"LE",
|
2002-05-06 19:51:41 +04:00
|
|
|
"TEST",
|
2005-08-30 00:49:21 +04:00
|
|
|
"TESTSET",
|
2001-11-28 23:13:13 +03:00
|
|
|
"CALL",
|
2002-03-21 23:32:22 +03:00
|
|
|
"TAILCALL",
|
2001-11-28 23:13:13 +03:00
|
|
|
"RETURN",
|
|
|
|
"FORLOOP",
|
2003-05-14 00:15:59 +04:00
|
|
|
"FORPREP",
|
2008-10-30 18:39:30 +03:00
|
|
|
"TFORCALL",
|
2010-10-13 20:45:54 +04:00
|
|
|
"TFORLOOP",
|
2001-11-28 23:13:13 +03:00
|
|
|
"SETLIST",
|
2004-05-31 22:51:50 +04:00
|
|
|
"CLOSURE",
|
2004-12-02 15:59:10 +03:00
|
|
|
"VARARG",
|
2008-04-02 21:38:54 +04:00
|
|
|
"EXTRAARG",
|
2004-12-02 15:59:10 +03:00
|
|
|
NULL
|
2001-06-28 23:58:57 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2003-05-14 16:09:12 +04:00
|
|
|
#define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m))
|
2002-03-08 22:10:32 +03:00
|
|
|
|
2009-11-19 22:06:52 +03:00
|
|
|
LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = {
|
2003-05-14 16:09:12 +04:00
|
|
|
/* T A B C mode opcode */
|
2006-09-11 18:07:24 +04:00
|
|
|
opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */
|
2003-05-14 16:09:12 +04:00
|
|
|
,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */
|
2011-04-12 21:27:35 +04:00
|
|
|
,opmode(0, 1, OpArgN, OpArgN, iABx) /* OP_LOADKX */
|
2003-05-14 16:09:12 +04:00
|
|
|
,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */
|
2011-04-19 20:22:13 +04:00
|
|
|
,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_LOADNIL */
|
2003-05-14 16:09:12 +04:00
|
|
|
,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */
|
2010-02-26 23:40:29 +03:00
|
|
|
,opmode(0, 1, OpArgU, OpArgK, iABC) /* OP_GETTABUP */
|
2003-05-14 16:09:12 +04:00
|
|
|
,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_GETTABLE */
|
2010-02-26 23:40:29 +03:00
|
|
|
,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABUP */
|
2003-05-14 16:09:12 +04:00
|
|
|
,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_SETUPVAL */
|
|
|
|
,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABLE */
|
|
|
|
,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_NEWTABLE */
|
|
|
|
,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_SELF */
|
|
|
|
,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_ADD */
|
|
|
|
,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SUB */
|
|
|
|
,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MUL */
|
2005-03-08 21:00:16 +03:00
|
|
|
,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */
|
2003-05-14 16:09:12 +04:00
|
|
|
,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */
|
2013-12-16 23:06:52 +04:00
|
|
|
,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */
|
|
|
|
,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_IDIV */
|
2013-12-18 18:12:03 +04:00
|
|
|
,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BAND */
|
|
|
|
,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BOR */
|
|
|
|
,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BXOR */
|
2013-12-31 00:47:58 +04:00
|
|
|
,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SHL */
|
|
|
|
,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SHR */
|
2003-05-14 16:09:12 +04:00
|
|
|
,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */
|
2013-12-31 00:47:58 +04:00
|
|
|
,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_BNOT */
|
2003-05-14 16:09:12 +04:00
|
|
|
,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */
|
2005-05-20 19:53:42 +04:00
|
|
|
,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */
|
2003-05-14 16:09:12 +04:00
|
|
|
,opmode(0, 1, OpArgR, OpArgR, iABC) /* OP_CONCAT */
|
|
|
|
,opmode(0, 0, OpArgR, OpArgN, iAsBx) /* OP_JMP */
|
|
|
|
,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */
|
|
|
|
,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LT */
|
|
|
|
,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LE */
|
2011-04-12 21:27:35 +04:00
|
|
|
,opmode(1, 0, OpArgN, OpArgU, iABC) /* OP_TEST */
|
2005-08-30 00:49:21 +04:00
|
|
|
,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TESTSET */
|
2003-05-14 16:09:12 +04:00
|
|
|
,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_CALL */
|
|
|
|
,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_TAILCALL */
|
|
|
|
,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_RETURN */
|
|
|
|
,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORLOOP */
|
|
|
|
,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORPREP */
|
2008-10-30 18:39:30 +03:00
|
|
|
,opmode(0, 0, OpArgN, OpArgU, iABC) /* OP_TFORCALL */
|
2010-10-13 20:45:54 +04:00
|
|
|
,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_TFORLOOP */
|
2004-10-04 23:01:53 +04:00
|
|
|
,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */
|
2003-05-14 16:09:12 +04:00
|
|
|
,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */
|
2004-05-31 22:51:50 +04:00
|
|
|
,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */
|
2008-04-02 21:38:54 +04:00
|
|
|
,opmode(0, 0, OpArgU, OpArgU, iAx) /* OP_EXTRAARG */
|
2001-06-28 23:58:57 +04:00
|
|
|
};
|
|
|
|
|