From f54d2d0d22987f6e6522d3aafb3d13e2d55e8f8c Mon Sep 17 00:00:00 2001 From: Jeff Date: Thu, 7 Nov 2024 00:49:36 -0500 Subject: [PATCH] Clean up --- dust-lang/src/disassembler.rs | 2 +- dust-lang/src/native_function.rs | 8 ++++++++ dust-lang/src/value.rs | 32 ++++++++++++++++---------------- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/dust-lang/src/disassembler.rs b/dust-lang/src/disassembler.rs index 0a7be92..9c17e1d 100644 --- a/dust-lang/src/disassembler.rs +++ b/dust-lang/src/disassembler.rs @@ -353,7 +353,7 @@ impl<'a> Disassembler<'a> { .indent(self.indent + 1) .disassemble(); - self.push_details(&function_disassembly); + self.output.push_str(&function_disassembly); } } diff --git a/dust-lang/src/native_function.rs b/dust-lang/src/native_function.rs index 80d5052..4cab885 100644 --- a/dust-lang/src/native_function.rs +++ b/dust-lang/src/native_function.rs @@ -52,6 +52,14 @@ macro_rules! define_native_function { )* } } + + pub fn returns_value(&self) -> bool { + match self { + $( + NativeFunction::$name => $type.return_type.is_some(), + )* + } + } } impl From for NativeFunction { diff --git a/dust-lang/src/value.rs b/dust-lang/src/value.rs index b39dc83..b6d2db2 100644 --- a/dust-lang/src/value.rs +++ b/dust-lang/src/value.rs @@ -344,6 +344,22 @@ impl Display for Value { } } +/// Value representation that can be resolved to a concrete value by the VM. +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] +pub enum AbstractValue { + List { start: u8, end: u8, item_type: Type }, +} + +impl Display for AbstractValue { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + match self { + AbstractValue::List { start, end, .. } => { + write!(f, "List [R{}..=R{}]", start, end) + } + } + } +} + #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] pub enum ConcreteValue { Boolean(bool), @@ -714,22 +730,6 @@ impl Ord for RangeValue { } } -/// Value representation that can be resolved to a concrete value by the VM. -#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] -pub enum AbstractValue { - List { start: u8, end: u8, item_type: Type }, -} - -impl Display for AbstractValue { - fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - match self { - AbstractValue::List { start, end, .. } => { - write!(f, "List [R{}..=R{}]", start, end) - } - } - } -} - #[derive(Clone, Debug, PartialEq)] pub enum ValueError { CannotAdd(Value, Value),