diff --git a/src/interpreter/classes.rs b/src/interpreter/classes.rs index 0f50b2e..47fa444 100644 --- a/src/interpreter/classes.rs +++ b/src/interpreter/classes.rs @@ -24,6 +24,7 @@ pub type ClassMemberKey = (ClassMemberKind, bool, String); #[derive(Debug, Clone)] pub struct Class { name: String, + superclass: Option, members: HashMap, fields: RefCell>, } @@ -34,7 +35,7 @@ pub type ClassRef = Rc>; /// An instance of a Lox class #[derive(Debug, Clone)] pub struct Instance { - class: Rc>, + class: ClassRef, fields: RefCell>, } @@ -58,9 +59,14 @@ fn bind_method(method: &Function, this_value: Value) -> Function { impl Class { /// Create a new class, specifying its name. - pub fn new(name: String, members: HashMap) -> Self { + pub fn new( + name: String, + superclass: Option, + members: HashMap, + ) -> Self { Self { name, + superclass, members, fields: RefCell::new(HashMap::default()), }