lua-users home
lua-l archive

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


> If I wanted to write my own (or adapt other's efforts), I'd clearly 
> need an understanding of the lua byte code dumped format.

I don't see why a Lua lint would need to look into the bytecode; don't
lints usually parse the source? Of course, in the case of Lua it's easier
to look into the bytecode because no parser tool exists for Lua. As I said
before here, I wish it were easy to reuse the Lua parser, as it is easy to
reuse the lexer (see my ltokens).

> 1) Is there documentation on the lua 5 dump format?

No. The only documentation is the source: ldump.c, which is pretty simple,
really. Written docs would probably get out of date between versions.

Anyway, the format is simply a header followed by a function. The function
is dumped as a header plus lines, locals, upvalues (all three just debug
info) plus the constants used in the functions (number, strings, functions)
plus the actual bytecode. Note the recursion.

The easiest way to process bytecode is to process listings, as produced
by luac -l. (Actually, I'm trying an experimental "unlister", which does
what ludump does, except it reads listings, not binary chunks. This will
be a primitive assembler then...)

--lhf