Created
April 10, 2014 15:00
-
-
Save neomantra/10391366 to your computer and use it in GitHub Desktop.
Convert LuaJIT bytecode number to name.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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