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;
81pub mod frame;
82
83pub use mech_core::*;
84
85pub use crate::literals::*;
86pub use crate::interpreter::*;
87pub use crate::structures::*;
88#[cfg(feature = "functifons")]
89pub use crate::functions::*;
90pub use crate::statements::*;
91pub use crate::expressions::*;
92pub use crate::mechdown::*;
93pub use crate::frame::*;
94
95#[cfg(feature = "access")]
96pub use crate::stdlib::access::*;
97#[cfg(feature = "assign")]
98pub use crate::stdlib::assign::*;
99#[cfg(feature = "convert")]
100pub use crate::stdlib::convert::*;
101#[cfg(feature = "matrix_horzcat")]
102pub use crate::stdlib::horzcat::*;
103#[cfg(feature = "matrix_vertcat")]
104pub use crate::stdlib::vertcat::*;
105#[cfg(feature = "combinatorics")]
106pub use mech_combinatorics::*;
107#[cfg(feature = "matrix")]
108pub use mech_matrix::*;
109#[cfg(feature = "stats")]
110pub use mech_stats::*;
111#[cfg(feature = "math")]
112pub use mech_math::*;
113#[cfg(feature = "logic")]
114pub use mech_logic::*;
115#[cfg(feature = "compare")]
116pub use mech_compare::*;
117#[cfg(feature = "set")]
118pub use mech_set::*;
119
120pub fn load_stdkinds(kinds: &mut KindTable) {
121 #[cfg(feature = "u8")]
122 kinds.insert(hash_str("u8"),ValueKind::U8);
123 #[cfg(feature = "u16")]
124 kinds.insert(hash_str("u16"),ValueKind::U16);
125 #[cfg(feature = "u32")]
126 kinds.insert(hash_str("u32"),ValueKind::U32);
127 #[cfg(feature = "u64")]
128 kinds.insert(hash_str("u64"),ValueKind::U64);
129 #[cfg(feature = "u128")]
130 kinds.insert(hash_str("u128"),ValueKind::U128);
131 #[cfg(feature = "i8")]
132 kinds.insert(hash_str("i8"),ValueKind::I8);
133 #[cfg(feature = "i16")]
134 kinds.insert(hash_str("i16"),ValueKind::I16);
135 #[cfg(feature = "i32")]
136 kinds.insert(hash_str("i32"),ValueKind::I32);
137 #[cfg(feature = "i64")]
138 kinds.insert(hash_str("i64"),ValueKind::I64);
139 #[cfg(feature = "i128")]
140 kinds.insert(hash_str("i128"),ValueKind::I128);
141 #[cfg(feature = "f32")]
142 kinds.insert(hash_str("f32"),ValueKind::F32);
143 #[cfg(feature = "f64")]
144 kinds.insert(hash_str("f64"),ValueKind::F64);
145 #[cfg(feature = "c64")]
146 kinds.insert(hash_str("c64"),ValueKind::C64);
147 #[cfg(feature = "r64")]
148 kinds.insert(hash_str("r64"),ValueKind::R64);
149 #[cfg(feature = "string")]
150 kinds.insert(hash_str("string"),ValueKind::String);
151 #[cfg(feature = "bool")]
152 kinds.insert(hash_str("bool"),ValueKind::Bool);
153}
154
155#[cfg(feature = "functions")]
156pub fn load_stdlib(fxns: &mut Functions) {
157
158 for fxn_desc in inventory::iter::<FunctionDescriptor> {
159 fxns.insert_function(fxn_desc.clone());
160 }
161
162 for fxn_comp in inventory::iter::<FunctionCompilerDescriptor> {
163 fxns.function_compilers.insert(hash_str(fxn_comp.name), fxn_comp.ptr);
164 }
165
166}