lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

I've attached the pure Lua bytecode parser from a personal project.
Rough usage might look like:

local top_level_function = undump.chunk(zio.read_string(data)).proto
for i, opcode in ipairs(top_level_function.code) do
  print(, opcode.a, opcode.b, opcode.c)
-- Sub-functions are stored in the array top_level_function.prototypes
-- Constants (as referenced by [SG]ETGLOBAL's b field) are in the
array top_level_function.constants


On Mon, Mar 22, 2010 at 11:38 PM, Alexander Gladysh <> wrote:
> Hi, list!
> I have a variable, containing Lua function value.
> I want to dump bytecode for that function and get a list of
> GET/SETGLOBAL ops along with their arguments. I want to do this
> programmatically, from the same Lua state that function is loaded in.
> While I do have the source of a function, I do not want to use Metalua
> for that analysis — that dependency would be too heavy for what I'm
> doing.
> I remember seeing some Lua bytecode parser module somewhere — but
> can't find it now. Any clues?
> Alexander.

Description: Zip archive