mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-01 18:56:38 +03:00
remove mut variable keyword
This commit is contained in:
parent
82e13edbbe
commit
7977b20ad2
@ -25,8 +25,8 @@ use std::fmt;
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum CircuitMember {
|
||||
// (is_mutable, variable_name, variable_type)
|
||||
CircuitVariable(bool, Identifier, Type),
|
||||
// (variable_name, variable_type)
|
||||
CircuitVariable(Identifier, Type),
|
||||
// (function)
|
||||
CircuitFunction(Function),
|
||||
}
|
||||
@ -34,7 +34,6 @@ pub enum CircuitMember {
|
||||
impl<'ast> From<GrammarCircuitVariableDefinition<'ast>> for CircuitMember {
|
||||
fn from(circuit_value: GrammarCircuitVariableDefinition<'ast>) -> Self {
|
||||
CircuitMember::CircuitVariable(
|
||||
circuit_value.mutable.is_some(),
|
||||
Identifier::from(circuit_value.identifier),
|
||||
Type::from(circuit_value.type_),
|
||||
)
|
||||
@ -59,10 +58,7 @@ impl<'ast> From<GrammarCircuitMember<'ast>> for CircuitMember {
|
||||
impl fmt::Display for CircuitMember {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
CircuitMember::CircuitVariable(ref mutable, ref identifier, ref type_) => {
|
||||
if *mutable {
|
||||
write!(f, "mut ")?;
|
||||
}
|
||||
CircuitMember::CircuitVariable(ref identifier, ref type_) => {
|
||||
write!(f, "{}: {}", identifier, type_)
|
||||
}
|
||||
CircuitMember::CircuitFunction(ref function) => {
|
||||
|
@ -58,7 +58,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
|
||||
for member in circuit.members.into_iter() {
|
||||
match member {
|
||||
CircuitMember::CircuitVariable(is_mutable, identifier, type_) => {
|
||||
CircuitMember::CircuitVariable(identifier, type_) => {
|
||||
let matched_variable = members
|
||||
.clone()
|
||||
.into_iter()
|
||||
@ -74,11 +74,6 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
variable.expression,
|
||||
)?;
|
||||
|
||||
// Add mutability to circuit variable
|
||||
if is_mutable {
|
||||
variable_value = ConstrainedValue::Mutable(Box::new(variable_value))
|
||||
}
|
||||
|
||||
resolved_members.push(ConstrainedCircuitMember(identifier, variable_value))
|
||||
}
|
||||
None => return Err(ExpressionError::expected_circuit_member(identifier.to_string(), span)),
|
||||
@ -89,10 +84,6 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
let constrained_function_value =
|
||||
ConstrainedValue::Function(Some(circuit_identifier.clone()), function);
|
||||
|
||||
// if _static {
|
||||
// constrained_function_value = ConstrainedValue::Static(Box::new(constrained_function_value));
|
||||
// }
|
||||
|
||||
resolved_members.push(ConstrainedCircuitMember(identifier, constrained_function_value));
|
||||
}
|
||||
};
|
||||
|
@ -28,7 +28,6 @@ use serde::Serialize;
|
||||
#[derive(Clone, Debug, FromPest, PartialEq, Serialize)]
|
||||
#[pest_ast(rule(Rule::circuit_variable_definition))]
|
||||
pub struct CircuitVariableDefinition<'ast> {
|
||||
pub mutable: Option<Mutable>,
|
||||
pub identifier: Identifier<'ast>,
|
||||
pub type_: Type<'ast>,
|
||||
#[pest_ast(outer())]
|
||||
|
@ -322,7 +322,7 @@ circuit = { "circuit " ~ identifier ~ "{" ~ NEWLINE* ~ circuit_member* ~ NEWLINE
|
||||
circuit_variable = { identifier ~ ":" ~ expression }
|
||||
|
||||
// Declared in circuits/circuit_variable_definition.rs
|
||||
circuit_variable_definition = { mutable? ~ identifier ~ ":" ~ type_ ~ ","?}
|
||||
circuit_variable_definition = { identifier ~ ":" ~ type_ ~ ","?}
|
||||
|
||||
// Declared in circuits/circuit_member.rs
|
||||
circuit_member = { function | circuit_variable_definition ~ NEWLINE*}
|
||||
|
@ -14,7 +14,7 @@
|
||||
// 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::{types::circuits::CircuitVariableType, Attribute, FunctionType, SymbolTable, Type, TypeError};
|
||||
use crate::{types::circuits::CircuitVariableType, FunctionType, SymbolTable, Type, TypeError};
|
||||
use leo_ast::{Circuit, CircuitMember, Identifier, InputValue, Parameter, Span};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -54,7 +54,7 @@ impl CircuitType {
|
||||
// Resolve the type of every circuit member.
|
||||
for member in unresolved.members {
|
||||
match member {
|
||||
CircuitMember::CircuitVariable(is_mutable, variable_identifier, type_) => {
|
||||
CircuitMember::CircuitVariable(variable_identifier, type_) => {
|
||||
// Resolve the type of the circuit member variable.
|
||||
let type_ = Type::new_from_circuit(
|
||||
table,
|
||||
@ -63,14 +63,11 @@ impl CircuitType {
|
||||
circuit_identifier.span.clone(),
|
||||
)?;
|
||||
|
||||
// Check if the circuit member variable is mutable.
|
||||
let attribute = if is_mutable { Some(Attribute::Mutable) } else { None };
|
||||
|
||||
// Create a new circuit variable type.
|
||||
let variable = CircuitVariableType {
|
||||
identifier: variable_identifier,
|
||||
type_,
|
||||
attribute,
|
||||
attribute: None,
|
||||
};
|
||||
|
||||
// Store the circuit variable type.
|
||||
|
Loading…
Reference in New Issue
Block a user