feat: Implement Pipeline support
Adds support for pipelines, allowing streams to be chained together and transformed. This includes new types for `PipeStream` and `SourceAdapter`, along with modifications to the `Environment` to manage pipeline execution. A new example `pipeline.myc` demonstrates its usage.
This commit is contained in:
@@ -21,6 +21,8 @@ use crate::ast::types::{
|
||||
Identity, NodeIdentity, Object, Purity, SourceLocation, StaticType, Value,
|
||||
};
|
||||
|
||||
pub type PipelineGenerator = Box<dyn FnMut() -> bool>;
|
||||
|
||||
pub struct Environment {
|
||||
pub global_names: Rc<RefCell<HashMap<Symbol, (GlobalIdx, Identity)>>>,
|
||||
pub global_types: Rc<RefCell<HashMap<GlobalIdx, StaticType>>>,
|
||||
@@ -33,7 +35,7 @@ pub struct Environment {
|
||||
pub debug_mode: bool,
|
||||
pub optimization: bool,
|
||||
pub macro_registry: Rc<RefCell<MacroRegistry>>,
|
||||
pub pipeline_generators: Rc<RefCell<Vec<Box<dyn FnMut() -> bool>>>>,
|
||||
pub pipeline_generators: Rc<RefCell<Vec<PipelineGenerator>>>,
|
||||
}
|
||||
|
||||
struct EnvFunctionRegistry {
|
||||
@@ -394,7 +396,9 @@ impl Environment {
|
||||
let compiled = self.compile(source)?;
|
||||
let linked = self.link(compiled);
|
||||
let func = self.instantiate(linked);
|
||||
Ok((func.func)(vec![]))
|
||||
let res = (func.func)(vec![]);
|
||||
self.run_pipeline();
|
||||
Ok(res)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -423,6 +427,9 @@ impl Environment {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
self.run_pipeline();
|
||||
|
||||
Ok((result, observer.logs))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user