Refactor: Analyze node purity and recursion
The Analyzer has been refactored to decorate `TypedNode`s with their purity and recursion status. This involves creating a new `AnalyzedNode` type and a `NodeMetrics` struct to hold this information. The `Analyzer` now returns an `AnalyzedNode` instead of a separate `Analysis` struct. This change lays the groundwork for future optimizations and analysis passes.
This commit is contained in:
@@ -27,6 +27,17 @@ pub type BoundNode<T = ()> = Node<BoundKind<T>, T>;
|
||||
/// Type alias for a node that has been fully type-checked.
|
||||
pub type TypedNode = BoundNode<StaticType>;
|
||||
|
||||
/// Metrics collected during the analysis phase.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct NodeMetrics {
|
||||
pub original: Rc<TypedNode>,
|
||||
pub purity: crate::ast::types::Purity,
|
||||
pub is_recursive: bool,
|
||||
}
|
||||
|
||||
/// Type alias for a node that has been analyzed.
|
||||
pub type AnalyzedNode = BoundNode<NodeMetrics>;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum BoundKind<T = ()> {
|
||||
Nop,
|
||||
|
||||
Reference in New Issue
Block a user