🚗 Implemented ordered functio chaining

pull/1/head
ondra05 2021-12-14 21:45:44 +01:00
parent a722ea00d5
commit 7aa2d67449
1 changed files with 19 additions and 1 deletions

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 {