smt_scope/items/
theory.rs1use core::num::NonZeroU32;
2
3#[cfg(feature = "mem_dbg")]
4use mem_dbg::{MemDbg, MemSize};
5
6use crate::{IString, StringTable};
7
8#[cfg_attr(feature = "mem_dbg", derive(MemSize, MemDbg))]
15#[cfg_attr(feature = "mem_dbg", copy_type)]
16#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
17pub enum TheoryKind {
18 Null,
19 Basic,
20 Label,
21 Pattern,
22 ModelValue,
23 UserSort,
24 Arith,
25 Polymorphic,
26
27 Other(IString),
28 Unknown(NonZeroU32),
29}
30
31impl TheoryKind {
32 pub fn from_id(id: i32) -> Self {
33 debug_assert!(id >= -1);
34 use TheoryKind::*;
35 match id {
36 -1 => Null,
37 0 => Basic,
38 1 => Label,
39 2 => Pattern,
40 3 => ModelValue,
41 4 => UserSort,
42 5 => Arith,
43 6 => Polymorphic,
44 _ => Unknown(NonZeroU32::new(id as u32).unwrap()),
45 }
46 }
47
48 pub fn from_name(name: &str, strings: &mut StringTable) -> Self {
49 use TheoryKind::*;
50 match name {
51 "null" => Null,
52 "basic" => Basic,
53 "label" => Label,
54 "pattern" => Pattern,
55 "model-value" => ModelValue,
56 "user-sort" => UserSort,
57 "arith" => Arith,
58 "polymorphic" => Polymorphic,
59 _ => Other(IString(strings.get_or_intern(name))),
60 }
61 }
62}