mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-09-11 05:45:30 +03:00
add circuit function types
This commit is contained in:
parent
7640d27db4
commit
b766f96d23
@ -230,6 +230,8 @@ pub enum Statement<F: Field + PrimeField, G: Group> {
|
||||
Expression(Expression<F, G>),
|
||||
}
|
||||
|
||||
/// Circuits
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct CircuitMember<F: Field + PrimeField, G: Group> {
|
||||
pub identifier: Identifier<F, G>,
|
||||
@ -237,9 +239,9 @@ pub struct CircuitMember<F: Field + PrimeField, G: Group> {
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
pub struct CircuitObject<F: Field + PrimeField, G: Group> {
|
||||
pub identifier: Identifier<F, G>,
|
||||
pub _type: Type<F, G>,
|
||||
pub enum CircuitObject<F: Field + PrimeField, G: Group> {
|
||||
CircuitValue(Identifier<F, G>, Type<F, G>),
|
||||
CircuitFunction(bool, Function<F, G>),
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
|
@ -291,7 +291,17 @@ impl<F: Field + PrimeField, G: Group> fmt::Display for Type<F, G> {
|
||||
|
||||
impl<F: Field + PrimeField, G: Group> fmt::Display for CircuitObject<F, G> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}: {}", self.identifier, self._type)
|
||||
match self {
|
||||
CircuitObject::CircuitValue(ref identifier, ref _type) => {
|
||||
write!(f, "{}: {}", self.identifier, self._type)
|
||||
}
|
||||
CircuitObject::CircuitFunction(ref _static, ref function) => {
|
||||
if _static {
|
||||
write!(f, "static ")?;
|
||||
}
|
||||
write!(f, "{}", function)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -695,37 +695,38 @@ impl<'ast, F: Field + PrimeField, G: Group> From<ast::Type<'ast>> for types::Typ
|
||||
/// pest ast -> types::Struct
|
||||
|
||||
impl<'ast, F: Field + PrimeField, G: Group> From<ast::CircuitValue<'ast>>
|
||||
for types::CircuitObject<F, G>
|
||||
for types::CircuitObject<F, G>
|
||||
{
|
||||
fn from(_circuit_value: ast::CircuitValue<'ast>) -> Self {
|
||||
unimplemented!("circuit value")
|
||||
// types::CircuitObject {
|
||||
// identifier: types::Identifier::from(struct_field.identifier),
|
||||
// _type: types::Type::from(struct_field._type),
|
||||
// }
|
||||
fn from(circuit_value: ast::CircuitValue<'ast>) -> Self {
|
||||
types::CircuitObject::CircuitValue(
|
||||
types::Identifier::from(circuit_value.identifier),
|
||||
types::Type::from(circuit_value._type),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ast, F: Field + PrimeField, G: Group> From<ast::CircuitFunction<'ast>>
|
||||
for types::CircuitObject<F, G>
|
||||
for types::CircuitObject<F, G>
|
||||
{
|
||||
fn from(_circuit_value: ast::CircuitFunction<'ast>) -> Self {
|
||||
unimplemented!("circuit function")
|
||||
// types::CircuitObject {
|
||||
// identifier: types::Identifier::from(struct_field.identifier),
|
||||
// _type: types::Type::from(struct_field._type),
|
||||
// }
|
||||
fn from(circuit_function: ast::CircuitFunction<'ast>) -> Self {
|
||||
types::CircuitObject::CircuitFunction(
|
||||
circuit_function._static.is_some(),
|
||||
types::Function::from(circuit_function.function),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl<'ast, F: Field + PrimeField, G: Group> From<ast::CircuitObject<'ast>>
|
||||
for types::CircuitObject<F, G>
|
||||
{
|
||||
fn from(object: ast::CircuitObject<'ast>) -> Self {
|
||||
match object {
|
||||
ast::CircuitObject::CircuitValue(circuit_value) => types::CircuitObject::from(circuit_value),
|
||||
ast::CircuitObject::CircuitFunction(circuit_function) => types::CircuitObject::from(circuit_function),
|
||||
ast::CircuitObject::CircuitValue(circuit_value) => {
|
||||
types::CircuitObject::from(circuit_value)
|
||||
}
|
||||
ast::CircuitObject::CircuitFunction(circuit_function) => {
|
||||
types::CircuitObject::from(circuit_function)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user