remove old code

This commit is contained in:
collin 2020-04-23 15:29:21 -07:00
parent 34d8a552e7
commit ac9707da92
8 changed files with 2 additions and 1164 deletions

View File

@ -97,39 +97,6 @@ impl<F: Field + PrimeField, CS: ConstraintSystem<F>> ResolvedProgram<F, CS> {
ResolvedValue::Boolean(Boolean::Constant(bool))
}
// pub(crate) fn bool_from_variable(&mut self, scope: String, variable: Variable<F>) -> Boolean {
// // Evaluate variable name in current function scope
// let variable_name = new_scope_from_variable(scope, &variable);
//
// match self.get(&variable_name) {
// Some(value) => match value {
// ResolvedValue::Boolean(boolean) => boolean.clone(),
// value => unimplemented!(
// "expected boolean for variable {}, got {}",
// variable_name,
// value
// ),
// },
// None => unimplemented!("cannot resolve variable {} in program", variable_name),
// }
// }
// fn get_bool_value(
// &mut self,
// cs: &mut CS,
// scope: String,
// expression: BooleanExpression<F>,
// ) -> Boolean {
// match expression {
// BooleanExpression::Variable(variable) => self.bool_from_variable(scope, variable),
// BooleanExpression::Value(value) => Boolean::Constant(value),
// expression => match self.enforce_boolean_expression(cs, scope, expression) {
// ResolvedValue::Boolean(value) => value,
// _ => unimplemented!("boolean expression did not resolve to boolean"),
// },
// }
// }
pub(crate) fn enforce_not(value: ResolvedValue<F>) -> ResolvedValue<F> {
match value {
ResolvedValue::Boolean(boolean) => ResolvedValue::Boolean(boolean.not()),
@ -184,86 +151,4 @@ impl<F: Field + PrimeField, CS: ConstraintSystem<F>> ResolvedProgram<F, CS> {
ResolvedValue::Boolean(Boolean::Constant(true))
}
//
// pub(crate) fn enforce_boolean_expression(
// &mut self,
// cs: &mut CS,
// scope: String,
// expression: BooleanExpression<F>,
// ) -> ResolvedValue<F> {
// match expression {
// BooleanExpression::Variable(variable) => {
// ResolvedValue::Boolean(self.bool_from_variable(cs, scope, variable))
// }
// BooleanExpression::Value(value) => ResolvedValue::Boolean(Boolean::Constant(value)),
// BooleanExpression::Not(expression) => {
// ResolvedValue::Boolean(self.enforce_not(cs, scope, *expression))
// }
// BooleanExpression::Or(left, right) => {
// ResolvedValue::Boolean(self.enforce_or(cs, scope, *left, *right))
// }
// BooleanExpression::And(left, right) => {
// ResolvedValue::Boolean(self.enforce_and(cs, scope, *left, *right))
// }
// BooleanExpression::IntegerEq(left, right) => {
// ResolvedValue::Boolean(self.enforce_integer_equality(cs, scope, *left, *right))
// }
// BooleanExpression::FieldEq(left, right) => {
// ResolvedValue::Boolean(self.enforce_field_equality(cs, scope, *left, *right))
// }
// BooleanExpression::BoolEq(left, right) => {
// ResolvedValue::Boolean(self.enforce_bool_equality(cs, scope, *left, *right))
// }
// BooleanExpression::IfElse(first, second, third) => {
// let resolved_first =
// match self.enforce_boolean_expression(cs, scope.clone(), *first) {
// ResolvedValue::Boolean(resolved) => resolved,
// _ => unimplemented!("if else conditional must resolve to boolean"),
// };
// if resolved_first.eq(&Boolean::Constant(true)) {
// self.enforce_boolean_expression(cs, scope, *second)
// } else {
// self.enforce_boolean_expression(cs, scope, *third)
// }
// }
// BooleanExpression::Array(array) => {
// let mut result = vec![];
// array.into_iter().for_each(|element| match *element {
// BooleanSpreadOrExpression::Spread(spread) => match spread {
// BooleanExpression::Variable(variable) => {
// let array_name = new_scope_from_variable(scope.clone(), &variable);
// match self.get(&array_name) {
// Some(value) => match value {
// ResolvedValue::BooleanArray(array) => {
// result.extend(array.clone())
// }
// value => unimplemented!(
// "spreads only implemented for arrays, got {}",
// value
// ),
// },
// None => unimplemented!(
// "cannot copy elements from array that does not exist {}",
// variable.name
// ),
// }
// }
// value => {
// unimplemented!("spreads only implemented for arrays, got {}", value)
// }
// },
// BooleanSpreadOrExpression::Expression(expression) => {
// match self.enforce_boolean_expression(cs, scope.clone(), expression) {
// ResolvedValue::Boolean(value) => result.push(value),
// value => {
// unimplemented!("expected boolean for boolean array, got {}", value)
// }
// }
// }
// });
// ResolvedValue::BooleanArray(result)
// }
// expression => unimplemented!("boolean expression {}", expression),
// }
// }
}

View File

@ -211,46 +211,6 @@ impl<F: Field + PrimeField, CS: ConstraintSystem<F>> ResolvedProgram<F, CS> {
}
}
}
// ResolvedValue::U32Array(field_array) => {
// match index {
// RangeOrExpression::Range(from, to) => {
// let from_resolved = match from {
// Some(from_index) => self.enforce_index(cs, scope.clone(), from_index),
// None => 0usize, // Array slice starts at index 0
// };
// let to_resolved = match to {
// Some(to_index) => self.enforce_index(cs, scope.clone(), to_index),
// None => field_array.len(), // Array slice ends at array length
// };
// ResolvedValue::U32Array(field_array[from_resolved..to_resolved].to_owned())
// }
// RangeOrExpression::Expression(index) => {
// let index_resolved = self.enforce_index(cs, scope.clone(), index);
// ResolvedValue::U32(field_array[index_resolved].to_owned())
// }
// }
// }
// ResolvedValue::BooleanArray(bool_array) => {
// match index {
// RangeOrExpression::Range(from, to) => {
// let from_resolved = match from {
// Some(from_index) => self.enforce_index(cs, scope.clone(), from_index),
// None => 0usize, // Array slice starts at index 0
// };
// let to_resolved = match to {
// Some(to_index) => self.enforce_index(cs, scope.clone(), to_index),
// None => bool_array.len(), // Array slice ends at array length
// };
// ResolvedValue::BooleanArray(
// bool_array[from_resolved..to_resolved].to_owned(),
// )
// }
// RangeOrExpression::Expression(index) => {
// let index_resolved = self.enforce_index(cs, scope.clone(), index);
// ResolvedValue::Boolean(bool_array[index_resolved].to_owned())
// }
// }
// }
value => unimplemented!("Cannot access element of untyped array {}", value),
}
}
@ -439,15 +399,6 @@ impl<F: Field + PrimeField, CS: ConstraintSystem<F>> ResolvedProgram<F, CS> {
Expression::FunctionCall(function, arguments) => {
self.enforce_function_access_expression(cs, scope, function, arguments)
}
// Expression::BooleanExp(boolean_expression) => {
// self.enforce_boolean_expression(cs, scope, boolean_expression)
// }
// Expression::IntegerExp(integer_expression) => {
// self.enforce_integer_expression(cs, scope, integer_expression)
// }
// Expression::FieldElementExp(field_expression) => {
// self.enforce_field_expression(cs, scope, field_expression)
// }
_ => unimplemented!(),
}
}

