Move some code around
This commit is contained in:
parent
876373c9fd
commit
1eaf201145
@ -156,16 +156,14 @@ impl<'a> State<'a> {
|
|||||||
Expression(Value(identifier), _) => {
|
Expression(Value(identifier), _) => {
|
||||||
match self.values.get(&identifier) {
|
match self.values.get(&identifier) {
|
||||||
Some(&ValueEntry::Function { ref body, ref param_names }) => {
|
Some(&ValueEntry::Function { ref body, ref param_names }) => {
|
||||||
let mut new_state = State::new_with_parent(self);
|
|
||||||
let sub_ast = body.clone();
|
|
||||||
|
|
||||||
if arguments.len() != param_names.len() {
|
if arguments.len() != param_names.len() {
|
||||||
return Err(format!("Wrong number of arguments for the function"));
|
return Err(format!("Wrong number of arguments for the function"));
|
||||||
}
|
}
|
||||||
|
let mut new_state = State::new_with_parent(self);
|
||||||
|
let sub_ast = body.clone();
|
||||||
for (param, val) in param_names.iter().zip(arguments.into_iter()) {
|
for (param, val) in param_names.iter().zip(arguments.into_iter()) {
|
||||||
new_state.values.insert(param.clone(), ValueEntry::Binding { val });
|
new_state.values.insert(param.clone(), ValueEntry::Binding { val });
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut ret: Option<FullyEvaluatedExpr> = None;
|
let mut ret: Option<FullyEvaluatedExpr> = None;
|
||||||
for statement in sub_ast.into_iter() {
|
for statement in sub_ast.into_iter() {
|
||||||
ret = new_state.eval_statement(statement)?;
|
ret = new_state.eval_statement(statement)?;
|
||||||
|
Loading…
Reference in New Issue
Block a user