diff --git a/dust-lang/src/chunk.rs b/dust-lang/src/chunk.rs index a87cbb2..470b6df 100644 --- a/dust-lang/src/chunk.rs +++ b/dust-lang/src/chunk.rs @@ -288,8 +288,8 @@ impl<'a> ChunkDisassembler<'a> { "", "Instructions", "------------", - "INDEX OPERATION INFO POSITION", - "----- --------------- ------------------------------ --------", + "INDEX BYTECODE OPERATION INFO POSITION", + "----- -------- --------------- ------------------------------ --------", ]; const CONSTANT_HEADER: [&'static str; 5] = [ @@ -377,11 +377,15 @@ impl<'a> ChunkDisassembler<'a> { let position = position.to_string(); let operation = instruction.operation().to_string(); let info_option = instruction.disassembly_info(Some(self.chunk)); + let bytecode = u32::from(instruction); 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 { - format!("{index:<5} {operation:15} {:30} {position:8}", " ") + format!( + "{index:<5} {bytecode:<8X} {operation:15} {:30} {position:8}", + " " + ) }; disassembly.push_str(¢er(&instruction_display)); diff --git a/dust-lang/src/instruction.rs b/dust-lang/src/instruction.rs index 4694f83..6178f54 100644 --- a/dust-lang/src/instruction.rs +++ b/dust-lang/src/instruction.rs @@ -528,6 +528,12 @@ impl Display for Instruction { } } +impl From<&Instruction> for u32 { + fn from(instruction: &Instruction) -> Self { + instruction.0 + } +} + #[cfg(test)] mod tests { use super::*;