1use std::fmt::Display;
4
5use super::CompileTimeConstant;
6
7#[derive(Clone,Eq,PartialEq,Debug)]
9pub enum FipsType {
10 Double,
11 Int64,
12 Array{
14 typ: Box<FipsType>,
15 length: CompileTimeConstant<usize>
16 }
17}
18
19impl FipsType {
20 pub(crate) fn is_scalar(&self) -> bool {
22 match self {
23 FipsType::Double | FipsType::Int64 => true,
24 FipsType::Array {..} => false
25 }
26 }
27
28 pub(crate) fn is_i64_derived(&self) -> bool {
30 match self {
31 FipsType::Int64 => true,
32 FipsType::Double => false,
33 FipsType::Array { typ, ..} => typ.is_i64_derived()
34 }
35 }
36
37 pub(crate) fn is_f64_derived(&self) -> bool {
39 match self {
40 FipsType::Int64 => false,
41 FipsType::Double => true,
42 FipsType::Array { typ, ..} => typ.is_f64_derived()
43 }
44 }
45}
46
47impl Display for FipsType {
48 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
49 match self {
50 FipsType::Double => f.write_str("f64"),
51 FipsType::Int64 => f.write_str("i64"),
52 FipsType::Array { typ, length } => f.write_fmt(format_args!("[{},{}]", typ, length))
53 }
54 }
55}