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
#[allow(dead_code)]
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
pub enum Type {
Empty,
Integer,
String,
Boolean,
Bits(String),
Scalar(String),
AddiGroupEl(String),
MultGroupEl(String),
List(Box<Type>),
Set(Box<Type>),
Tuple(Vec<Type>),
Table(Box<Type>, Box<Type>),
Maybe(Box<Type>),
Fn(Vec<Type>, Box<Type>),
Oracle(Vec<Type>, Box<Type>),
}
impl Type {
pub fn new_bits(length: &str) -> Type {
Type::Bits(length.to_string())
}
pub fn new_scalar(name: &str) -> Type {
Type::Scalar(name.to_string())
}
#[allow(dead_code)]
pub fn new_list(t: &Type) -> Type {
Type::List(Box::new(t.clone()))
}
#[allow(dead_code)]
pub fn new_set(t: &Type) -> Type {
Type::Set(Box::new(t.clone()))
}
pub fn new_fn(args: Vec<Type>, ret: Type) -> Type {
Type::Fn(args, Box::new(ret))
}
}