Prettified the debug output
This commit is contained in:
parent
53929b5dfe
commit
4c43e9290f
2 changed files with 10 additions and 2 deletions
|
@ -669,7 +669,7 @@ impl JVM {
|
||||||
|
|
||||||
//println!("{} locals: {:?}", " ".repeat(frame_index), frame.locals);
|
//println!("{} locals: {:?}", " ".repeat(frame_index), frame.locals);
|
||||||
println!("{} stack: {:?}", " ".repeat(frame_index), frame.operand_stack);
|
println!("{} stack: {:?}", " ".repeat(frame_index), frame.operand_stack);
|
||||||
println!("{}{:25}.{:15}:{:<10}{instruction:?}\n", " ".repeat(frame_index), class.get_classname().unwrap(), method.name, frame.instruction_pointer);
|
println!("{}{}.{}:{:<10}{instruction:?}\n", " ".repeat(frame_index), class.get_classname().unwrap(), method.name, frame.instruction_pointer);
|
||||||
|
|
||||||
match instruction {
|
match instruction {
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use core::fmt::Debug;
|
||||||
use crate::accessmasks::MethodAccessFlag;
|
use crate::accessmasks::MethodAccessFlag;
|
||||||
use crate::classfile::{ AttributeData, JavaClassFile };
|
use crate::classfile::{ AttributeData, JavaClassFile };
|
||||||
use crate::heap_area::{ ObjectReference, FieldValue };
|
use crate::heap_area::{ ObjectReference, FieldValue };
|
||||||
|
@ -19,12 +20,19 @@ pub enum StackValue {
|
||||||
Empty(),
|
Empty(),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct OperandStack {
|
pub struct OperandStack {
|
||||||
stack: Box<[StackValue]>,
|
stack: Box<[StackValue]>,
|
||||||
depth: u16,
|
depth: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Debug for OperandStack {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
f.debug_list()
|
||||||
|
.entries(self.stack.iter().take(self.depth as usize))
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
PushError(String),
|
PushError(String),
|
||||||
|
|
Loading…
Reference in a new issue