Finished up to and including chapter 16

This commit is contained in:
Moritz Gmeiner 2023-01-30 17:41:48 +01:00
commit b86985deaf
24 changed files with 1051 additions and 198 deletions

22
vm/src/value.rs Normal file
View file

@ -0,0 +1,22 @@
use std::fmt::Display;
#[derive(Debug, Clone, PartialEq)]
pub enum Value {
Nil,
Number(f64),
}
impl Default for Value {
fn default() -> Self {
Value::Nil
}
}
impl Display for Value {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Value::Nil => write!(f, "nil"),
Value::Number(num) => write!(f, "{num}"),
}
}
}