rename circuit_field -> circuit_variable in typed

This commit is contained in:
collin 2020-09-02 14:10:40 -07:00
parent 16f3cbd3dd
commit d33ca81869
6 changed files with 30 additions and 22 deletions

View File

@ -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()

View File

@ -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 ")?;

View File

@ -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),
}

View File

@ -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::*;

View File

@ -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))
}
})
}

View File

@ -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))
}