View File

@ -90,32 +90,6 @@ impl<F: Field + PrimeField, CS: ConstraintSystem<F>> ResolvedProgram<F, CS> {
// parameter_variable
}
// fn field_element_from_variable(&mut self, scope: String, variable: Variable<F>) -> F {
// // Evaluate variable name in current function scope
// let variable_name = new_scope_from_variable(scope, &variable);
//
// match self.get(&variable_name) {
// Some(value) => match value {
// ResolvedValue::FieldElement(fe) => fe.clone(),
// value => unimplemented!(
// "expected field element for variable {}, got {}",
// variable_name,
// value
// ),
// },
// None => unimplemented!("cannot resolve variable {} in program", variable_name),
// }
// }
// fn get_field_value(&mut self, cs: &mut CS, scope: String, expression: FieldExpression<F>) -> F {
// match expression {
// FieldExpression::Variable(variable) => {
// self.field_element_from_variable(scope, variable)
// }
// FieldExpression::Number(element) => element,
// }
// }
pub(crate) fn enforce_field_eq(&mut self, fe1: F, fe2: F) -> ResolvedValue<F> {
ResolvedValue::Boolean(Boolean::Constant(fe1.eq(&fe2)))
}
@ -141,137 +115,4 @@ impl<F: Field + PrimeField, CS: ConstraintSystem<F>> ResolvedProgram<F, CS> {
// ResolvedValue::FieldElement(fe1.pow(&fe2))
}
// fn enforce_field_add_old(
// &mut self,
// cs: &mut CS,
// scope: String,
// left: FieldExpression<F>,
// right: FieldExpression<F>,
// ) -> ResolvedValue<F> {
// let left = self.get_field_value(cs, scope.clone(), left);
// let right = self.get_field_value(cs, scope.clone(), right);
//
// ResolvedValue::FieldElement(left.add(&right))
// }
//
// fn enforce_field_sub_old(
// &mut self,
// cs: &mut CS,
// scope: String,
// left: FieldExpression<F>,
// right: FieldExpression<F>,
// ) -> ResolvedValue<F> {
// let left = self.get_field_value(cs, scope.clone(), left);
// let right = self.get_field_value(cs, scope.clone(), right);
//
// ResolvedValue::FieldElement(left.sub(&right))
// }
//
// fn enforce_field_mul_old(
// &mut self,
// cs: &mut CS,
// scope: String,
// left: FieldExpression<F>,
// right: FieldExpression<F>,
// ) -> ResolvedValue<F> {
// let left = self.get_field_value(cs, scope.clone(), left);
// let right = self.get_field_value(cs, scope.clone(), right);
//
// ResolvedValue::FieldElement(left.mul(&right))
// }
//
// fn enforce_field_div_old(
// &mut self,
// cs: &mut CS,
// scope: String,
// left: FieldExpression<F>,
// right: FieldExpression<F>,
// ) -> ResolvedValue<F> {
// let left = self.get_field_value(cs, scope.clone(), left);
// let right = self.get_field_value(cs, scope.clone(), right);
//
// ResolvedValue::FieldElement(left.div(&right))
// }
//
// fn enforce_field_pow_old(
// &mut self,
// _cs: &mut CS,
// _scope: String,
// _left: FieldExpression<F>,
// _right: FieldExpression<F>,
// ) -> ResolvedValue<F> {
// unimplemented!("field element exponentiation not supported")
// // let left = self.get_field_value(cs, scope.clone(), left);
// // let right = self.get_field_value(cs, scope.clone(), right);
// //
// // ResolvedValue::FieldElement(left.pow(&right))
// }
// pub(crate) fn enforce_field_expression(
// &mut self,
// cs: &mut CS,
// scope: String,
// expression: FieldExpression<F>,
// ) -> ResolvedValue<F> {
// match expression {
// FieldExpression::Variable(variable) => {
// ResolvedValue::FieldElement(self.field_element_from_variable(scope, variable))
// }
// FieldExpression::Number(field) => ResolvedValue::FieldElement(field),
// FieldExpression::Add(left, right) => self.enforce_field_add_old(cs, scope, *left, *right),
// FieldExpression::Sub(left, right) => self.enforce_field_sub_old(cs, scope, *left, *right),
// FieldExpression::Mul(left, right) => self.enforce_field_mul_old(cs, scope, *left, *right),
// FieldExpression::Div(left, right) => self.enforce_field_div_old(cs, scope, *left, *right),
// FieldExpression::Pow(left, right) => self.enforce_field_pow_old(cs, scope, *left, *right),
// FieldExpression::IfElse(first, second, third) => {
// let resolved_first =
// match self.enforce_boolean_expression(cs, scope.clone(), *first) {
// ResolvedValue::Boolean(resolved) => resolved,
// _ => unimplemented!("if else conditional must resolve to boolean"),
// };
//
// if resolved_first.eq(&Boolean::Constant(true)) {
// self.enforce_field_expression(cs, scope, *second)
// } else {
// self.enforce_field_expression(cs, scope, *third)
// }
// }
// FieldExpression::Array(array) => {
// let mut result = vec![];
// array.into_iter().for_each(|element| match *element {
// FieldSpreadOrExpression::Spread(spread) => match spread {
// FieldExpression::Variable(variable) => {
// let array_name = new_scope_from_variable(scope.clone(), &variable);
// match self.get(&array_name) {
// Some(value) => match value {
// ResolvedValue::FieldElementArray(array) => {
// result.extend(array.clone())
// }
// value => unimplemented!(
// "spreads only implemented for arrays, got {}",
// value
// ),
// },
// None => unimplemented!(
// "cannot copy elements from array that does not exist {}",
// variable.name
// ),
// }
// }
// value => {
// unimplemented!("spreads only implemented for arrays, got {}", value)
// }
// },
// FieldSpreadOrExpression::Expression(expression) => {
// match self.enforce_field_expression(cs, scope.clone(), expression) {
// ResolvedValue::FieldElement(value) => result.push(value),
// _ => unimplemented!("cannot resolve field"),
// }
// }
// });
// ResolvedValue::FieldElementArray(result)
// }
// }
// }
}

