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:
+6
-4
@@ -1,6 +1,8 @@
|
||||
use crate::ast::environment::Environment;
|
||||
use crate::ast::types::{Purity, Signature, StaticType, Value};
|
||||
use crate::ast::types::{NativeFunction, Purity, Signature, StaticType, Value};
|
||||
use std::cell::RefCell;
|
||||
use std::f64::consts;
|
||||
use std::rc::Rc;
|
||||
|
||||
pub fn register(env: &Environment) {
|
||||
// Constants
|
||||
@@ -165,10 +167,10 @@ pub fn register(env: &Environment) {
|
||||
fastrand::Rng::new()
|
||||
};
|
||||
|
||||
let prng = std::rc::Rc::new(std::cell::RefCell::new(rng));
|
||||
let prng = Rc::new(RefCell::new(rng));
|
||||
|
||||
Value::Function(std::rc::Rc::new(crate::ast::types::NativeFunction {
|
||||
func: std::rc::Rc::new(move |_args| Value::Float(prng.borrow_mut().f64())),
|
||||
Value::Function(Rc::new(NativeFunction {
|
||||
func: Rc::new(move |_args| Value::Float(prng.borrow_mut().f64())),
|
||||
purity: Purity::Impure,
|
||||
}))
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user