Update various types to use their own definitions

This commit refactors several modules to use the defined types from
`ast::types` and `ast::nodes` directly, rather than using fully
qualified paths. This improves code readability and reduces redundancy.

Specifically, the following changes were made:

- In `analyzer.rs`, `crate::ast::types::Identity` and
  `crate::ast::types::Purity` are now used directly.
- In `binder.rs`, `crate::ast::types::NodeIdentity`,
  `crate::ast::types::SourceLocation`,
  `crate::ast::types::RecordLayout`, and `crate::ast::types::Value` are
  now used directly.
- In `macros.rs`, types like `Address`, `VirtualId`, `NodeIdentity`,
  `SourceLocation`, `StaticType`, and `Purity` are now used directly.
- In `optimizer/engine.rs`, `Address<VirtualId>` is now used directly.
- In `type_checker.rs`, `BoundPhase`, `Signature`, `Keyword`, and
  `RecordLayout` are now used directly.
- In `environment.rs`, `CompilerScope`, `LocalInfo`, `CapturePass`,
  `AnalyzedPhase`, `NativeFunction`, and `Closure` are now used
  directly.
- In `nodes.rs`, `RecordLayout`, `Keyword`, `Purity`, and `StaticType`
  are now used directly.
- In `parser.rs`, `SourceLocation` and `NodeIdentity` are now used
  directly.
- In `rtl/math.rs`, `NativeFunction`, `Purity`, `Signature`,
  `StaticType`, `Value`, `RefCell`, and `Rc` are now used directly.
- In `rtl/streams.rs`, `ScalarValue`, `SeriesMember`, `Object`,
  `PipeFn`, `Value`, `VM`, `RingBuffer`, `RecordSeries`, `SeriesView`,
  `build_map_stream`, and `build_pipeline_node` are now used directly.
- In `rtl/type_registry.rs`, `RecordLayout`, `Keyword`, `Purity`,
  `Signature`, `StaticType`, and `Value` are now used directly.
- In `vm.rs`, `RecordSeries`, `SeriesView`, `build_map_stream`,
  `build_pipeline_node`, `StreamNode`, `Object`, and `PipeFn` are now
  used directly.
- In `utils/tester.rs`, `TypedNode` is now used directly.
This commit is contained in:
2026-03-22 18:30:56 +01:00
parent 1cbc656554
commit 007446a167
13 changed files with 112 additions and 104 deletions
+13 -11
View File
@@ -642,10 +642,12 @@ impl<E: MacroEvaluator> MacroExpander<E> {
#[cfg(test)]
mod tests {
use super::*;
use crate::ast::nodes::Address;
use crate::ast::compiler::binder::{CompilerScope, LocalInfo};
use crate::ast::compiler::Binder;
use crate::ast::diagnostics::Diagnostics;
use crate::ast::nodes::{Address, VirtualId};
use crate::ast::parser::Parser;
use crate::ast::types::{Object, Value};
use crate::ast::types::{NodeIdentity, Object, Purity, SourceLocation, StaticType, Value};
struct SimpleEvaluator;
impl MacroEvaluator for SimpleEvaluator {
@@ -787,19 +789,19 @@ mod tests {
let mut locals = HashMap::new();
locals.insert(
Symbol::from("*"),
crate::ast::compiler::binder::LocalInfo {
addr: Address::Local(crate::ast::nodes::VirtualId(0)),
identity: crate::ast::types::NodeIdentity::new(crate::ast::types::SourceLocation {
LocalInfo {
addr: Address::Local(VirtualId(0)),
identity: NodeIdentity::new(SourceLocation {
line: 0,
col: 0,
}),
_ty: crate::ast::types::StaticType::Any,
purity: crate::ast::types::Purity::Pure,
_ty: StaticType::Any,
purity: Purity::Pure,
},
);
let initial_scopes = vec![crate::ast::compiler::binder::CompilerScope { locals }];
let initial_scopes = vec![CompilerScope { locals }];
let mut diag = crate::ast::diagnostics::Diagnostics::new();
let mut diag = Diagnostics::new();
// fixed_scope_idx = 0 means scope 0 is frozen (Global)
let result = Binder::bind_root(initial_scopes, 1, 0, &expanded, &mut diag);
assert!(
@@ -824,7 +826,7 @@ mod tests {
let mut expander = MacroExpander::new(MacroRegistry::new(), SimpleEvaluator);
let expanded = expander.expand(syntax).unwrap();
let mut diag = crate::ast::diagnostics::Diagnostics::new();
let mut diag = Diagnostics::new();
let result = Binder::bind_root(vec![], 0, 0, &expanded, &mut diag);
assert!(result.is_ok(), "Hygiene failed: {:?}", result.err());
}
@@ -844,7 +846,7 @@ mod tests {
let mut expander = MacroExpander::new(MacroRegistry::new(), SimpleEvaluator);
let expanded = expander.expand(syntax).unwrap();
let mut diag = crate::ast::diagnostics::Diagnostics::new();
let mut diag = Diagnostics::new();
let result = Binder::bind_root(vec![], 0, 0, &expanded, &mut diag);
assert!(
result.is_ok(),