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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
use crate::{serialization::op_code::OpCode, types::*};
use core::fmt;
use Expr::*;
mod constant;
pub mod ops;
pub use constant::*;
#[derive(PartialEq, Eq, Debug, Clone)]
pub struct RegisterId(u8);
#[derive(PartialEq, Eq, Debug, Clone)]
pub enum Expr {
Const(Constant),
ConstPlaceholder(ConstantPlaceholder),
Coll {
tpe: SType,
v: Vec<Expr>,
},
Tup {
tpe: SType,
v: Vec<Expr>,
},
PredefFunc(PredefFunc),
CollM(CollMethods),
BoxM(BoxMethods),
CtxM(ContextMethods),
MethodCall {
tpe: SType,
obj: Box<Expr>,
method: SMethod,
args: Vec<Expr>,
},
BinOp(ops::BinOp, Box<Expr>, Box<Expr>),
}
impl Expr {
pub fn op_code(&self) -> OpCode {
match self {
Const(_) => todo!(),
ConstPlaceholder(cp) => cp.op_code(),
_ => todo!(),
}
}
pub fn tpe(&self) -> &SType {
match self {
Const(c) => &c.tpe,
_ => todo!(),
}
}
}
impl fmt::Display for Expr {
fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result {
todo!()
}
}
#[derive(PartialEq, Eq, Debug, Clone)]
pub enum CollMethods {
Fold {
input: Box<Expr>,
zero: Box<Expr>,
fold_op: Box<Expr>,
},
}
#[derive(PartialEq, Eq, Debug, Clone)]
pub enum BoxMethods {
ExtractRegisterAs {
input: Box<Expr>,
register_id: RegisterId,
},
}
impl BoxMethods {
pub fn op_code(&self) -> OpCode {
todo!()
}
}
#[derive(PartialEq, Eq, Debug, Clone)]
pub enum ContextMethods {
Inputs,
Outputs,
}
#[derive(PartialEq, Eq, Debug, Clone)]
pub enum PredefFunc {
Sha256 {
input: Box<Expr>,
},
}