diff --git a/src/object.rs b/src/object.rs index dea3b7b..89730e5 100644 --- a/src/object.rs +++ b/src/object.rs @@ -62,14 +62,14 @@ impl QuoteTable { // Value // ///////////////////////////////////////////////////////////////////////////// -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq)] pub enum Value { Array(Vec), Float(Float), Int(Int), Str(Str), Quote(Quote), - ObjPtr(ObjPtr), + //ObjPtr(ObjPtr), BuiltinFn(BuiltinFn), } @@ -82,7 +82,7 @@ impl Value { Int(_) => "int", Str(_) => "str", Quote(_) => "quote", - ObjPtr(_) => "object", + //ObjPtr(_) => "object", BuiltinFn(_) => "builtin function", } } @@ -95,7 +95,7 @@ impl Value { Int(i) => *i != 0, Str(s) => s.len() > 0, Quote(_) => true, - ObjPtr(_) => true, + //ObjPtr(_) => true, BuiltinFn(_) => true, } } @@ -110,7 +110,7 @@ impl Display for Value { Int(i) => write!(fmt, "{}", i), Str(s) => write!(fmt, "{}", s), Quote(q) => write!(fmt, "[quoted value #{}]", q.index()), - ObjPtr(o) => write!(fmt, "[object #{}]", o.slot()), + //ObjPtr(o) => write!(fmt, "[object #{}]", o.slot()), BuiltinFn(b) => write!(fmt, "[{:?}]", b), } } @@ -141,6 +141,12 @@ pub struct BuiltinFn { fun: Rc, } +impl PartialEq for BuiltinFn { + fn eq(&self, other: &Self) -> bool { + (&self.fun as *const _ as usize) == (&other.fun as *const _ as usize) + } +} + impl BuiltinFn { pub fn new(name: String, fun: Rc) -> Self { BuiltinFn {