From 1ef5ddc01348357fbeeb68b2c3b5baae57a7a02e Mon Sep 17 00:00:00 2001 From: Jeff Date: Fri, 29 Nov 2024 18:10:03 -0500 Subject: [PATCH] Tweak example and native function logic --- dust-lang/src/compiler.rs | 2 ++ dust-lang/src/instruction/mod.rs | 12 ++++++------ dust-lang/src/native_function/logic.rs | 8 -------- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/dust-lang/src/compiler.rs b/dust-lang/src/compiler.rs index 662fe2e..ddc52f4 100644 --- a/dust-lang/src/compiler.rs +++ b/dust-lang/src/compiler.rs @@ -778,6 +778,8 @@ impl<'src> Compiler<'src> { }); } + if let Some([Operation::Test, Operation::Jump]) = self.get_last_operations() {} + let (argument, push_back) = self.handle_binary_argument(&left_instruction)?; if push_back { diff --git a/dust-lang/src/instruction/mod.rs b/dust-lang/src/instruction/mod.rs index e7c03f6..fa8a82a 100644 --- a/dust-lang/src/instruction/mod.rs +++ b/dust-lang/src/instruction/mod.rs @@ -686,10 +686,10 @@ impl Instruction { function, argument_count, } = Call::from(self); - let first_argument = destination.index().saturating_sub(argument_count); - let last_argument = destination.index() - 1; + let arguments_start = destination.index().saturating_sub(argument_count); + let arguments_end = arguments_start + argument_count; - format!("{destination} = {function}(R{first_argument}..=R{last_argument})") + format!("{destination} = {function}(R{arguments_start}..R{arguments_end})") } Operation::CallNative => { let CallNative { @@ -697,10 +697,10 @@ impl Instruction { function, argument_count, } = CallNative::from(self); - let first_argument = destination.index().saturating_sub(argument_count); - let last_argument = destination.index() - 1; + let arguments_start = destination.index().saturating_sub(argument_count); + let arguments_end = arguments_start + argument_count; - format!("{destination} = {function}(R{first_argument}..=R{last_argument})") + format!("{destination} = {function}(R{arguments_start}..R{arguments_end})") } Operation::Return => { let Return { diff --git a/dust-lang/src/native_function/logic.rs b/dust-lang/src/native_function/logic.rs index b250fc1..1dae66d 100644 --- a/dust-lang/src/native_function/logic.rs +++ b/dust-lang/src/native_function/logic.rs @@ -104,10 +104,6 @@ pub fn write<'a>(vm: &'a Vm<'a>, instruction: Instruction) -> Result(vm: &'a Vm<'a>, instruction: Instruction) -> Result