Skip to content

Commit

Permalink
When disassembling, give the operator more space and also print the u…
Browse files Browse the repository at this point in the history
…uid of the call target.
  • Loading branch information
Ivorforce committed Jul 16, 2024
1 parent 28a29d9 commit 587245c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/interpreter/disassembler.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::mem::transmute;
use std::ptr::read_unaligned;
use uuid::Uuid;
use crate::interpreter::chunks::Chunk;
use crate::interpreter::opcode::{OpCode, Primitive};

Expand All @@ -19,7 +20,7 @@ pub fn disassemble_one(ip: *const u8) -> usize {
unsafe {
let code = transmute::<u8, OpCode>(*ip);
// TODO Somehow, {:<20?} doesn't pad correctly.
print!("{:<15}", format!("{:?}", code));
print!("{:<20}", format!("{:?}", code));

match code {
OpCode::NEG | OpCode::ADD | OpCode::SUB | OpCode::MUL | OpCode::DIV |
Expand Down Expand Up @@ -48,7 +49,11 @@ pub fn disassemble_one(ip: *const u8) -> usize {
print!("\t{:?}", read_unaligned(ip.add(1) as *mut i32));
return 1 + 4;
}
OpCode::NOOP | OpCode::PANIC | OpCode::RETURN | OpCode::CALL | OpCode::TRANSPILE_ADD | OpCode::AND |
OpCode::CALL => {
print!("\t{}", Uuid::from_u128(read_unaligned(ip.add(1) as *mut u128)));
return 1 + 16;
}
OpCode::NOOP | OpCode::PANIC | OpCode::RETURN | OpCode::TRANSPILE_ADD | OpCode::AND |
OpCode::OR | OpCode::POP64 | OpCode::PRINT | OpCode::NOT |
OpCode::ADD_STRING | OpCode::DUP64 | OpCode::LOAD0 | OpCode::SWAP64 => {
return 1;
Expand Down

0 comments on commit 587245c

Please sign in to comment.