From b574ecc4cbe805cb4a6c3d7e62a58aa144d682e2 Mon Sep 17 00:00:00 2001 From: Jeff Date: Thu, 28 Nov 2024 02:12:59 -0500 Subject: [PATCH] Clean up --- dust-lang/src/compiler.rs | 4 ++-- dust-lang/src/disassembler.rs | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/dust-lang/src/compiler.rs b/dust-lang/src/compiler.rs index 687bdb1..188b55d 100644 --- a/dust-lang/src/compiler.rs +++ b/dust-lang/src/compiler.rs @@ -194,13 +194,13 @@ impl<'src> Compiler<'src> { let identifier = ConcreteValue::string(identifier); let identifier_index = self.chunk.push_or_get_constant(identifier); - let local_index = self.chunk.locals().len(); + let local_index = self.chunk.locals().len() as u16; self.chunk .locals_mut() .push(Local::new(identifier_index, r#type, is_mutable, scope)); - (local_index as u16, identifier_index) + (local_index, identifier_index) } fn allow(&mut self, allowed: Token) -> Result { diff --git a/dust-lang/src/disassembler.rs b/dust-lang/src/disassembler.rs index e98d599..619e39c 100644 --- a/dust-lang/src/disassembler.rs +++ b/dust-lang/src/disassembler.rs @@ -50,8 +50,8 @@ use crate::{value::ConcreteValue, Chunk, Local}; const INSTRUCTION_HEADER: [&str; 4] = [ "Instructions", "------------", - " i POSITION OPERATION TYPE INFO ", - "--- ---------- ------------- ---------------- ----------------------------------", + " i POSITION OPERATION TYPE INFO ", + "--- ---------- ------------- -------------------------------- --------------------------------", ]; const CONSTANT_HEADER: [&str; 4] = [ @@ -64,8 +64,8 @@ const CONSTANT_HEADER: [&str; 4] = [ const LOCAL_HEADER: [&str; 4] = [ "Locals", "------", - " i SCOPE MUTABLE TYPE IDENTIFIER ", - "--- ------- ------- ---------------- ----------------", + " i SCOPE MUTABLE TYPE IDENTIFIER ", + "--- ------- ------- -------------------------------- ----------------", ]; /// Builder that constructs a human-readable representation of a chunk. @@ -262,7 +262,7 @@ impl<'a> Disassembler<'a> { let r#type = r#type.to_string(); let info = instruction.disassembly_info(); let instruction_display = - format!("{index:^3} {position:^10} {operation:13} {type:^16} {info:^34}"); + format!("{index:^3} {position:^10} {operation:13} {type:^32} {info:^32}"); self.push_details(&instruction_display); } @@ -290,8 +290,9 @@ impl<'a> Disassembler<'a> { .map(|value| value.to_string()) .unwrap_or_else(|| "unknown".to_string()); let type_display = r#type.to_string(); + let scope = scope.to_string(); let local_display = format!( - "{index:^3} {scope:7} {is_mutable:^7} {type_display:^16} {identifier_display:^16}" + "{index:^3} {scope:^7} {is_mutable:^7} {type_display:^32} {identifier_display:^16}" ); self.push_details(&local_display);