mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Lua 5.3 adds several awesome features of particular interest to nmap including bitwise operators and integers, a utf8 library, and standard binary pack/unpack functions. In addition to adding Lua 5.3, this branch changes: o Complete removal of the NSE bit library (in C), It has been replaced with a new Lua library wrapping Lua 5.3's bit-wise operators. o Complete removal of the NSE bin library (in C). It has been replaced with a new Lua library wrapping Lua 5.3's string.pack|unpack functions. o The bin.pack "B" format specifier (which has never worked correctly) is unimplemented. All scripts/libraries which use it have been updated. Most usage of this option was to allow string based bit-wise operations which are no longer necessary now that Lua 5.3 provides integers and bit-wise operators. o The base32/base64 libraries have been reimplemented using Lua 5.3's new bitwise operators. (This library was the main user of the bin.pack "B" format specifier.) o A new "bits" library has been added for common bit hacks. Currently only has a reverse function. Thanks to David Fifield, Daniel Miller, Jacek Wielemborek, and Paulino Calderon for testing this branch.
125 lines
3.5 KiB
C
125 lines
3.5 KiB
C
/*
|
|
** $Id: lopcodes.c,v 1.55 2015/01/05 13:48:33 roberto Exp $
|
|
** Opcodes for Lua virtual machine
|
|
** See Copyright Notice in lua.h
|
|
*/
|
|
|
|
#define lopcodes_c
|
|
#define LUA_CORE
|
|
|
|
#include "lprefix.h"
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include "lopcodes.h"
|
|
|
|
|
|
/* ORDER OP */
|
|
|
|
LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = {
|
|
"MOVE",
|
|
"LOADK",
|
|
"LOADKX",
|
|
"LOADBOOL",
|
|
"LOADNIL",
|
|
"GETUPVAL",
|
|
"GETTABUP",
|
|
"GETTABLE",
|
|
"SETTABUP",
|
|
"SETUPVAL",
|
|
"SETTABLE",
|
|
"NEWTABLE",
|
|
"SELF",
|
|
"ADD",
|
|
"SUB",
|
|
"MUL",
|
|
"MOD",
|
|
"POW",
|
|
"DIV",
|
|
"IDIV",
|
|
"BAND",
|
|
"BOR",
|
|
"BXOR",
|
|
"SHL",
|
|
"SHR",
|
|
"UNM",
|
|
"BNOT",
|
|
"NOT",
|
|
"LEN",
|
|
"CONCAT",
|
|
"JMP",
|
|
"EQ",
|
|
"LT",
|
|
"LE",
|
|
"TEST",
|
|
"TESTSET",
|
|
"CALL",
|
|
"TAILCALL",
|
|
"RETURN",
|
|
"FORLOOP",
|
|
"FORPREP",
|
|
"TFORCALL",
|
|
"TFORLOOP",
|
|
"SETLIST",
|
|
"CLOSURE",
|
|
"VARARG",
|
|
"EXTRAARG",
|
|
NULL
|
|
};
|
|
|
|
|
|
#define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m))
|
|
|
|
LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = {
|
|
/* T A B C mode opcode */
|
|
opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */
|
|
,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */
|
|
,opmode(0, 1, OpArgN, OpArgN, iABx) /* OP_LOADKX */
|
|
,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */
|
|
,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_LOADNIL */
|
|
,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */
|
|
,opmode(0, 1, OpArgU, OpArgK, iABC) /* OP_GETTABUP */
|
|
,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_GETTABLE */
|
|
,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABUP */
|
|
,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 */
|
|
,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */
|
|
,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */
|
|
,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */
|
|
,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_IDIV */
|
|
,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BAND */
|
|
,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BOR */
|
|
,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BXOR */
|
|
,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SHL */
|
|
,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SHR */
|
|
,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */
|
|
,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_BNOT */
|
|
,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */
|
|
,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */
|
|
,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 */
|
|
,opmode(1, 0, OpArgN, OpArgU, iABC) /* OP_TEST */
|
|
,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TESTSET */
|
|
,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 */
|
|
,opmode(0, 0, OpArgN, OpArgU, iABC) /* OP_TFORCALL */
|
|
,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_TFORLOOP */
|
|
,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */
|
|
,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */
|
|
,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */
|
|
,opmode(0, 0, OpArgU, OpArgU, iAx) /* OP_EXTRAARG */
|
|
};
|
|
|