1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
use super::{BasicType, BasicTypeBase, TypeKind};
mod functions;
mod ops;
pub type IntegerType = BasicType<IntegerImpl>;
pub const fn name() -> &'static str {
"Integer"
}
pub struct IntegerImpl;
impl IntegerType {
pub fn new() -> Self {
Self::default()
}
}
impl Default for IntegerType {
fn default() -> Self {
BasicType::from_base_with_functions(
IntegerImpl,
vec![
(crate::ops::NOT, ops::not),
(crate::ops::NEGATE, ops::negate),
(crate::ops::NOT, ops::not),
(crate::ops::MUL, ops::multiply),
(crate::ops::DIV, ops::divide),
(crate::ops::REM, ops::remainder),
(crate::ops::ADD, ops::add),
(crate::ops::SUB, ops::subtract),
(crate::ops::SHL, ops::shift_left),
(crate::ops::SHR, ops::shift_right),
(crate::ops::BIT_AND, ops::bit_and),
(crate::ops::BIT_OR, ops::bit_or),
(crate::ops::BIT_XOR, ops::bit_xor),
(crate::ops::EQUAL, ops::equal),
(crate::ops::NOT_EQUAL, ops::not_equal),
(crate::ops::LESS, ops::less),
(crate::ops::LESS_OR_EQUAL, ops::less_or_equal),
(crate::ops::GREATER, ops::greater),
(crate::ops::GREATER_OR_EQUAL, ops::greater_or_equal),
("abs", functions::abs),
("clone", functions::clone),
("is_negative", functions::is_negative),
("is_positive", functions::is_positive),
("pow", functions::pow),
("signum", functions::signum),
("to_string", functions::to_string),
],
)
}
}
impl BasicTypeBase for IntegerImpl {
fn name(&self) -> &str {
self::name()
}
fn kind(&self) -> TypeKind {
TypeKind::Integer
}
}