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")]
pub fn into_bytecode(compiled: &CompiledReid) -> Vec<u8> {
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<CompiledReid, GenericError> {
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<u8> {
fn into_u8(self) -> Vec<u8> {
let mut list = Vec::new();
list.push(self.id());
match &self {

View File

@ -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) => {

View File

@ -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;

View File

@ -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)