d6655d8c10
benilla-lua is a Lua 5.1.5 interpreter in Rust that speaks the 1.12.1 client's grammar. It is opt-in behind the `benilla-vm` feature, with `benilla-mlua`, the slice of mlua that benilla-ui uses, over it. The C build stays the default. Its front end ports 5.1.5's `lparser.c` and `lcode.c`, so registers, limits and messages match the C build's. Our finish on top: - the collector counts growth as C does, off the write path; - frames under a leaky generic `for` start nil, as `luaD_precall`; - the budget hook counts what C dispatches, and costs nothing when unset; - `__index` chains stop at 100; - mlua 0.11's conversions; - `vm_parity` answers recorded per platform. Tests: `vm_parity` on both VMs; the front-end corpus (8,543 chunks) against `string.dump`; 7,613 app and UI tests on benilla-lua. Built on macOS; Linux by CI. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Sam <samuv.eth@gmail.com>
21 lines
663 B
Rust
21 lines
663 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, 0).unwrap();
|
|
dump(&p, 0);
|
|
}
|