Fix warnings

This commit is contained in:
Sofia 2020-07-05 22:56:11 +03:00
parent 00619f09fd
commit 082981f203
4 changed files with 8 additions and 9 deletions

View File

@ -19,8 +19,8 @@ pub fn open_source(path: &Path) -> Result<String, GenericError> {
#[cfg(feature = "compiler")] #[cfg(feature = "compiler")]
pub fn into_bytecode(compiled: &CompiledReid) -> Vec<u8> { pub fn into_bytecode(compiled: &CompiledReid) -> Vec<u8> {
let mut list = Vec::new(); let mut list = Vec::new();
let iter = compiled.list.iter(); let cloned = compiled.list.clone().into_iter();
for item in iter { for item in cloned {
list.append(&mut item.into_u8()); list.append(&mut item.into_u8());
} }
list list
@ -50,7 +50,7 @@ pub fn open_bytecode(path: &Path) -> Result<CompiledReid, GenericError> {
impl VariableType { impl VariableType {
#[cfg(feature = "compiler")] #[cfg(feature = "compiler")]
fn into_u8(&self) -> u8 { fn into_u8(self) -> u8 {
match self { match self {
VariableType::TypeString => 0, VariableType::TypeString => 0,
VariableType::TypeI32 => 1, VariableType::TypeI32 => 1,
@ -139,7 +139,7 @@ impl Command {
} }
#[cfg(feature = "compiler")] #[cfg(feature = "compiler")]
fn into_u8(&self) -> Vec<u8> { fn into_u8(self) -> Vec<u8> {
let mut list = Vec::new(); let mut list = Vec::new();
list.push(self.id()); list.push(self.id());
match &self { match &self {

View File

@ -96,6 +96,7 @@ fn main() {
fn run_bytecode(run_path: &Path, builtin_functions: BuiltinFunctions) { fn run_bytecode(run_path: &Path, builtin_functions: BuiltinFunctions) {
let compiled = open_bytecode(run_path); let compiled = open_bytecode(run_path);
dbg!(&compiled);
match compiled { match compiled {
Ok(compiled) => run(compiled, builtin_functions), Ok(compiled) => run(compiled, builtin_functions),
Err(error) => { Err(error) => {

View File

@ -1,8 +1,6 @@
use std::fmt; use std::fmt;
use std::fmt::Display; use std::fmt::Display;
use std::ops::{Add, Sub};
pub type FuncID = u16; pub type FuncID = u16;
pub type HeapID = u16; pub type HeapID = u16;
pub type RegID = u8; pub type RegID = u8;

View File

@ -155,7 +155,7 @@ impl VirtualMachine {
let val2 = self.pop_stack()?; let val2 = self.pop_stack()?;
let res = val2.add(val1); let res = val2.add(val1);
if let Some(res) = res { if let Some(res) = res {
self.push_stack(res); self.push_stack(res)?;
Ok(()) Ok(())
} else { } else {
Err(RuntimePanic::AttemptedInvalidArithmeticOperation) Err(RuntimePanic::AttemptedInvalidArithmeticOperation)
@ -166,7 +166,7 @@ impl VirtualMachine {
let val2 = self.pop_stack()?; let val2 = self.pop_stack()?;
let res = val2.sub(val1); let res = val2.sub(val1);
if let Some(res) = res { if let Some(res) = res {
self.push_stack(res); self.push_stack(res)?;
Ok(()) Ok(())
} else { } else {
Err(RuntimePanic::AttemptedInvalidArithmeticOperation) Err(RuntimePanic::AttemptedInvalidArithmeticOperation)
@ -177,7 +177,7 @@ impl VirtualMachine {
let val2 = self.pop_stack()?; let val2 = self.pop_stack()?;
let res = val2.mul(val1); let res = val2.mul(val1);
if let Some(res) = res { if let Some(res) = res {
self.push_stack(res); self.push_stack(res)?;
Ok(()) Ok(())
} else { } else {
Err(RuntimePanic::AttemptedInvalidArithmeticOperation) Err(RuntimePanic::AttemptedInvalidArithmeticOperation)