From 48a35aa382ec83af6af702c5fbb212123f2f331b Mon Sep 17 00:00:00 2001 From: greg Date: Fri, 29 Dec 2017 04:55:03 -0800 Subject: [PATCH] Delete some unneeded code --- src/rukka_lang/mod.rs | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/src/rukka_lang/mod.rs b/src/rukka_lang/mod.rs index d227579..450a11a 100644 --- a/src/rukka_lang/mod.rs +++ b/src/rukka_lang/mod.rs @@ -92,18 +92,12 @@ impl EvaluatorState { fn eval(&mut self, expr: Sexp) -> Result { use self::Sexp::*; Ok(match expr { - SymbolAtom(ref sym) => { - if let Some(op) = get_builtin(sym) { - Primitive(op) - } else { - match self.get_var(sym) { - Some(ref sexp) => { - let q: &Sexp = sexp; //WTF? if I delete this line, the copy doesn't work?? - q.clone() //TODO make this not involve a clone - }, - None => return Err(format!("Variable {} not bound", sym)), - } - } + SymbolAtom(ref sym) => match self.get_var(sym) { + Some(ref sexp) => { + let q: &Sexp = sexp; //WTF? if I delete this line, the copy doesn't work?? + q.clone() //TODO make this not involve a clone + }, + None => return Err(format!("Variable {} not bound", sym)), }, expr @ Primitive(_) => expr, expr @ FnLiteral { .. } => expr, @@ -313,15 +307,6 @@ enum PrimitiveFn { Plus, Minus, Mult, Div, Mod, Greater, Less, GreaterThanOrEqual, LessThanOrEqual } -fn get_builtin(sym: &String) -> Option { - use self::PrimitiveFn::*; - Some(match &sym[..] { - "+" => Plus, "-" => Minus, "*" => Mult, "/" => Div, "%" => Mod, - ">" => Greater, "<" => Less, ">=" => GreaterThanOrEqual, "<=" => LessThanOrEqual, - _ => return None - }) -} - impl Sexp { fn print(&self) -> String { use self::Sexp::*;