Add bytcode to dissassembly
This commit is contained in:
parent
be77d64c39
commit
dee09d3583
@ -288,8 +288,8 @@ impl<'a> ChunkDisassembler<'a> {
|
|||||||
"",
|
"",
|
||||||
"Instructions",
|
"Instructions",
|
||||||
"------------",
|
"------------",
|
||||||
"INDEX OPERATION INFO POSITION",
|
"INDEX BYTECODE OPERATION INFO POSITION",
|
||||||
"----- --------------- ------------------------------ --------",
|
"----- -------- --------------- ------------------------------ --------",
|
||||||
];
|
];
|
||||||
|
|
||||||
const CONSTANT_HEADER: [&'static str; 5] = [
|
const CONSTANT_HEADER: [&'static str; 5] = [
|
||||||
@ -377,11 +377,15 @@ impl<'a> ChunkDisassembler<'a> {
|
|||||||
let position = position.to_string();
|
let position = position.to_string();
|
||||||
let operation = instruction.operation().to_string();
|
let operation = instruction.operation().to_string();
|
||||||
let info_option = instruction.disassembly_info(Some(self.chunk));
|
let info_option = instruction.disassembly_info(Some(self.chunk));
|
||||||
|
let bytecode = u32::from(instruction);
|
||||||
|
|
||||||
let instruction_display = if let Some(info) = info_option {
|
let instruction_display = if let Some(info) = info_option {
|
||||||
format!("{index:<5} {operation:15} {info:30} {position:8}")
|
format!("{index:<5} {bytecode:<8X} {operation:15} {info:30} {position:8}")
|
||||||
} else {
|
} else {
|
||||||
format!("{index:<5} {operation:15} {:30} {position:8}", " ")
|
format!(
|
||||||
|
"{index:<5} {bytecode:<8X} {operation:15} {:30} {position:8}",
|
||||||
|
" "
|
||||||
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
disassembly.push_str(¢er(&instruction_display));
|
disassembly.push_str(¢er(&instruction_display));
|
||||||
|
@ -528,6 +528,12 @@ impl Display for Instruction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<&Instruction> for u32 {
|
||||||
|
fn from(instruction: &Instruction) -> Self {
|
||||||
|
instruction.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
Loading…
Reference in New Issue
Block a user