forked from Orchid/orchid
Generic mutation scheduling system
IO adapted to use it Also, Atoms can now dispatch type-erased requests
This commit is contained in:
@@ -34,6 +34,12 @@ pub trait Atomic: Any + Debug + DynClone
|
||||
where
|
||||
Self: 'static,
|
||||
{
|
||||
/// A fully type-erased interface to issue a command to the unknown type
|
||||
/// and see if it supports it
|
||||
fn request(&self, _request: Box<dyn Any>) -> Option<Box<dyn Any>> {
|
||||
None
|
||||
}
|
||||
|
||||
/// Casts this value to [Any] so that its original value can be salvaged
|
||||
/// during introspection by other external code. There is no other way to
|
||||
/// interact with values of unknown types at the moment.
|
||||
|
||||
@@ -4,11 +4,11 @@ use std::fmt::Debug;
|
||||
|
||||
use trait_set::trait_set;
|
||||
|
||||
use super::{Atomic, AtomicResult, AtomicReturn, ExternFn, XfnResult};
|
||||
use super::{Atomic, ExternFn, XfnResult};
|
||||
use crate::interpreted::{Clause, ExprInst};
|
||||
use crate::interpreter::{Context, HandlerRes};
|
||||
use crate::utils::pushed::pushed_ref;
|
||||
use crate::{atomic_defaults, ConstTree};
|
||||
use crate::utils::pure_push::pushed_ref;
|
||||
use crate::{ConstTree, atomic_inert};
|
||||
|
||||
trait_set! {
|
||||
/// A "well behaved" type that can be used as payload in a CPS box
|
||||
@@ -93,16 +93,7 @@ impl<T: CPSPayload> CPSBox<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: CPSPayload> Atomic for CPSBox<T> {
|
||||
atomic_defaults!();
|
||||
fn run(&self, ctx: Context) -> AtomicResult {
|
||||
Ok(AtomicReturn {
|
||||
clause: self.clone().atom_cls(),
|
||||
gas: ctx.gas,
|
||||
inert: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
atomic_inert!(CPSBox(T:(CPSPayload)), typestr = "a CPS box");
|
||||
|
||||
/// Like [init_cps] but wrapped in a [ConstTree] for init-time usage
|
||||
pub fn const_cps<T: CPSPayload>(argc: usize, payload: T) -> ConstTree {
|
||||
|
||||
Reference in New Issue
Block a user