🚗 Implemented ordered functio chaining

This commit is contained in:
Erin 2021-12-14 21:45:44 +01:00 committed by ondra05
parent 690c78c9c0
commit cd902e0036

View file

@ -350,6 +350,15 @@ impl ExecEnv {
})
.collect::<Result<Vec<_>, Error>>()?;
self.fn_call_with_values(func, &args, span)
}
fn fn_call_with_values(
&mut self,
func: Functio,
args: &[Rc<RefCell<Value>>],
span: &Range<usize>,
) -> Result<(), Error> {
match func {
Functio::Bf {
instructions,
@ -396,7 +405,16 @@ impl ExecEnv {
self.stack.pop();
res?;
}
Functio::Chain { .. } => todo!(),
Functio::Chain { functios, kind } => {
let (left_functio, right_functio) = *functios;
let (left_args, right_args) = match kind {
crate::variables::FunctioChainKind::Ordered => args.split_at(args.len() / 2),
crate::variables::FunctioChainKind::Interlaced => todo!(),
};
self.fn_call_with_values(left_functio, left_args, span)?;
self.fn_call_with_values(right_functio, right_args, span)?;
}
Functio::Eval(code) => {
if !args.is_empty() {
return Err(Error {