finished resolver (chapter 11) and started classes (chapter 12)

This commit is contained in:
Moritz Gmeiner 2023-01-28 01:11:55 +01:00
commit 10540708d4
34 changed files with 1449 additions and 439 deletions

19
interpreter/src/class.rs Normal file
View file

@ -0,0 +1,19 @@
use std::fmt::Display;
#[derive(Debug)]
pub struct LoxClass {
name: String,
}
impl LoxClass {
pub fn new(name: impl Into<String>) -> Self {
let name = name.into();
LoxClass { name }
}
}
impl Display for LoxClass {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "<class {}>", self.name)
}
}