Refactor bound node types for clarity
Introduce generic `CompilerPhase` trait to unify different stages of the bound AST. Rename `LocalSlot` to `VirtualId` and introduce `StackOffset` for clearer distinction between compile-time and run-time addressing. Update type aliases and implementations to reflect these changes.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
use crate::ast::compiler::bound_nodes::{BoundKind, Node};
|
||||
use std::fmt::Debug;
|
||||
use crate::ast::compiler::bound_nodes::{BoundKind, CompilerPhase, Node};
|
||||
|
||||
/// Human-readable AST dumper for the bound AST.
|
||||
pub struct Dumper {
|
||||
@@ -9,7 +8,7 @@ pub struct Dumper {
|
||||
|
||||
impl Dumper {
|
||||
/// Produces a formatted string representation of the given bound AST node and its children.
|
||||
pub fn dump<T: Debug>(node: &Node<T>) -> String {
|
||||
pub fn dump<P: CompilerPhase>(node: &Node<P>) -> String {
|
||||
let mut dumper = Self {
|
||||
output: String::new(),
|
||||
indent: 0,
|
||||
@@ -24,14 +23,14 @@ impl Dumper {
|
||||
}
|
||||
}
|
||||
|
||||
fn log<T: Debug>(&mut self, label: &str, node: &Node<T>) {
|
||||
fn log<P: CompilerPhase>(&mut self, label: &str, node: &Node<P>) {
|
||||
self.write_indent();
|
||||
self.output.push_str(label);
|
||||
self.output
|
||||
.push_str(&format!(" <Metadata: {:?}>\n", node.ty));
|
||||
}
|
||||
|
||||
fn visit<T: Debug>(&mut self, node: &Node<T>) {
|
||||
fn visit<P: CompilerPhase>(&mut self, node: &Node<P>) {
|
||||
match &node.kind {
|
||||
BoundKind::Nop => self.log("Nop", node),
|
||||
BoundKind::Constant(v) => {
|
||||
|
||||
Reference in New Issue
Block a user