This commit is contained in:
Erin 2022-08-06 22:23:57 +02:00 committed by ondra05
parent 9bf1a6b633
commit 18fd6a35d5
3 changed files with 11 additions and 5 deletions

View file

@ -4,7 +4,7 @@
//! 1. (Britain) To do a clumsy or inelegant job, usually as a temporary repair; mend, patch up, repair. //! 1. (Britain) To do a clumsy or inelegant job, usually as a temporary repair; mend, patch up, repair.
//! 2. To work green wood using traditional country methods; to perform the craft of a bodger. //! 2. To work green wood using traditional country methods; to perform the craft of a bodger.
//! //!
//! A simple tree-walk interpreter intended for testing purposes. //! A simple silly compiler + VM intended for testing purposes.
//! To be replaced by VM soon™ :ferrisClueless: //! To be replaced by something better soon™ :ferrisClueless:
pub mod value; pub mod value;

View file

@ -23,9 +23,9 @@ pub enum Value<'s> {
Keyword(Str<'s>), Keyword(Str<'s>),
Number(OrderedF64), Number(OrderedF64),
String(Str<'s>), String(Str<'s>),
Function(Function<'s>), Function(Rc<Function<'s>>),
NativeFun(fn(&'s [Value<'s>]) -> Value<'s>), NativeFun(fn(&'s [Value<'s>]) -> Value<'s>),
Macro(Function<'s>), Macro(Rc<Function<'s>>),
} }
impl<'s> From<Spanned<Expr<'s>>> for Value<'s> { impl<'s> From<Spanned<Expr<'s>>> for Value<'s> {

View file

@ -1,4 +1,4 @@
use std::{fmt::Display, ops::Deref, rc::Rc}; use std::{fmt::Display, ops::Deref, rc::Rc, hash::Hash};
/// A Wisp string type which can hold two variants: /// A Wisp string type which can hold two variants:
/// - Borrowed (usually a reference to source code or built-in literal) /// - Borrowed (usually a reference to source code or built-in literal)
@ -40,6 +40,12 @@ impl<'a> PartialEq for Str<'a> {
impl<'a> Eq for Str<'a> {} impl<'a> Eq for Str<'a> {}
impl<'a> Hash for Str<'a> {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
(**self).hash(state);
}
}
impl<'a> Display for Str<'a> { impl<'a> Display for Str<'a> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self { match self {