Fix lookup_binding in function call case

This commit is contained in:
greg 2016-01-24 15:52:18 -08:00
parent 5eba222679
commit c36bc3377e
1 changed files with 7 additions and 10 deletions

View File

@ -52,17 +52,14 @@ impl Evaluator {
} }
fn lookup_binding(&mut self, var: String) -> Option<Expression> { fn lookup_binding(&mut self, var: String) -> Option<Expression> {
self.varmap.map.get(&var).map(|expr| expr.clone()) for frame in self.frames.iter() {
.or_else(|| { match frame.map.get(&var) {
for frame in self.frames.iter() { None => (),
match frame.map.get(&var) { Some(expr) => return Some(expr.clone()),
None => (), }
Some(expr) => return Some(expr.clone()), }
}
}
None self.varmap.map.get(&var).map(|expr| expr.clone())
})
} }
fn add_function(&mut self, name: String, function: Function) { fn add_function(&mut self, name: String, function: Function) {