Delete some unneeded code

This commit is contained in:
greg 2017-12-29 04:55:03 -08:00
parent 0c64b14be0
commit 48a35aa382
1 changed files with 6 additions and 21 deletions

View File

@ -92,18 +92,12 @@ impl EvaluatorState {
fn eval(&mut self, expr: Sexp) -> Result<Sexp, String> {
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<PrimitiveFn> {
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::*;