View File

@ -93,34 +93,11 @@ impl<F: Field + PrimeField, CS: ConstraintSystem<F>> ResolvedProgram<F, CS> {
// parameter_variable
}
// pub(crate) fn integer_from_variable(
// &mut self,
// scope: String,
// variable: Variable<F>,
// ) -> ResolvedValue<F> {
// // Evaluate variable name in current function scope
// let variable_name = new_scope_from_variable(scope, &variable);
//
// match self.get(&variable_name) {
// Some(value) => value.clone(),
// None => unimplemented!("cannot resolve variable {} in program", variable_name),
// }
// }
pub(crate) fn get_integer_constant(integer: Integer) -> ResolvedValue<F> {
match integer {
Integer::U32(u32_value) => ResolvedValue::U32(UInt32::constant(u32_value)),
}
}
//
// pub(crate) fn get_integer_value(
// integer: Integer
// ) -> ResolvedValue<F> {
// match expression {
// IntegerExpression::Variable(variable) => self.integer_from_variable(scope, variable),
// IntegerExpression::Number(number) => Self::get_integer_constant(number),
// }
// }
pub(crate) fn enforce_u32_eq(cs: &mut CS, left: UInt32, right: UInt32) -> ResolvedValue<F> {
left.conditional_enforce_equal(
@ -186,243 +163,4 @@ impl<F: Field + PrimeField, CS: ConstraintSystem<F>> ResolvedProgram<F, CS> {
.unwrap(),
)
}
// pub(crate) fn enforce_integer_equality(
// &mut self,
// cs: &mut CS,
// scope: String,
// left: UInt32,
// right: UInt32,
// ) -> Boolean {
// let left = self.get_integer_value(cs, scope.clone(), left);
// let right = self.get_integer_value(cs, scope.clone(), right);
//
// match (left, right) {
// (ResolvedValue::U32(left_u32), ResolvedValue::U32(right_u32)) => {
// Self::enforce_u32_equality(cs, left_u32, right_u32)
// }
// (left_int, right_int) => {
// unimplemented!("equality not impl between {} == {}", left_int, right_int)
// }
// }
// }
// fn enforce_integer_add_old(
// &mut self,
// cs: &mut CS,
// scope: String,
// left: IntegerExpression<F>,
// right: IntegerExpression<F>,
// ) -> ResolvedValue<F> {
// let left = self.get_integer_value(cs, scope.clone(), left);
// let right = self.get_integer_value(cs, scope.clone(), right);
//
// match (left, right) {
// (ResolvedValue::U32(left_u32), ResolvedValue::U32(right_u32)) => {
// Self::enforce_u32_add(cs, left_u32, right_u32)
// }
// (left_int, right_int) => {
// unimplemented!("add not impl between {} + {}", left_int, right_int)
// }
// }
// }
// fn enforce_u32_sub_old(cs: &mut CS, left: UInt32, right: UInt32) -> ResolvedValue<F> {
// ResolvedValue::U32(
// left.sub(
// cs.ns(|| format!("enforce {} - {}", left.value.unwrap(), right.value.unwrap())),
// &right,
// )
// .unwrap(),
// )
// }
// fn enforce_integer_sub(
// &mut self,
// cs: &mut CS,
// scope: String,
// left: IntegerExpression<F>,
// right: IntegerExpression<F>,
// ) -> ResolvedValue<F> {
// let left = self.get_integer_value(cs, scope.clone(), left);
// let right = self.get_integer_value(cs, scope.clone(), right);
//
// match (left, right) {
// (ResolvedValue::U32(left_u32), ResolvedValue::U32(right_u32)) => {
// Self::enforce_u32_sub_old(cs, left_u32, right_u32)
// }
// (left_int, right_int) => {
// unimplemented!("add not impl between {} + {}", left_int, right_int)
// }
// }
// }
// fn enforce_u32_mul_old(cs: &mut CS, left: UInt32, right: UInt32) -> ResolvedValue<F> {
// ResolvedValue::U32(
// left.mul(
// cs.ns(|| format!("enforce {} * {}", left.value.unwrap(), right.value.unwrap())),
// &right,
// )
// .unwrap(),
// )
// }
//
// fn enforce_integer_mul(
// &mut self,
// cs: &mut CS,
// scope: String,
// left: IntegerExpression<F>,
// right: IntegerExpression<F>,
// ) -> ResolvedValue<F> {
// let left = self.get_integer_value(cs, scope.clone(), left);
// let right = self.get_integer_value(cs, scope.clone(), right);
//
// match (left, right) {
// (ResolvedValue::U32(left_u32), ResolvedValue::U32(right_u32)) => {
// Self::enforce_u32_mul_old(cs, left_u32, right_u32)
// }
// (left_int, right_int) => {
// unimplemented!("add not impl between {} + {}", left_int, right_int)
// }
// }
// }
//
// fn enforce_u32_div_old(cs: &mut CS, left: UInt32, right: UInt32) -> ResolvedValue<F> {
// ResolvedValue::U32(
// left.div(
// cs.ns(|| format!("enforce {} / {}", left.value.unwrap(), right.value.unwrap())),
// &right,
// )
// .unwrap(),
// )
// }
//
// fn enforce_integer_div(
// &mut self,
// cs: &mut CS,
// scope: String,
// left: IntegerExpression<F>,
// right: IntegerExpression<F>,
// ) -> ResolvedValue<F> {
// let left = self.get_integer_value(cs, scope.clone(), left);
// let right = self.get_integer_value(cs, scope.clone(), right);
//
// match (left, right) {
// (ResolvedValue::U32(left_u32), ResolvedValue::U32(right_u32)) => {
// Self::enforce_u32_div_old(cs, left_u32, right_u32)
// }
// (left_int, right_int) => {
// unimplemented!("add not impl between {} + {}", left_int, right_int)
// }
// }
// }
//
// fn enforce_u32_pow_old(cs: &mut CS, left: UInt32, right: UInt32) -> ResolvedValue<F> {
// ResolvedValue::U32(
// left.pow(
// cs.ns(|| {
// format!(
// "enforce {} ** {}",
// left.value.unwrap(),
// right.value.unwrap()
// )
// }),
// &right,
// )
// .unwrap(),
// )
// }
//
// fn enforce_integer_pow(
// &mut self,
// cs: &mut CS,
// scope: String,
// left: IntegerExpression<F>,
// right: IntegerExpression<F>,
// ) -> ResolvedValue<F> {
// let left = self.get_integer_value(cs, scope.clone(), left);
// let right = self.get_integer_value(cs, scope.clone(), right);
//
// match (left, right) {
// (ResolvedValue::U32(left_u32), ResolvedValue::U32(right_u32)) => {
// Self::enforce_u32_pow_old(cs, left_u32, right_u32)
// }
// (left_int, right_int) => {
// unimplemented!("add not impl between {} + {}", left_int, right_int)
// }
// }
// }
// pub(crate) fn enforce_integer_expression(
// &mut self,
// cs: &mut CS,
// scope: String,
// expression: IntegerExpression<F>,
// ) -> ResolvedValue<F> {
// match expression {
// IntegerExpression::Variable(variable) => self.integer_from_variable(scope, variable),
// IntegerExpression::Number(number) => Self::get_integer_constant(number),
// IntegerExpression::Add(left, right) => {
// self.enforce_integer_add_old(cs, scope, *left, *right)
// }
// IntegerExpression::Sub(left, right) => {
// self.enforce_integer_sub(cs, scope, *left, *right)
// }
// IntegerExpression::Mul(left, right) => {
// self.enforce_integer_mul(cs, scope, *left, *right)
// }
// IntegerExpression::Div(left, right) => {
// self.enforce_integer_div(cs, scope, *left, *right)
// }
// IntegerExpression::Pow(left, right) => {
// self.enforce_integer_pow(cs, scope, *left, *right)
// }
// IntegerExpression::IfElse(first, second, third) => {
// let resolved_first =
// match self.enforce_boolean_expression(cs, scope.clone(), *first) {
// ResolvedValue::Boolean(resolved) => resolved,
// _ => unimplemented!("if else conditional must resolve to boolean"),
// };
//
// if resolved_first.eq(&Boolean::Constant(true)) {
// self.enforce_integer_expression(cs, scope, *second)
// } else {
// self.enforce_integer_expression(cs, scope, *third)
// }
// }
// IntegerExpression::Array(array) => {
// let mut result = vec![];
// array.into_iter().for_each(|element| match *element {
// IntegerSpreadOrExpression::Spread(spread) => match spread {
// IntegerExpression::Variable(variable) => {
// let array_name = new_scope_from_variable(scope.clone(), &variable);
// match self.get(&array_name) {
// Some(value) => match value {
// ResolvedValue::U32Array(array) => result.extend(array.clone()),
// value => unimplemented!(
// "spreads only implemented for arrays, got {}",
// value
// ),
// },
// None => unimplemented!(
// "cannot copy elements from array that does not exist {}",
// variable.name
// ),
// }
// }
// value => {
// unimplemented!("spreads only implemented for arrays, got {}", value)
// }
// },
// IntegerSpreadOrExpression::Expression(expression) => {
// match self.enforce_integer_expression(cs, scope.clone(), expression) {
// ResolvedValue::U32(value) => result.push(value),
// _ => unimplemented!("cannot resolve field"),
// }
// }
// });
// ResolvedValue::U32Array(result)
// }
// }
// }
}

