From db95d2f718e6f55e6be354ba4690a120de57acbe Mon Sep 17 00:00:00 2001 From: Erin Date: Tue, 14 Dec 2021 21:45:44 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=97=20Implemented=20ordered=20functio?= =?UTF-8?q?=20chaining?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ablescript/src/interpret.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/ablescript/src/interpret.rs b/ablescript/src/interpret.rs index 8aad7ab..0d23481 100644 --- a/ablescript/src/interpret.rs +++ b/ablescript/src/interpret.rs @@ -350,6 +350,15 @@ impl ExecEnv { }) .collect::, Error>>()?; + self.fn_call_with_values(func, &args, span) + } + + fn fn_call_with_values( + &mut self, + func: Functio, + args: &[Rc>], + span: &Range, + ) -> 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 {