Skip to content

Instantly share code, notes, and snippets.

@neomantra
Created April 10, 2014 15:00
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neomantra/10391366 to your computer and use it in GitHub Desktop.
Save neomantra/10391366 to your computer and use it in GitHub Desktop.
Convert LuaJIT bytecode number to name.
-- Converts a LuaJIT bytecode number to name
--
-- usage: luajit bcname.lua bytecode_number [bytecode_number2 [...]]
--
-- example:
-- $ luajit-2.1 bcname.lua 71 72
-- VARG
-- ISNEXT
--
-- From: http://www.freelists.org/post/luajit/frames-and-tail-calls,1
local function bcnumber_to_name( bcnum )
if not bcnum then return '' end
return string.sub(require("jit.vmdef").bcnames, bcnum*6+1, bcnum*6+6)
end
for _, v in ipairs(arg) do
print(bcnumber_to_name(tonumber(v)))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment