|
|
@@ -1,5 +1,6 @@
|
|
|
use super::{LitType, Opcode, VarType};
|
|
|
|
|
|
+#[derive(Clone, Debug)]
|
|
|
pub struct Constant {
|
|
|
pub name: String,
|
|
|
pub typ: VarType,
|
|
|
@@ -7,6 +8,7 @@ pub struct Constant {
|
|
|
pub column: usize,
|
|
|
}
|
|
|
|
|
|
+#[derive(Clone, Debug)]
|
|
|
pub struct Witness {
|
|
|
pub name: String,
|
|
|
pub typ: VarType,
|
|
|
@@ -14,6 +16,7 @@ pub struct Witness {
|
|
|
pub column: usize,
|
|
|
}
|
|
|
|
|
|
+#[derive(Clone, Debug)]
|
|
|
pub struct Variable {
|
|
|
pub name: String,
|
|
|
pub typ: VarType,
|
|
|
@@ -21,6 +24,7 @@ pub struct Variable {
|
|
|
pub column: usize,
|
|
|
}
|
|
|
|
|
|
+#[derive(Clone, Debug)]
|
|
|
pub struct Literal {
|
|
|
pub name: String,
|
|
|
pub typ: LitType,
|
|
|
@@ -28,17 +32,29 @@ pub struct Literal {
|
|
|
pub column: usize,
|
|
|
}
|
|
|
|
|
|
+#[derive(Debug)]
|
|
|
+pub enum Var {
|
|
|
+ Constant(Constant),
|
|
|
+ Witness(Witness),
|
|
|
+ Variable(Variable),
|
|
|
+}
|
|
|
+
|
|
|
+#[derive(Clone, Debug)]
|
|
|
pub enum Arg {
|
|
|
Var(Variable),
|
|
|
Lit(Literal),
|
|
|
+ Func(Statement),
|
|
|
}
|
|
|
|
|
|
+#[derive(Copy, Clone, PartialEq, Debug)]
|
|
|
#[repr(u8)]
|
|
|
pub enum StatementType {
|
|
|
- Assign = 0x00,
|
|
|
- Call = 0x01,
|
|
|
+ Noop = 0x00,
|
|
|
+ Assign = 0x01,
|
|
|
+ Call = 0x02,
|
|
|
}
|
|
|
|
|
|
+#[derive(Clone, Debug)]
|
|
|
pub struct Statement {
|
|
|
pub typ: StatementType,
|
|
|
pub opcode: Opcode,
|
|
|
@@ -46,3 +62,9 @@ pub struct Statement {
|
|
|
pub rhs: Vec<Arg>,
|
|
|
pub line: usize,
|
|
|
}
|
|
|
+
|
|
|
+impl Default for Statement {
|
|
|
+ fn default() -> Self {
|
|
|
+ Self { typ: StatementType::Noop, opcode: Opcode::Noop, lhs: None, rhs: vec![], line: 0 }
|
|
|
+ }
|
|
|
+}
|