Feat: Add Pipe Node
Introduces a new `Pipe` node to the Abstract Syntax Tree (AST). This node represents a functional composition pattern, allowing for chaining of operations. The changes include: - Defining the `Pipe` variant in `BoundKind` and `UntypedKind`. - Implementing parsing logic for the `pipe` keyword. - Adding handling for the `Pipe` node in various compiler passes (analyzer, binder, captures, dumper, macros, optimizer, TCO, type checker). - Including a placeholder implementation for `Pipe` execution in the VM. - Updating integration tests to use the new `pipe` syntax.
This commit is contained in:
@@ -386,6 +386,21 @@ impl Optimizer {
|
||||
)
|
||||
}
|
||||
|
||||
BoundKind::Pipe { inputs, lambda } => {
|
||||
let mut o_inputs = Vec::with_capacity(inputs.len());
|
||||
for input in inputs {
|
||||
o_inputs.push(self.visit_node(input, sub, path));
|
||||
}
|
||||
let o_lambda = Box::new(self.visit_node(*lambda, sub, path));
|
||||
(
|
||||
BoundKind::Pipe {
|
||||
inputs: o_inputs,
|
||||
lambda: o_lambda,
|
||||
},
|
||||
node.ty.clone(),
|
||||
)
|
||||
}
|
||||
|
||||
BoundKind::Block { ref exprs } => {
|
||||
let mut info = UsageInfo::default();
|
||||
if !exprs.is_empty() {
|
||||
|
||||
@@ -152,6 +152,12 @@ impl UsageInfo {
|
||||
BoundKind::Again { args } => {
|
||||
self.collect(args);
|
||||
}
|
||||
BoundKind::Pipe { inputs, lambda } => {
|
||||
for input in inputs {
|
||||
self.collect(input);
|
||||
}
|
||||
self.collect(lambda);
|
||||
}
|
||||
BoundKind::Nop | BoundKind::FieldAccessor(_) | BoundKind::Extension(_) => {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user