mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-24 07:48:04 +03:00
rename circuit_field -> circuit_variable in typed
This commit is contained in:
parent
16f3cbd3dd
commit
d33ca81869
@ -22,7 +22,7 @@ use crate::{
|
||||
value::{ConstrainedCircuitMember, ConstrainedValue},
|
||||
GroupType,
|
||||
};
|
||||
use leo_typed::{CircuitFieldDefinition, CircuitMember, Identifier, Span};
|
||||
use leo_typed::{CircuitMember, CircuitVariableDefinition, Identifier, Span};
|
||||
|
||||
use snarkos_models::{
|
||||
curves::{Field, PrimeField},
|
||||
@ -36,7 +36,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
file_scope: String,
|
||||
function_scope: String,
|
||||
identifier: Identifier,
|
||||
members: Vec<CircuitFieldDefinition>,
|
||||
members: Vec<CircuitVariableDefinition>,
|
||||
span: Span,
|
||||
) -> Result<ConstrainedValue<F, G>, ExpressionError> {
|
||||
let mut program_identifier = new_scope(file_scope.clone(), identifier.to_string());
|
||||
@ -55,7 +55,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
|
||||
for member in circuit.members.clone().into_iter() {
|
||||
match member {
|
||||
CircuitMember::CircuitField(identifier, _type) => {
|
||||
CircuitMember::CircuitVariable(identifier, _type) => {
|
||||
let matched_field = members
|
||||
.clone()
|
||||
.into_iter()
|
||||
|
@ -18,7 +18,7 @@ use crate::{Function, Identifier, Type};
|
||||
use leo_ast::circuits::{
|
||||
CircuitFunction as AstCircuitFunction,
|
||||
CircuitMember as AstCircuitMember,
|
||||
CircuitVariableDefinition as AstCircuitFieldDefinition,
|
||||
CircuitVariableDefinition as AstCircuitVariableDefinition,
|
||||
};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -26,13 +26,13 @@ use std::fmt;
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum CircuitMember {
|
||||
CircuitField(Identifier, Type),
|
||||
CircuitVariable(Identifier, Type),
|
||||
CircuitFunction(bool, Function),
|
||||
}
|
||||
|
||||
impl<'ast> From<AstCircuitFieldDefinition<'ast>> for CircuitMember {
|
||||
fn from(circuit_value: AstCircuitFieldDefinition<'ast>) -> Self {
|
||||
CircuitMember::CircuitField(
|
||||
impl<'ast> From<AstCircuitVariableDefinition<'ast>> for CircuitMember {
|
||||
fn from(circuit_value: AstCircuitVariableDefinition<'ast>) -> Self {
|
||||
CircuitMember::CircuitVariable(
|
||||
Identifier::from(circuit_value.identifier),
|
||||
Type::from(circuit_value._type),
|
||||
)
|
||||
@ -60,7 +60,7 @@ impl<'ast> From<AstCircuitMember<'ast>> for CircuitMember {
|
||||
impl fmt::Display for CircuitMember {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
CircuitMember::CircuitField(ref identifier, ref _type) => write!(f, "{}: {}", identifier, _type),
|
||||
CircuitMember::CircuitVariable(ref identifier, ref _type) => write!(f, "{}: {}", identifier, _type),
|
||||
CircuitMember::CircuitFunction(ref _static, ref function) => {
|
||||
if *_static {
|
||||
write!(f, "static ")?;
|
||||
|
@ -15,19 +15,19 @@
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{Expression, Identifier};
|
||||
use leo_ast::circuits::CircuitField;
|
||||
use leo_ast::circuits::CircuitVariable;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct CircuitFieldDefinition {
|
||||
pub struct CircuitVariableDefinition {
|
||||
pub identifier: Identifier,
|
||||
pub expression: Expression,
|
||||
}
|
||||
|
||||
impl<'ast> From<CircuitField<'ast>> for CircuitFieldDefinition {
|
||||
fn from(member: CircuitField<'ast>) -> Self {
|
||||
CircuitFieldDefinition {
|
||||
impl<'ast> From<CircuitVariable<'ast>> for CircuitVariableDefinition {
|
||||
fn from(member: CircuitVariable<'ast>) -> Self {
|
||||
CircuitVariableDefinition {
|
||||
identifier: Identifier::from(member.identifier),
|
||||
expression: Expression::from(member.expression),
|
||||
}
|
@ -17,8 +17,8 @@
|
||||
pub mod circuit;
|
||||
pub use circuit::*;
|
||||
|
||||
pub mod circuit_field_definition;
|
||||
pub use circuit_field_definition::*;
|
||||
pub mod circuit_variable_definition;
|
||||
pub use circuit_variable_definition::*;
|
||||
|
||||
pub mod circuit_member;
|
||||
pub use circuit_member::*;
|
||||
|
@ -53,8 +53,8 @@ impl<'ast> From<AstAssignee<'ast>> for Assignee {
|
||||
AstAssigneeAccess::Tuple(tuple) => {
|
||||
Assignee::Tuple(Box::new(acc), Expression::get_count_from_ast(tuple.number))
|
||||
}
|
||||
AstAssigneeAccess::Member(circuit_field) => {
|
||||
Assignee::CircuitField(Box::new(acc), Identifier::from(circuit_field.identifier))
|
||||
AstAssigneeAccess::Member(circuit_variable) => {
|
||||
Assignee::CircuitField(Box::new(acc), Identifier::from(circuit_variable.identifier))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -14,7 +14,15 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{CircuitFieldDefinition, GroupValue, Identifier, IntegerType, RangeOrExpression, Span, SpreadOrExpression};
|
||||
use crate::{
|
||||
CircuitVariableDefinition,
|
||||
GroupValue,
|
||||
Identifier,
|
||||
IntegerType,
|
||||
RangeOrExpression,
|
||||
Span,
|
||||
SpreadOrExpression,
|
||||
};
|
||||
use leo_ast::{
|
||||
access::{Access, AssigneeAccess},
|
||||
common::{Assignee, Identifier as AstIdentifier},
|
||||
@ -90,7 +98,7 @@ pub enum Expression {
|
||||
TupleAccess(Box<Expression>, usize, Span),
|
||||
|
||||
// Circuits
|
||||
Circuit(Identifier, Vec<CircuitFieldDefinition>, Span),
|
||||
Circuit(Identifier, Vec<CircuitVariableDefinition>, Span),
|
||||
CircuitMemberAccess(Box<Expression>, Identifier, Span), // (declared circuit name, circuit member name)
|
||||
CircuitStaticFunctionAccess(Box<Expression>, Identifier, Span), // (defined circuit name, circuit static member name)
|
||||
|
||||
@ -249,8 +257,8 @@ impl<'ast> From<CircuitInlineExpression<'ast>> for Expression {
|
||||
let members = expression
|
||||
.members
|
||||
.into_iter()
|
||||
.map(|member| CircuitFieldDefinition::from(member))
|
||||
.collect::<Vec<CircuitFieldDefinition>>();
|
||||
.map(|member| CircuitVariableDefinition::from(member))
|
||||
.collect::<Vec<CircuitVariableDefinition>>();
|
||||
|
||||
Expression::Circuit(circuit_name, members, Span::from(expression.span))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user