Skip to content

Commit

Permalink
Renamed BlockDbg to Disassembler
Browse files Browse the repository at this point in the history
Also some last module / namespace cleanups and changes for Block and Disassembler
  • Loading branch information
patbuc committed Nov 8, 2023
1 parent b92a102 commit ba518ae
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
7 changes: 4 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
mod vm;

#[cfg(feature = "disassemble")]
use crate::vm::block::disassemble::BlockDbg;
use colored::Colorize;

use crate::vm::block::{Block, OpCode};
use colored::Colorize;

#[cfg(feature = "disassemble")]
use crate::vm::block::Disassembler;

fn main() {
println!(
Expand Down
4 changes: 2 additions & 2 deletions src/vm/block/disassemble.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use crate::vm::block::{Block, OpCode};
use num_traits::FromPrimitive;

pub trait BlockDbg {
pub trait Disassembler {
fn disassemble_block(&self);
fn disassemble_instruction(&self, offset: usize, line: usize) -> usize;
fn simple_instruction(&self, op_code: OpCode, offset: usize) -> usize;
fn constant_instruction(&self, op_code: OpCode, offset: usize) -> usize;
}

impl BlockDbg for Block {
impl Disassembler for Block {
fn disassemble_block(&self) {
println!();
println!("=== <{}> ===", self.name);
Expand Down
12 changes: 8 additions & 4 deletions src/vm/block/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
pub(crate) mod constants;
mod constants;

#[cfg(feature = "disassemble")]
pub(crate) mod disassemble;
#[cfg(test)]
mod tests;
mod disassemble;
#[cfg(feature = "disassemble")]
pub(crate) use crate::vm::block::disassemble::Disassembler;

use crate::vm::block::constants::Constants;
use enum_primitive_derive::Primitive;
Expand Down Expand Up @@ -86,3 +87,6 @@ impl Block {
(byte4 << 24) | (byte3 << 16) | (byte2 << 8) | byte1
}
}

#[cfg(test)]
mod tests;

0 comments on commit ba518ae

Please sign in to comment.