Fix a lot of things and implement gc

This commit is contained in:
2019-05-29 21:06:42 +02:00
parent c3876da74f
commit 84bdcf4b20
16 changed files with 146 additions and 55 deletions

View File

@@ -1,10 +1,11 @@
use Result;
use std::convert::TryInto;
use heap::Heap;
#[derive(Debug, Copy, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq)]
pub enum Value {
Int(i32),
HeapRef(usize),
HeapRef(Heap),
}
impl TryInto<i32> for Value {
@@ -22,9 +23,9 @@ impl TryInto<i32> for &Value {
type Error = &'static str;
fn try_into(self) -> Result<i32> {
match self {
&Value::Int(a) => Ok(a),
&Value::HeapRef(_) => Err("Cannot use HeapRef as i32"),
match *self {
Value::Int(a) => Ok(a),
Value::HeapRef(_) => Err("Cannot use HeapRef as i32"),
}
}
}