use core::num::NonZeroU32;
#[cfg(feature = "mem_dbg")]
use mem_dbg::{MemDbg, MemSize};
use crate::{IString, StringTable};
#[cfg_attr(feature = "mem_dbg", derive(MemSize, MemDbg))]
#[cfg_attr(feature = "mem_dbg", copy_type)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum TheoryKind {
Null,
Basic,
Label,
Pattern,
ModelValue,
UserSort,
Arith,
Polymorphic,
Other(IString),
Unknown(NonZeroU32),
}
impl TheoryKind {
pub fn from_id(id: i32) -> Self {
debug_assert!(id >= -1);
use TheoryKind::*;
match id {
-1 => Null,
0 => Basic,
1 => Label,
2 => Pattern,
3 => ModelValue,
4 => UserSort,
5 => Arith,
6 => Polymorphic,
_ => Unknown(NonZeroU32::new(id as u32).unwrap()),
}
}
pub fn from_name(name: &str, strings: &mut StringTable) -> Self {
use TheoryKind::*;
match name {
"null" => Null,
"basic" => Basic,
"label" => Label,
"pattern" => Pattern,
"model-value" => ModelValue,
"user-sort" => UserSort,
"arith" => Arith,
"polymorphic" => Polymorphic,
_ => Other(IString(strings.get_or_intern(name))),
}
}
}