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:
Michael Schimmel
2026-03-13 19:20:44 +01:00
parent d035da9d91
commit e5d82ee2b6
15 changed files with 403 additions and 458 deletions
+3 -3
View File
@@ -1,4 +1,4 @@
use crate::ast::compiler::bound_nodes::{Address, AnalyzedNode, BoundKind, LocalSlot};
use crate::ast::compiler::bound_nodes::{Address, AnalyzedNode, BoundKind, VirtualId};
use crate::ast::types::{Purity, Value};
use crate::ast::vm::Closure;
use std::cell::RefCell;
@@ -24,7 +24,7 @@ impl<'a> Inliner<'a> {
}
}
pub fn is_inlinable_value(&self, val: &Value, addr: Address) -> bool {
pub fn is_inlinable_value(&self, val: &Value, addr: Address<VirtualId>) -> bool {
let type_ok = match val {
Value::Int(_)
| Value::Float(_)
@@ -141,7 +141,7 @@ impl<'a> Inliner<'a> {
}
}
pub fn collect_parameter_slots_set(&self, node: &AnalyzedNode, slots: &mut HashSet<LocalSlot>) {
pub fn collect_parameter_slots_set(&self, node: &AnalyzedNode, slots: &mut HashSet<VirtualId>) {
match &node.kind {
BoundKind::Define {
addr: Address::Local(slot),