The pipeline is finally reasonably clean

This commit is contained in:
2023-09-12 01:26:46 +01:00
parent 6693d93944
commit 8c866967a9
86 changed files with 1959 additions and 1393 deletions

View File

@@ -1,13 +1,13 @@
//! Automated wrappers to make working with CPS commands easier.
use std::fmt::Debug;
use std::iter;
use trait_set::trait_set;
use super::{Atomic, AtomicResult, AtomicReturn, ExternFn, XfnResult};
use crate::interpreted::{Clause, ExprInst};
use crate::interpreter::{Context, HandlerRes};
use crate::utils::pushed::pushed_ref;
use crate::{atomic_defaults, ConstTree};
trait_set! {
@@ -39,10 +39,7 @@ impl<T: CPSPayload> ExternFn for CPSFn<T> {
}
fn apply(&self, arg: ExprInst, _ctx: Context) -> XfnResult {
let payload = self.payload.clone();
let continuations = (self.continuations.iter())
.cloned()
.chain(iter::once(arg))
.collect::<Vec<_>>();
let continuations = pushed_ref(&self.continuations, arg);
if self.argc == 1 {
Ok(CPSBox { payload, continuations }.atom_cls())
} else {