diff --git a/src/eval.rs b/src/eval.rs index 5ff5242d0..50a0b1241 100644 --- a/src/eval.rs +++ b/src/eval.rs @@ -1,4 +1,4 @@ -use std::{cell::RefCell, collections::HashMap, fmt::Display, rc::Rc}; +use std::{cell::RefCell, collections::HashMap, fmt::Display, rc::Rc, time::Instant}; use crate::{ parser::Operator, Block, BlockId, Call, Expr, Expression, ParserState, Span, Statement, VarId, @@ -21,6 +21,19 @@ pub enum Value { Unknown, } +impl PartialEq for Value { + fn eq(&self, other: &Self) -> bool { + match (self, other) { + (Value::Bool { val: lhs, .. }, Value::Bool { val: rhs, .. }) => lhs == rhs, + (Value::Int { val: lhs, .. }, Value::Int { val: rhs, .. }) => lhs == rhs, + (Value::String { val: lhs, .. }, Value::String { val: rhs, .. }) => lhs == rhs, + (Value::List(l1), Value::List(l2)) => l1 == l2, + (Value::Block(b1), Value::Block(b2)) => b1 == b2, + _ => false, + } + } +} + impl Display for Value { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { @@ -193,6 +206,64 @@ fn eval_call(state: &State, stack: Stack, call: &Call) -> Result std::io::Result<()> { .required("block", SyntaxShape::Block, "body of the definition"); working_set.add_decl(sig.into()); + let sig = Signature::build("for") + .required( + "var_name", + SyntaxShape::Variable, + "name of the looping variable", + ) + .required( + "range", + SyntaxShape::Keyword(b"in".to_vec(), Box::new(SyntaxShape::Int)), + "range of the loop", + ) + .required("block", SyntaxShape::Block, "the block to run"); + working_set.add_decl(sig.into()); + + let sig = + Signature::build("benchmark").required("block", SyntaxShape::Block, "the block to run"); + working_set.add_decl(sig.into()); + // let sig = Signature::build("foo").named("--jazz", SyntaxShape::Int, "jazz!!", Some('j')); // working_set.add_decl(sig.into());