🚗 Implemented ordered functio chaining

This commit is contained in:
Erin 2021-12-14 21:45:44 +01:00 committed by ondra05
parent 872a16578f
commit db95d2f718

View file

@ -350,6 +350,15 @@ impl ExecEnv {
}) })
.collect::<Result<Vec<_>, Error>>()?; .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 { match func {
Functio::Bf { Functio::Bf {
instructions, instructions,
@ -396,7 +405,16 @@ impl ExecEnv {
self.stack.pop(); self.stack.pop();
res?; 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) => { Functio::Eval(code) => {
if !args.is_empty() { if !args.is_empty() {
return Err(Error { return Err(Error {