View File

@ -29,15 +29,6 @@ impl<F: Field + PrimeField> ResolvedValue<F> {
(ResolvedValue::FieldElement(ref _a), Type::FieldElement) => true,
(ResolvedValue::Boolean(ref _a), Type::Boolean) => true,
(ResolvedValue::Array(ref _arr), Type::Array(ref _ty, ref _len)) => true, // todo: add array types
// (ResolvedValue::U32Array(ref arr), Type::Array(ref arr_type, ref len)) => {
// (arr.len() == *len) & (**arr_type == Type::U32)
// }
// (ResolvedValue::FieldElementArray(ref arr), Type::Array(ref arr_type, ref len)) => {
// (arr.len() == *len) & (**arr_type == Type::FieldElement)
// }
// (ResolvedValue::BooleanArray(ref arr), Type::Array(ref arr_type, ref len)) => {
// (arr.len() == *len) & (**arr_type == Type::Boolean)
// }
(
ResolvedValue::StructExpression(ref actual_name, ref _members),
Type::Struct(ref expected_name),
@ -70,36 +61,6 @@ impl<F: Field + PrimeField> fmt::Display for ResolvedValue<F> {
}
write!(f, "]")
}
// ResolvedValue::U32Array(ref array) => {
// write!(f, "[")?;
// for (i, e) in array.iter().enumerate() {
// write!(f, "{}", e.value.unwrap())?;
// if i < array.len() - 1 {
// write!(f, ", ")?;
// }
// }
// write!(f, "]")
// }
// ResolvedValue::FieldElementArray(ref array) => {
// write!(f, "[")?;
// for (i, e) in array.iter().enumerate() {
// write!(f, "{}", e)?;
// if i < array.len() - 1 {
// write!(f, ", ")?;
// }
// }
// write!(f, "]")
// }
// ResolvedValue::BooleanArray(ref array) => {
// write!(f, "[")?;
// for (i, e) in array.iter().enumerate() {
// write!(f, "{}", e.get_value().unwrap())?;
// if i < array.len() - 1 {
// write!(f, ", ")?;
// }
// }
// write!(f, "]")
// }
ResolvedValue::StructExpression(ref variable, ref members) => {
write!(f, "{} {{", variable)?;
for (i, member) in members.iter().enumerate() {

View File

@ -30,7 +30,8 @@ impl Integer {
pub fn to_usize(&self) -> usize {
match *self {
// U8(u8)
Integer::U32(num) => num as usize, // U64(u64)
Integer::U32(num) => num as usize,
// U64(u64)
}
}
}
@ -90,9 +91,6 @@ pub enum Expression<F: Field + PrimeField> {
// Functions
FunctionCall(Box<Expression<F>>, Vec<Expression<F>>),
// IntegerExp(IntegerExpression<F>),
// FieldElementExp(FieldExpression<F>),
// BooleanExp(BooleanExpression<F>),
}
/// Definition assignee: v, arr[0..2], Point p.x
@ -185,95 +183,3 @@ impl<'ast, F: Field + PrimeField> Program<'ast, F> {
self
}
}
// /// Spread operator or u32 expression enum
// #[derive(Debug, Clone)]
// pub enum IntegerSpreadOrExpression<F: Field + PrimeField> {
// Spread(IntegerExpression<F>),
// Expression(IntegerExpression<F>),
// }
// Expression that evaluates to a u32 value
// #[derive(Debug, Clone)]
// pub enum IntegerExpression<F: Field + PrimeField> {
// Variable(Variable<F>),
// Number(Integer),
// Operators
// Add(Box<IntegerExpression<F>>, Box<IntegerExpression<F>>),
// Sub(Box<IntegerExpression<F>>, Box<IntegerExpression<F>>),
// Mul(Box<IntegerExpression<F>>, Box<IntegerExpression<F>>),
// Div(Box<IntegerExpression<F>>, Box<IntegerExpression<F>>),
// Pow(Box<IntegerExpression<F>>, Box<IntegerExpression<F>>),
// Conditionals
// IfElse(
// Box<BooleanExpression<F>>,
// Box<IntegerExpression<F>>,
// Box<IntegerExpression<F>>,
// ),
// Arrays
// Array(Vec<Box<IntegerSpreadOrExpression<F>>>),
// // Unresolved
// Unresolved(Box<Expression<F>>) // placeholder for array/struct access, function calls
// }
// /// Spread or field expression enum
// #[derive(Debug, Clone)]
// pub enum FieldSpreadOrExpression<F: Field + PrimeField> {
// Spread(FieldExpression<F>),
// Expression(FieldExpression<F>),
// }
// /// Expression that evaluates to a field value
// #[derive(Debug, Clone)]
// pub enum FieldExpression<F: Field + PrimeField> {
// Variable(Variable<F>),
// Number(F),
// Operators
// Add(Box<FieldExpression<F>>, Box<FieldExpression<F>>),
// Sub(Box<FieldExpression<F>>, Box<FieldExpression<F>>),
// Mul(Box<FieldExpression<F>>, Box<FieldExpression<F>>),
// Div(Box<FieldExpression<F>>, Box<FieldExpression<F>>),
// Pow(Box<FieldExpression<F>>, Box<FieldExpression<F>>),
// Conditionals
// IfElse(
// Box<BooleanExpression<F>>,
// Box<FieldExpression<F>>,
// Box<FieldExpression<F>>,
// ),
// Arrays
// Array(Vec<Box<FieldSpreadOrExpression<F>>>),
// }
// /// Spread or field expression enum
// #[derive(Debug, Clone)]
// pub enum BooleanSpreadOrExpression<F: Field + PrimeField> {
// Spread(BooleanExpression<F>),
// Expression(BooleanExpression<F>),
// }
// Expression that evaluates to a boolean value
// #[derive(Debug, Clone)]
// pub enum BooleanExpression<F: Field + PrimeField> {
// Variable(Variable<F>),
// Value(bool),
// Boolean operators
// Or(Box<BooleanExpression<F>>, Box<BooleanExpression<F>>),
// And(Box<BooleanExpression<F>>, Box<BooleanExpression<F>>),
// BoolEq(Box<BooleanExpression<F>>, Box<BooleanExpression<F>>),
// // Integer operators
// IntegerEq(Box<IntegerExpression<F>>, Box<IntegerExpression<F>>),
// Geq(Box<IntegerExpression<F>>, Box<IntegerExpression<F>>),
// Gt(Box<IntegerExpression<F>>, Box<IntegerExpression<F>>),
// Leq(Box<IntegerExpression<F>>, Box<IntegerExpression<F>>),
// Lt(Box<IntegerExpression<F>>, Box<IntegerExpression<F>>),
// // Field operators
// FieldEq(Box<FieldExpression<F>>, Box<FieldExpression<F>>),
// Conditionals
// IfElse(
// Box<BooleanExpression<F>>,
// Box<BooleanExpression<F>>,
// Box<BooleanExpression<F>>,
// ),
// Arrays
// Array(Vec<Box<BooleanSpreadOrExpression<F>>>),
// }

View File

@ -282,117 +282,3 @@ impl<F: Field + PrimeField> fmt::Debug for Function<F> {
)
}
}
// impl<F: Field + PrimeField> fmt::Display for IntegerSpreadOrExpression<F> {
// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
// match *self {
// IntegerSpreadOrExpression::Spread(ref spread) => write!(f, "...{}", spread),
// IntegerSpreadOrExpression::Expression(ref expression) => write!(f, "{}", expression),
// }
// }
// }
// impl<'ast, F: Field + PrimeField> fmt::Display for IntegerExpression<F> {
// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
// match *self {
// IntegerExpression::Variable(ref variable) => write!(f, "{}", variable),
// IntegerExpression::Number(ref number) => write!(f, "{}", number),
// IntegerExpression::Add(ref lhs, ref rhs) => write!(f, "{} + {}", lhs, rhs),
// IntegerExpression::Sub(ref lhs, ref rhs) => write!(f, "{} - {}", lhs, rhs),
// IntegerExpression::Mul(ref lhs, ref rhs) => write!(f, "{} * {}", lhs, rhs),
// IntegerExpression::Div(ref lhs, ref rhs) => write!(f, "{} / {}", lhs, rhs),
// IntegerExpression::Pow(ref lhs, ref rhs) => write!(f, "{} ** {}", lhs, rhs),
// IntegerExpression::IfElse(ref a, ref b, ref c) => {
// write!(f, "if {} then {} else {} fi", a, b, c)
// }
// IntegerExpression::Array(ref array) => {
// write!(f, "[")?;
// for (i, e) in array.iter().enumerate() {
// write!(f, "{}", e)?;
// if i < array.len() - 1 {
// write!(f, ", ")?;
// }
// }
// write!(f, "]")
// }
// }
// }
// }
// impl<F: Field + PrimeField> fmt::Display for FieldSpreadOrExpression<F> {
// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
// match *self {
// FieldSpreadOrExpression::Spread(ref spread) => write!(f, "...{}", spread),
// FieldSpreadOrExpression::Expression(ref expression) => write!(f, "{}", expression),
// }
// }
// }
//
// impl<'ast, F: Field + PrimeField> fmt::Display for FieldExpression<F> {
// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
// match *self {
// FieldExpression::Variable(ref variable) => write!(f, "{}", variable),
// FieldExpression::Number(ref number) => write!(f, "{}", number),
// FieldExpression::Add(ref lhs, ref rhs) => write!(f, "{} + {}", lhs, rhs),
// FieldExpression::Sub(ref lhs, ref rhs) => write!(f, "{} - {}", lhs, rhs),
// FieldExpression::Mul(ref lhs, ref rhs) => write!(f, "{} * {}", lhs, rhs),
// FieldExpression::Div(ref lhs, ref rhs) => write!(f, "{} / {}", lhs, rhs),
// FieldExpression::Pow(ref lhs, ref rhs) => write!(f, "{} ** {}", lhs, rhs),
// FieldExpression::IfElse(ref a, ref b, ref c) => {
// write!(f, "if {} then {} else {} fi", a, b, c)
// }
// FieldExpression::Array(ref array) => {
// write!(f, "[")?;
// for (i, e) in array.iter().enumerate() {
// write!(f, "{}", e)?;
// if i < array.len() - 1 {
// write!(f, ", ")?;
// }
// }
// write!(f, "]")
// } // _ => unimplemented!("not all field expressions can be displayed")
// }
// }
// }
// impl<F: Field + PrimeField> fmt::Display for BooleanSpreadOrExpression<F> {
// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
// match *self {
// BooleanSpreadOrExpression::Spread(ref spread) => write!(f, "...{}", spread),
// BooleanSpreadOrExpression::Expression(ref expression) => write!(f, "{}", expression),
// }
// }
// }
// impl<'ast, F: Field + PrimeField> fmt::Display for BooleanExpression<F> {
// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
// match *self {
// BooleanExpression::Variable(ref variable) => write!(f, "{}", variable),
// BooleanExpression::Value(ref value) => write!(f, "{}", value),
// BooleanExpression::Not(ref expression) => write!(f, "!{}", expression),
// BooleanExpression::Or(ref lhs, ref rhs) => write!(f, "{} || {}", lhs, rhs),
// BooleanExpression::And(ref lhs, ref rhs) => write!(f, "{} && {}", lhs, rhs),
// BooleanExpression::BoolEq(ref lhs, ref rhs) => write!(f, "{} == {}", lhs, rhs),
// BooleanExpression::IntegerEq(ref lhs, ref rhs) => write!(f, "{} == {}", lhs, rhs),
// BooleanExpression::FieldEq(ref lhs, ref rhs) => write!(f, "{} == {}", lhs, rhs),
// // BooleanExpression::Neq(ref lhs, ref rhs) => write!(f, "{} != {}", lhs, rhs),
// BooleanExpression::Geq(ref lhs, ref rhs) => write!(f, "{} >= {}", lhs, rhs),
// BooleanExpression::Gt(ref lhs, ref rhs) => write!(f, "{} > {}", lhs, rhs),
// BooleanExpression::Leq(ref lhs, ref rhs) => write!(f, "{} <= {}", lhs, rhs),
// BooleanExpression::Lt(ref lhs, ref rhs) => write!(f, "{} < {}", lhs, rhs),
// BooleanExpression::IfElse(ref a, ref b, ref c) => {
// write!(f, "if {} then {} else {} fi", a, b, c)
// }
// BooleanExpression::Array(ref array) => {
// write!(f, "[")?;
// for (i, e) in array.iter().enumerate() {
// write!(f, "{}", e)?;
// if i < array.len() - 1 {
// write!(f, ", ")?;
// }
// }
// write!(f, "]")
// }
// }
// }
// }

