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::{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 = "complex")]
31use mech_core::C64;
32#[cfg(feature = "rational")]
33use mech_core::R64;
34#[cfg(feature = "functions")]
35use crate::functions::*;
36#[cfg(feature = "access")]
37use crate::stdlib::access::*;
38#[cfg(feature = "assign")]
39use crate::stdlib::assign::*;
40#[cfg(feature = "convert")]
41use crate::stdlib::convert::*;
42#[cfg(feature = "matrix_horzcat")]
43use crate::stdlib::horzcat::*;
44#[cfg(feature = "matrix_vertcat")]
45use crate::stdlib::vertcat::*;
46#[cfg(feature = "combinatorics")]
47use mech_combinatorics::*;
48#[cfg(feature = "matrix")]
49use mech_matrix::*;
50#[cfg(feature = "stats")]
51use mech_stats::*;
52#[cfg(feature = "math")]
53use mech_math::*;
54#[cfg(feature = "logic")]
55use mech_logic::*;
56#[cfg(feature = "compare")]
57use mech_compare::*;
58#[cfg(feature = "range_inclusive")]
59use mech_range::inclusive::RangeInclusive;
60#[cfg(feature = "range_exclusive")]
61use mech_range::exclusive::RangeExclusive;
62#[cfg(feature = "set")]
63use mech_set::*;
64
65#[cfg(feature = "matrix")]
66use na::DMatrix;
67#[cfg(feature = "set")]
68use indexmap::set::IndexSet;
69#[cfg(any(feature = "map", feature = "table", feature = "record"))]
70use indexmap::map::IndexMap;
71
72pub mod literals;
73pub mod structures;
74pub mod interpreter;
75pub mod stdlib;
76#[cfg(feature = "functions")]
77pub mod functions;
78pub mod statements;
79pub mod expressions;
80pub mod mechdown;
81#[cfg(feature = "functions")]
82pub mod frame;
83
84pub use mech_core::*;
85
86pub use crate::literals::*;
87pub use crate::interpreter::*;
88pub use crate::structures::*;
89#[cfg(feature = "functifons")]
90pub use crate::functions::*;
91pub use crate::statements::*;
92pub use crate::expressions::*;
93pub use crate::mechdown::*;
94#[cfg(feature = "functions")]
95pub use crate::frame::*;
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}