move args to make more sense

This commit is contained in:
2024-10-22 14:40:39 -04:00
parent 2a987ae465
commit 8fbb4780df

View File

@@ -316,12 +316,17 @@ where
self.exec(isfalse) self.exec(isfalse)
}, },
ParseTree::FunctionCall(ident, args) => { ParseTree::FunctionCall(ident, args) => {
let args = args.into_iter().map(|x| Object::variable(x, self.globals.clone(), self.locals.clone())).collect();
let obj = self.get_object_mut(&ident)?; let obj = self.get_object_mut(&ident)?;
let v = Self::eval(obj)?; let v = Self::eval(obj)?;
match v { match v {
Value::Function(mut f) => f.call(Self::obj_globals(obj), Self::obj_locals(obj), args), Value::Function(mut f) => {
let args = args.into_iter()
.map(|x| Object::variable(x, self.globals.clone(), self.locals.clone()))
.collect();
f.call(Self::obj_globals(obj), Self::obj_locals(obj), args)
},
_ => Err(RuntimeError::FunctionUndefined(ident.clone())) _ => Err(RuntimeError::FunctionUndefined(ident.clone()))
} }
}, },