View File

@ -42,33 +42,6 @@ impl<'ast, F: Field + PrimeField> From<ast::U32<'ast>> for types::Expression<F>
}
}
// impl<'ast, F: Field + PrimeField> From<ast::Expression<'ast>> for types::Expression<F> {
// fn from(expression: ast::Expression<'ast>) -> Self {
// match types::Expression::from(expression) {
// types::Expression::Variable(variable) => types::IntegerExpression::Variable(variable),
// types::Expression::IntegerExp(integer_expression) => integer_expression,
// expression => unimplemented!("expected integer in integer expression, got {}", expression),
// }
// }
// }
// impl<'ast, F: Field + PrimeField> From<ast::SpreadOrExpression<'ast>>
// for types::IntegerSpreadOrExpression<F>
// {
// fn from(s_or_e: ast::SpreadOrExpression<'ast>) -> Self {
// match s_or_e {
// ast::SpreadOrExpression::Spread(spread) => types::IntegerSpreadOrExpression::Spread(
// types::IntegerExpression::from(spread.expression),
// ),
// ast::SpreadOrExpression::Expression(expression) => {
// types::IntegerSpreadOrExpression::Expression(types::IntegerExpression::from(
// expression,
// ))
// }
// }
// }
// }
impl<'ast, F: Field + PrimeField> From<ast::RangeOrExpression<'ast>>
for types::RangeOrExpression<F>
{
@ -99,12 +72,6 @@ impl<'ast, F: Field + PrimeField> From<ast::RangeOrExpression<'ast>>
}
}
//
// impl<'ast, F: Field + PrimeField> From<ast::Variable<'ast>> for types::FieldExpression<F> {
// fn from(variable: ast::Variable<'ast>) -> Self {
// types::FieldExpression::Variable(types::Variable::from(variable))
// }
// }
/// pest ast -> types::FieldExpression
impl<'ast, F: Field + PrimeField> From<ast::Field<'ast>> for types::Expression<F> {
@ -113,37 +80,6 @@ impl<'ast, F: Field + PrimeField> From<ast::Field<'ast>> for types::Expression<F
}
}
// impl<'ast, F: Field + PrimeField> From<ast::Expression<'ast>> for types::FieldExpression<F> {
// fn from(expression: ast::Expression<'ast>) -> Self {
// match types::Expression::from(expression) {
// types::Expression::FieldElementExp(field_expression) => field_expression,
// types::Expression::Variable(variable) => types::FieldExpression::Variable(variable),
// expression => unimplemented!("expected field in field expression, got {}", expression),
// }
// }
// }
// impl<'ast, F: Field + PrimeField> From<ast::SpreadOrExpression<'ast>>
// for types::FieldSpreadOrExpression<F>
// {
// fn from(s_or_e: ast::SpreadOrExpression<'ast>) -> Self {
// match s_or_e {
// ast::SpreadOrExpression::Spread(spread) => types::FieldSpreadOrExpression::Spread(
// types::FieldExpression::from(spread.expression),
// ),
// ast::SpreadOrExpression::Expression(expression) => {
// types::FieldSpreadOrExpression::Expression(types::FieldExpression::from(expression))
// }
// }
// }
// }
// impl<'ast, F: Field + PrimeField> From<ast::Variable<'ast>> for types::BooleanExpression<F> {
// fn from(variable: ast::Variable<'ast>) -> Self {
// types::BooleanExpression::Variable(types::Variable::from(variable))
// }
// }
/// pest ast -> types::Boolean
impl<'ast, F: Field + PrimeField> From<ast::Boolean<'ast>> for types::Expression<F> {
@ -157,33 +93,6 @@ impl<'ast, F: Field + PrimeField> From<ast::Boolean<'ast>> for types::Expression
}
}
// impl<'ast, F: Field + PrimeField> From<ast::Expression<'ast>> for types::BooleanExpression<F> {
// fn from(expression: ast::Expression<'ast>) -> Self {
// match types::Expression::from(expression) {
// types::Expression::BooleanExp(boolean_expression) => boolean_expression,
// types::Expression::Variable(variable) => types::BooleanExpression::Variable(variable),
// expression => unimplemented!("expected boolean in boolean expression, got {}", expression),
// }
// }
// }
// impl<'ast, F: Field + PrimeField> From<ast::SpreadOrExpression<'ast>>
// for types::BooleanSpreadOrExpression<F>
// {
// fn from(s_or_e: ast::SpreadOrExpression<'ast>) -> Self {
// match s_or_e {
// ast::SpreadOrExpression::Spread(spread) => types::BooleanSpreadOrExpression::Spread(
// types::BooleanExpression::from(spread.expression),
// ),
// ast::SpreadOrExpression::Expression(expression) => {
// types::BooleanSpreadOrExpression::Expression(types::BooleanExpression::from(
// expression,
// ))
// }
// }
// }
// }
/// pest ast -> types::Expression
impl<'ast, F: Field + PrimeField> From<ast::Value<'ast>> for types::Expression<F> {
@ -196,107 +105,12 @@ impl<'ast, F: Field + PrimeField> From<ast::Value<'ast>> for types::Expression<F
}
}
// impl<'ast, F: Field + PrimeField> From<ast::Variable<'ast>> for types::Expression<F> {
// fn from(variable: ast::Variable<'ast>) -> Self {
// types::Expression::Variable(types::Variable::from(variable))
// }
// }
impl<'ast, F: Field + PrimeField> From<ast::NotExpression<'ast>> for types::Expression<F> {
fn from(expression: ast::NotExpression<'ast>) -> Self {
types::Expression::Not(Box::new(types::Expression::from(*expression.expression)))
}
}
// impl<'ast, F: Field + PrimeField> types::BooleanExpression<F> {
// /// Find out which types we are comparing and output the corresponding expression.
// fn from_eq(expression: ast::BinaryExpression<'ast>) -> Self {
// let left = types::Expression::from(*expression.left);
// let right = types::Expression::from(*expression.right);
//
// // When matching a variable, look at the opposite side to see what we are comparing to and assume that variable type
// match (left, right) {
// // Boolean equality
// (types::Expression::BooleanExp(lhs), types::Expression::BooleanExp(rhs)) => {
// types::BooleanExpression::BoolEq(Box::new(lhs), Box::new(rhs))
// }
// (types::Expression::BooleanExp(lhs), types::Expression::Variable(rhs)) => {
// types::BooleanExpression::BoolEq(
// Box::new(lhs),
// Box::new(types::BooleanExpression::Variable(rhs)),
// )
// }
// (types::Expression::Variable(lhs), types::Expression::BooleanExp(rhs)) => {
// types::BooleanExpression::BoolEq(
// Box::new(types::BooleanExpression::Variable(lhs)),
// Box::new(rhs),
// )
// } //TODO: check case for two variables?
// // Integer equality
// (types::Expression::IntegerExp(lhs), types::Expression::IntegerExp(rhs)) => {
// types::BooleanExpression::IntegerEq(Box::new(lhs), Box::new(rhs))
// }
// (types::Expression::IntegerExp(lhs), types::Expression::Variable(rhs)) => {
// types::BooleanExpression::IntegerEq(
// Box::new(lhs),
// Box::new(types::IntegerExpression::Variable(rhs)),
// )
// }
// (types::Expression::Variable(lhs), types::Expression::IntegerExp(rhs)) => {
// types::BooleanExpression::IntegerEq(
// Box::new(types::IntegerExpression::Variable(lhs)),
// Box::new(rhs),
// )
// }
// // Field equality
// (types::Expression::FieldElementExp(lhs), types::Expression::FieldElementExp(rhs)) => {
// types::BooleanExpression::FieldEq(Box::new(lhs), Box::new(rhs))
// }
// (types::Expression::FieldElementExp(lhs), types::Expression::Variable(rhs)) => {
// types::BooleanExpression::FieldEq(
// Box::new(lhs),
// Box::new(types::FieldExpression::Variable(rhs)),
// )
// }
// (types::Expression::Variable(lhs), types::Expression::FieldElementExp(rhs)) => {
// types::BooleanExpression::FieldEq(
// Box::new(types::FieldExpression::Variable(lhs)),
// Box::new(rhs),
// )
// }
//
// (lhs, rhs) => unimplemented!("pattern {} == {} unimplemented", lhs, rhs),
// }
// }
//
// fn from_neq(expression: ast::BinaryExpression<'ast>) -> Self {
// types::BooleanExpression::Not(Box::new(Self::from_eq(expression)))
// }
// }
// impl<'ast, F: Field + PrimeField> types::Type<F> {
// fn resolve_type(left: &Box<ast::Expression<'ast>>, right: &Box<ast::Expression<'ast>>) -> Self {
// let left = types::Expression::<F>::from(*left.clone());
// let right = types::Expression::<F>::from(*right.clone());
//
// match (left, right) {
// // Integer operation
// (types::Expression::IntegerExp(_), _) | (_, types::Expression::IntegerExp(_)) => {
// types::Type::U32
// }
// // Field operation
// (types::Expression::FieldElementExp(_), _) | (_, types::Expression::FieldElementExp(_)) => {
// types::Type::FieldElement
// }
// // Unmatched: two array accesses, two variables
// (lhs, rhs) => unimplemented!(
// "operand types {} and {} must match for binary expression",
// lhs,
// rhs
// ),
// }
// }
// }
impl<'ast, F: Field + PrimeField> From<ast::SpreadOrExpression<'ast>>
for types::SpreadOrExpression<F>
{
@ -374,92 +188,11 @@ impl<'ast, F: Field + PrimeField> From<ast::BinaryExpression<'ast>> for types::E
impl<'ast, F: Field + PrimeField> From<ast::TernaryExpression<'ast>> for types::Expression<F> {
fn from(expression: ast::TernaryExpression<'ast>) -> Self {
// Evaluate expressions to find out result type
// let first = ;
// let second = ;
// let third = ;
types::Expression::IfElse(
Box::new(types::Expression::from(*expression.first)),
Box::new(types::Expression::from(*expression.second)),
Box::new(types::Expression::from(*expression.third)),
)
// match (second, third) {
// // Boolean Result
// (types::Expression::BooleanExp(second), types::Expression::BooleanExp(third)) => {
// types::Expression::BooleanExp(types::Expression::IfElse(
// Box::new(first),
// Box::new(second),
// Box::new(third),
// ))
// }
// (types::Expression::BooleanExp(second), types::Expression::Variable(third)) => {
// types::Expression::BooleanExp(types::BooleanExpression::IfElse(
// Box::new(first),
// Box::new(second),
// Box::new(types::BooleanExpression::Variable(third)),
// ))
// }
// (types::Expression::Variable(second), types::Expression::BooleanExp(third)) => {
// types::Expression::BooleanExp(types::BooleanExpression::IfElse(
// Box::new(first),
// Box::new(types::BooleanExpression::Variable(second)),
// Box::new(third),
// ))
// }
// // Integer Result
// (types::Expression::IntegerExp(second), types::Expression::IntegerExp(third)) => {
// types::Expression::IntegerExp(types::IntegerExpression::IfElse(
// Box::new(first),
// Box::new(second),
// Box::new(third),
// ))
// }
// (types::Expression::IntegerExp(second), types::Expression::Variable(third)) => {
// types::Expression::IntegerExp(types::IntegerExpression::IfElse(
// Box::new(first),
// Box::new(second),
// Box::new(types::IntegerExpression::Variable(third)),
// ))
// }
// (types::Expression::Variable(second), types::Expression::IntegerExp(third)) => {
// types::Expression::IntegerExp(types::IntegerExpression::IfElse(
// Box::new(first),
// Box::new(types::IntegerExpression::Variable(second)),
// Box::new(third),
// ))
// }
// // Field Result
// (types::Expression::FieldElementExp(second), types::Expression::FieldElementExp(third)) => {
// types::Expression::FieldElementExp(types::FieldExpression::IfElse(
// Box::new(first),
// Box::new(second),
// Box::new(third),
// ))
// }
// (types::Expression::FieldElementExp(second), types::Expression::Variable(third)) => {
// types::Expression::FieldElementExp(types::FieldExpression::IfElse(
// Box::new(first),
// Box::new(second),
// Box::new(types::FieldExpression::Variable(third)),
// ))
// }
// (types::Expression::Variable(second), types::Expression::FieldElementExp(third)) => {
// types::Expression::FieldElementExp(types::FieldExpression::IfElse(
// Box::new(first),
// Box::new(types::FieldExpression::Variable(second)),
// Box::new(third),
// ))
// }
//
// (second, third) => unimplemented!(
// "pattern if {} then {} else {} unimplemented",
// first,
// second,
// third
// ),
// }
}
}
@ -545,10 +278,6 @@ impl<'ast, F: Field + PrimeField> From<ast::Expression<'ast>> for types::Express
/// For defined types (ex: u32[4]) we manually construct the expression instead of implementing the From trait.
/// This saves us from having to resolve things at a later point in time.
impl<'ast, F: Field + PrimeField> types::Expression<F> {
// fn from_basic(_ty: ast::BasicType<'ast>, expression: ast::Expression<'ast>) -> Self {
// types::Expression::from(expression)
// }
fn get_count(count: ast::Value<'ast>) -> usize {
match count {
ast::Value::U32(f) => f
@ -560,65 +289,6 @@ impl<'ast, F: Field + PrimeField> types::Expression<F> {
}
}
// fn from_array(ty: ast::ArrayType<'ast>, expression: ast::Expression<'ast>) -> Self {
// match ty.ty {
// ast::BasicType::U32(_ty) => {
// let elements: Vec<Box<types::IntegerSpreadOrExpression<F>>> = match expression {
// ast::Expression::ArrayInline(array) => array
// .expressions
// .into_iter()
// .map(|s_or_e| Box::new(types::IntegerSpreadOrExpression::from(s_or_e)))
// .collect(),
// ast::Expression::ArrayInitializer(array) => {
// let count = types::Expression::<F>::get_count(array.count);
// let expression =
// Box::new(types::IntegerSpreadOrExpression::from(*array.expression));
//
// vec![expression; count]
// }
// _ => unimplemented!("expected array after array type"),
// };
// types::Expression::IntegerExp(types::IntegerExpression::Array(elements))
// }
// ast::BasicType::Field(_ty) => {
// let elements: Vec<Box<types::FieldSpreadOrExpression<F>>> = match expression {
// ast::Expression::ArrayInline(array) => array
// .expressions
// .into_iter()
// .map(|s_or_e| Box::new(types::FieldSpreadOrExpression::from(s_or_e)))
// .collect(),
// ast::Expression::ArrayInitializer(array) => {
// let count = types::Expression::<F>::get_count(array.count);
// let expression =
// Box::new(types::FieldSpreadOrExpression::from(*array.expression));
//
// vec![expression; count]
// }
// _ => unimplemented!("expected array after array type"),
// };
// types::Expression::FieldElementExp(types::FieldExpression::Array(elements))
// }
// ast::BasicType::Boolean(_ty) => {
// let elements: Vec<Box<types::BooleanSpreadOrExpression<F>>> = match expression {
// ast::Expression::ArrayInline(array) => array
// .expressions
// .into_iter()
// .map(|s_or_e| Box::new(types::BooleanSpreadOrExpression::from(s_or_e)))
// .collect(),
// ast::Expression::ArrayInitializer(array) => {
// let count = types::Expression::<F>::get_count(array.count);
// let expression =
// Box::new(types::BooleanSpreadOrExpression::from(*array.expression));
//
// vec![expression; count]
// }
// _ => unimplemented!("expected array after array type"),
// };
// types::Expression::BooleanExp(types::BooleanExpression::Array(elements))
// }
// }
// }
fn from_struct(ty: ast::StructType<'ast>, expression: ast::Expression<'ast>) -> Self {
let declaration_struct = ty.variable.value;
match expression {