mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-09-20 02:07:38 +03:00
parse boolean later in program
This commit is contained in:
parent
0159b1c0cc
commit
5f0b3e2b0c
@ -6,6 +6,7 @@ use crate::{
|
||||
enforce_or,
|
||||
errors::ExpressionError,
|
||||
evaluate_not,
|
||||
new_bool_constant,
|
||||
new_scope,
|
||||
FieldType,
|
||||
GroupType,
|
||||
@ -902,7 +903,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
Expression::Integer(integer) => Ok(ConstrainedValue::Integer(integer)),
|
||||
Expression::Field(field, span) => Ok(ConstrainedValue::Field(FieldType::constant(field, span)?)),
|
||||
Expression::Group(group_affine, span) => Ok(ConstrainedValue::Group(G::constant(group_affine, span)?)),
|
||||
Expression::Boolean(bool) => Ok(ConstrainedValue::Boolean(bool)),
|
||||
Expression::Boolean(boolean, span) => Ok(ConstrainedValue::Boolean(new_bool_constant(boolean, span)?)),
|
||||
Expression::Implicit(value, span) => Self::enforce_number_implicit(expected_types, value, span),
|
||||
|
||||
// Binary operations
|
||||
|
@ -16,8 +16,6 @@ use leo_ast::{
|
||||
values::{BooleanValue, FieldValue, GroupValue, IntegerValue, NumberImplicitValue, Value},
|
||||
};
|
||||
|
||||
use snarkos_models::gadgets::utilities::boolean::Boolean;
|
||||
|
||||
use std::fmt;
|
||||
|
||||
/// Expression that evaluates to a value
|
||||
@ -30,7 +28,7 @@ pub enum Expression {
|
||||
Integer(Integer),
|
||||
Field(String, Span),
|
||||
Group(String, Span),
|
||||
Boolean(Boolean),
|
||||
Boolean(String, Span),
|
||||
Implicit(String, Span),
|
||||
|
||||
// Number operations
|
||||
@ -125,7 +123,7 @@ impl<'ast> fmt::Display for Expression {
|
||||
Expression::Integer(ref integer) => write!(f, "{}", integer),
|
||||
Expression::Field(ref field, ref _span) => write!(f, "{}", field),
|
||||
Expression::Group(ref group, ref _span) => write!(f, "{}", group),
|
||||
Expression::Boolean(ref bool) => write!(f, "{}", bool.get_value().unwrap()),
|
||||
Expression::Boolean(ref bool, ref _span) => write!(f, "{}", bool),
|
||||
Expression::Implicit(ref value, ref _span) => write!(f, "{}", value),
|
||||
|
||||
// Number operations
|
||||
@ -438,9 +436,7 @@ impl<'ast> From<GroupValue<'ast>> for Expression {
|
||||
|
||||
impl<'ast> From<BooleanValue<'ast>> for Expression {
|
||||
fn from(boolean: BooleanValue<'ast>) -> Self {
|
||||
Expression::Boolean(Boolean::Constant(
|
||||
boolean.value.parse::<bool>().expect("unable to parse boolean"),
|
||||
))
|
||||
Expression::Boolean(boolean.value, Span::from(boolean.span))
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user