更酷的名字是:修改 Lua 虚拟机,修改 Lua 字节码顺序
使用的是 Lua 5.1.5 版本:
修改两个文件 lopcodes.h & lopcodes.c :
/*
** grep "ORDER OP" if you change these enums #老外还是很有意思的
*/
typedef enum {
/*----------------------------------------------------------------------
name args description
------------------------------------------------------------------------*/
OP_ADD,/* A B C R(A) := RK(B) + RK(C) */
OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */
/* ORDER OP */
const char *const luaP_opnames[NUM_OPCODES+1] = {
"ADD",
"CALL",
"MOVE",
测试的 lua 文件:
print('hello')
function p(...)
local b = 2+1 *3/5
print('qt',b)
end
p('b'