From 460cb0920f832f689ab8abc08cea0dea675e8f39 Mon Sep 17 00:00:00 2001 From: William Venner Date: Tue, 21 Sep 2021 18:18:43 +0100 Subject: [PATCH] dump_stack can now read boolean and number types --- gmod/src/lua/lua_state.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gmod/src/lua/lua_state.rs b/gmod/src/lua/lua_state.rs index a4c5acd..93ec317 100644 --- a/gmod/src/lua/lua_state.rs +++ b/gmod/src/lua/lua_state.rs @@ -396,7 +396,6 @@ impl LuaState { None } - #[cfg(debug_assertions)] pub unsafe fn dump_stack(&self) { let top = self.get_top(); println!("\n=== STACK DUMP ==="); @@ -411,13 +410,24 @@ impl LuaState { self.pop(); 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!(); } - #[cfg(debug_assertions)] pub unsafe fn dump_val(&self, index: i32) -> String { let lua_type_name = self.lua_type_name(self.lua_type(index)); match lua_type_name.as_ref() {