Fix a lot of things and implement gc
This commit is contained in:
11
src/value.rs
11
src/value.rs
@@ -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"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user