Fix dis.dis to prints inner constant codes like CPython

This commit is contained in:
Jeong YunWon committed 2020-09-21 06:09:55 +09:00
1 parent 04e7b5ada4
commit 9e78ec9ef9
4 files changed
+14 -3

No files matched your search

+11 -1
View File
@@ -488,7 +488,17 @@ impl CodeObject {
impl fmt::Display for CodeObject {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.display_inner(f, false, 1)
self.display_inner(f, false, 1)?;
for constant in self.get_constants() {
match constant {
Constant::Code { code } => {
write!(f, "\nDisassembly of {}\n", constant)?;
code.fmt(f)?;
}
_ => continue,
}
}
Ok(())
}
}