a04df2d17d
benilla-lua now matches the client's Lua 5.0 wherever an addon can see the difference: - Number keys hash as `hashnum` does (`0x6fa260`), so `pairs` walks them in the client's order. - Calls nest at most 4096 deep (`0x6f61c0`). - `^` calls the global `__pow` (`0x6f9b5e`). - The parser's limits and messages are the client's (`0x6ff440`); the client has no assignment limit. - A numeric for's variable is its counter (`0x6fe380`, `0x6f9262`). - A generic for uses `forlist`'s layout (`0x6fe540`): the first name is the control, and closures share the variables. - Only calls name a callee (`0x6fc499`), and a stray token reports `<eof> expected` (`0x871cf4`). Each fix has a test that fails without it. Two audits re-derived every address from the bytes. The bench is faster or level. Fixes #1369 Fixes #1370 Fixes #1371 Fixes #1372 Fixes #1374 Fixes #1377 Fixes #1752 Fixes #1753 Fixes #1754 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
21 lines
660 B
Rust
21 lines
660 B
Rust
//! Prints the bytecode of a chunk and its functions: `cargo run --example dis -- '<lua>'`.
|
|
fn dump(p: &benilla_lua::proto::Proto, depth: usize) {
|
|
let pad = " ".repeat(depth);
|
|
println!(
|
|
"{pad}function {} (params {}, maxstack {})",
|
|
p.key, p.nparams, p.maxstack
|
|
);
|
|
for (i, op) in p.code.iter().enumerate() {
|
|
println!("{pad} {i:3} {op:?}");
|
|
}
|
|
for q in &p.protos {
|
|
dump(q, depth + 1);
|
|
}
|
|
}
|
|
fn main() {
|
|
let src = std::env::args().nth(1).unwrap();
|
|
let mut heap = benilla_lua::heap::Heap::default();
|
|
let p = benilla_lua::compile(src.as_bytes(), b"=dis", &mut heap).unwrap();
|
|
dump(&p, 0);
|
|
}
|