dump_stack can now read boolean and number types

This commit is contained in:
William Venner 2021-09-21 18:18:43 +01:00
parent d47174601a
commit 460cb0920f
1 changed files with 12 additions and 2 deletions

View File

@ -396,7 +396,6 @@ impl LuaState {
None None
} }
#[cfg(debug_assertions)]
pub unsafe fn dump_stack(&self) { pub unsafe fn dump_stack(&self) {
let top = self.get_top(); let top = self.get_top();
println!("\n=== STACK DUMP ==="); println!("\n=== STACK DUMP ===");
@ -411,13 +410,24 @@ impl LuaState {
self.pop(); self.pop();
str str
}), }),
"boolean" => println!("{}. {}: {:?}", i, lua_type_name, {
self.push_value(i);
let bool = self.get_boolean(-1);
self.pop();
bool
}),
"number" => println!("{}. {}: {:?}", i, lua_type_name, {
self.push_value(i);
let n = self.to_number(-1);
self.pop();
n
}),
_ => println!("{}. {}", i, lua_type_name), _ => println!("{}. {}", i, lua_type_name),
} }
} }
println!(); println!();
} }
#[cfg(debug_assertions)]
pub unsafe fn dump_val(&self, index: i32) -> String { pub unsafe fn dump_val(&self, index: i32) -> String {
let lua_type_name = self.lua_type_name(self.lua_type(index)); let lua_type_name = self.lua_type_name(self.lua_type(index));
match lua_type_name.as_ref() { match lua_type_name.as_ref() {