1#![allow(warnings)]
2#![feature(step_trait)]
3#![feature(box_patterns)]
4#![feature(trivial_bounds)]
5#![feature(where_clause_attrs)]
6
7#[cfg(feature = "matrix")]
8extern crate nalgebra as na;
9#[macro_use]
10extern crate mech_core;
11
12use mech_core::*;
13#[cfg(feature = "matrix")]
14use mech_core::matrix::{Matrix, ToMatrix};
15use mech_core::kind::Kind;
16use mech_core::{Dictionary, Ref, Value, ValueKind, ValRef, ToValue};
17use mech_core::{MechError, MechErrorKind, hash_str, MResult, nodes::Kind as NodeKind, nodes::Matrix as Mat, nodes::*};
18#[cfg(feature = "map")]
19use mech_core::MechMap;
20#[cfg(feature = "record")]
21use mech_core::MechRecord;
22#[cfg(feature = "set")]
23use mech_core::MechSet;
24#[cfg(feature = "tuple")]
25use mech_core::MechTuple;
26#[cfg(feature = "enum")]
27use mech_core::MechEnum;
28#[cfg(feature = "table")]
29use mech_core::MechTable;
30#[cfg(feature = "f64")]
31use mech_core::F64;
32#[cfg(feature = "f32")]
33use mech_core::F32;
34#[cfg(feature = "complex")]
35use mech_core::C64;
36#[cfg(feature = "rational")]
37use mech_core::R64;
38#[cfg(feature = "functions")]
39use crate::functions::*;
40#[cfg(feature = "access")]
41use crate::stdlib::access::*;
42#[cfg(feature = "assign")]
43use crate::stdlib::assign::*;
44#[cfg(feature = "convert")]
45use crate::stdlib::convert::*;
46#[cfg(feature = "matrix_horzcat")]
47use crate::stdlib::horzcat::*;
48#[cfg(feature = "matrix_vertcat")]
49use crate::stdlib::vertcat::*;
50#[cfg(feature = "combinatorics")]
51use mech_combinatorics::*;
52#[cfg(feature = "matrix")]
53use mech_matrix::*;
54#[cfg(feature = "stats")]
55use mech_stats::*;
56#[cfg(feature = "math")]
57use mech_math::*;
58#[cfg(feature = "logic")]
59use mech_logic::*;
60#[cfg(feature = "compare")]
61use mech_compare::*;
62#[cfg(feature = "range_inclusive")]
63use mech_range::inclusive::RangeInclusive;
64#[cfg(feature = "range_exclusive")]
65use mech_range::exclusive::RangeExclusive;
66#[cfg(feature = "set")]
67use mech_set::*;
68
69#[cfg(feature = "matrix")]
70use na::DMatrix;
71#[cfg(feature = "set")]
72use indexmap::set::IndexSet;
73#[cfg(any(feature = "map", feature = "table", feature = "record"))]
74use indexmap::map::IndexMap;
75
76pub mod literals;
77pub mod structures;
78pub mod interpreter;
79pub mod stdlib;
80#[cfg(feature = "functions")]
81pub mod functions;
82pub mod statements;
83pub mod expressions;
84pub mod mechdown;
85
86pub use mech_core::*;
87
88pub use crate::literals::*;
89pub use crate::interpreter::*;
90pub use crate::structures::*;
91#[cfg(feature = "functifons")]
92pub use crate::functions::*;
93pub use crate::statements::*;
94pub use crate::expressions::*;
95pub use crate::mechdown::*;
96
97#[cfg(feature = "access")]
98pub use crate::stdlib::access::*;
99#[cfg(feature = "assign")]
100pub use crate::stdlib::assign::*;
101#[cfg(feature = "convert")]
102pub use crate::stdlib::convert::*;
103#[cfg(feature = "matrix_horzcat")]
104pub use crate::stdlib::horzcat::*;
105#[cfg(feature = "matrix_vertcat")]
106pub use crate::stdlib::vertcat::*;
107#[cfg(feature = "combinatorics")]
108pub use mech_combinatorics::*;
109#[cfg(feature = "matrix")]
110pub use mech_matrix::*;
111#[cfg(feature = "stats")]
112pub use mech_stats::*;
113#[cfg(feature = "math")]
114pub use mech_math::*;
115#[cfg(feature = "logic")]
116pub use mech_logic::*;
117#[cfg(feature = "compare")]
118pub use mech_compare::*;
119#[cfg(feature = "set")]
120pub use mech_set::*;
121
122pub fn load_stdkinds(kinds: &mut KindTable) {
123 #[cfg(feature = "u8")]
124 kinds.insert(hash_str("u8"),ValueKind::U8);
125 #[cfg(feature = "u16")]
126 kinds.insert(hash_str("u16"),ValueKind::U16);
127 #[cfg(feature = "u32")]
128 kinds.insert(hash_str("u32"),ValueKind::U32);
129 #[cfg(feature = "u64")]
130 kinds.insert(hash_str("u64"),ValueKind::U64);
131 #[cfg(feature = "u128")]
132 kinds.insert(hash_str("u128"),ValueKind::U128);
133 #[cfg(feature = "i8")]
134 kinds.insert(hash_str("i8"),ValueKind::I8);
135 #[cfg(feature = "i16")]
136 kinds.insert(hash_str("i16"),ValueKind::I16);
137 #[cfg(feature = "i32")]
138 kinds.insert(hash_str("i32"),ValueKind::I32);
139 #[cfg(feature = "i64")]
140 kinds.insert(hash_str("i64"),ValueKind::I64);
141 #[cfg(feature = "i128")]
142 kinds.insert(hash_str("i128"),ValueKind::I128);
143 #[cfg(feature = "f32")]
144 kinds.insert(hash_str("f32"),ValueKind::F32);
145 #[cfg(feature = "f64")]
146 kinds.insert(hash_str("f64"),ValueKind::F64);
147 #[cfg(feature = "c64")]
148 kinds.insert(hash_str("c64"),ValueKind::C64);
149 #[cfg(feature = "r64")]
150 kinds.insert(hash_str("r64"),ValueKind::R64);
151 #[cfg(feature = "string")]
152 kinds.insert(hash_str("string"),ValueKind::String);
153 #[cfg(feature = "bool")]
154 kinds.insert(hash_str("bool"),ValueKind::Bool);
155}
156
157#[cfg(feature = "functions")]
158pub fn load_stdlib(fxns: &mut Functions) {
159
160 for fxn_desc in inventory::iter::<FunctionDescriptor> {
161 fxns.insert_function(fxn_desc.clone());
162 }
163
164 for fxn_comp in inventory::iter::<FunctionCompilerDescriptor> {
165 fxns.function_compilers.insert(hash_str(fxn_comp.name), fxn_comp.ptr);
166 }
167
168}