Skip to content

Commit

Permalink
style: opt lua bytecodes print
Browse files Browse the repository at this point in the history
  • Loading branch information
sbwtw committed Feb 29, 2024
1 parent 795ae29 commit 3ccac45
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
15 changes: 15 additions & 0 deletions lib/src/backend/lua/dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ impl CompiledCode for LuaCode {
// TODO: maxstacksize
lua_dump_byte(w, 0)?;

// Dump Code

// Dump Constants

// Dump UpValues

// Dump Protos

// Dump Debug

Ok(())
}
}
Expand All @@ -129,5 +139,10 @@ mod test {
lua_dump_size(&mut buf, 128).unwrap();
assert_eq!(0x01, buf[0]);
assert_eq!(0x80, buf[1]);

let mut buf = vec![0u8; 0];
lua_dump_size(&mut buf, 668).unwrap();
assert_eq!(0x05, buf[0]);
assert_eq!(0x9c, buf[1]);
}
}
10 changes: 9 additions & 1 deletion viewer/src/stc_viewer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,15 @@ impl StcViewerApp {
let mut buf = vec![0u8; 0];
lua_dump_function(func, &mut buf).unwrap();

println!("{:0>2x?}", buf);
for (i, v) in buf.iter().enumerate() {
print!("{:0>2x} ", v);

if i % 16 == 15 {
println!();
}
}

println!()
}
}

Expand Down

0 comments on commit 3ccac45

Please sign in to comment.