From 082981f2037022559b7717cc539b2f82a53c7017 Mon Sep 17 00:00:00 2001 From: teascade Date: Sun, 5 Jul 2020 22:56:11 +0300 Subject: [PATCH] Fix warnings --- src/file_io.rs | 8 ++++---- src/main.rs | 1 + src/vm/compiled.rs | 2 -- src/vm/mod.rs | 6 +++--- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/file_io.rs b/src/file_io.rs index 05abb00..cc3ff91 100644 --- a/src/file_io.rs +++ b/src/file_io.rs @@ -19,8 +19,8 @@ pub fn open_source(path: &Path) -> Result { #[cfg(feature = "compiler")] pub fn into_bytecode(compiled: &CompiledReid) -> Vec { let mut list = Vec::new(); - let iter = compiled.list.iter(); - for item in iter { + let cloned = compiled.list.clone().into_iter(); + for item in cloned { list.append(&mut item.into_u8()); } list @@ -50,7 +50,7 @@ pub fn open_bytecode(path: &Path) -> Result { impl VariableType { #[cfg(feature = "compiler")] - fn into_u8(&self) -> u8 { + fn into_u8(self) -> u8 { match self { VariableType::TypeString => 0, VariableType::TypeI32 => 1, @@ -139,7 +139,7 @@ impl Command { } #[cfg(feature = "compiler")] - fn into_u8(&self) -> Vec { + fn into_u8(self) -> Vec { let mut list = Vec::new(); list.push(self.id()); match &self { diff --git a/src/main.rs b/src/main.rs index 1749f6c..bfc73f6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -96,6 +96,7 @@ fn main() { fn run_bytecode(run_path: &Path, builtin_functions: BuiltinFunctions) { let compiled = open_bytecode(run_path); + dbg!(&compiled); match compiled { Ok(compiled) => run(compiled, builtin_functions), Err(error) => { diff --git a/src/vm/compiled.rs b/src/vm/compiled.rs index 5dc4bfb..8ec85d7 100644 --- a/src/vm/compiled.rs +++ b/src/vm/compiled.rs @@ -1,8 +1,6 @@ use std::fmt; use std::fmt::Display; -use std::ops::{Add, Sub}; - pub type FuncID = u16; pub type HeapID = u16; pub type RegID = u8; diff --git a/src/vm/mod.rs b/src/vm/mod.rs index baa39d6..3b76270 100644 --- a/src/vm/mod.rs +++ b/src/vm/mod.rs @@ -155,7 +155,7 @@ impl VirtualMachine { let val2 = self.pop_stack()?; let res = val2.add(val1); if let Some(res) = res { - self.push_stack(res); + self.push_stack(res)?; Ok(()) } else { Err(RuntimePanic::AttemptedInvalidArithmeticOperation) @@ -166,7 +166,7 @@ impl VirtualMachine { let val2 = self.pop_stack()?; let res = val2.sub(val1); if let Some(res) = res { - self.push_stack(res); + self.push_stack(res)?; Ok(()) } else { Err(RuntimePanic::AttemptedInvalidArithmeticOperation) @@ -177,7 +177,7 @@ impl VirtualMachine { let val2 = self.pop_stack()?; let res = val2.mul(val1); if let Some(res) = res { - self.push_stack(res); + self.push_stack(res)?; Ok(()) } else { Err(RuntimePanic::AttemptedInvalidArithmeticOperation)