From b95c47312153a7cb8d504cb6617fa4e5a26e886a Mon Sep 17 00:00:00 2001 From: Daniel Watkins Date: Tue, 31 Jul 2018 23:32:46 -0400 Subject: [PATCH] Output locals mapping in trace logging The Locals line in the Frame Object output is now, for example: Locals: {"num": RefCell { value: [PyObj int 9] }, "f": RefCell { value: [PyObj function] }} --- vm/src/frame.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/vm/src/frame.rs b/vm/src/frame.rs index 5b54794be..087dc7e41 100644 --- a/vm/src/frame.rs +++ b/vm/src/frame.rs @@ -114,11 +114,16 @@ impl fmt::Debug for Frame { .map(|elem| format!("\n > {:?}", elem)) .collect::>() .join(""); - let local_str = "".to_string(); /* self.locals - .iter() - .map(|elem| format!("\n {} = {}", elem.0, elem.1.borrow_mut().str())) - .collect::>() - .join(""); */ + let local_str = match self.locals.borrow().kind { + PyObjectKind::Scope { ref scope } => match scope.locals.borrow().kind { + PyObjectKind::Dict { ref elements } => format!(" {:?}", elements), + ref unexpected => format!( + "locals unexpectedly not wrapping a dict! instead: {:?}", + unexpected + ), + }, + ref unexpected => format!("locals unexpectedly not a scope! instead: {:?}", unexpected), + }; write!( f, "Frame Object {{ \n Stack:{}\n Blocks:{}\n Locals:{}\n}}",