From f32ea5b74475542e33ad522132a4f2de5d7aef1b Mon Sep 17 00:00:00 2001 From: collin Date: Fri, 7 Aug 2020 15:14:02 -0700 Subject: [PATCH] rename minus -> negate --- ast/src/expressions/unary_expression.rs | 2 +- ast/src/leo.pest | 4 ++-- ast/src/operations/unary_operation.rs | 8 ++++---- compiler/src/expression/arithmetic/mod.rs | 4 ++-- .../src/expression/arithmetic/{minus.rs => negate.rs} | 4 ++-- compiler/src/expression/expression.rs | 4 ++-- typed/src/expression.rs | 6 +++--- 7 files changed, 16 insertions(+), 16 deletions(-) rename compiler/src/expression/arithmetic/{minus.rs => negate.rs} (82%) diff --git a/ast/src/expressions/unary_expression.rs b/ast/src/expressions/unary_expression.rs index 95092e9e04..bc661d4067 100644 --- a/ast/src/expressions/unary_expression.rs +++ b/ast/src/expressions/unary_expression.rs @@ -15,7 +15,7 @@ pub struct UnaryExpression<'ast> { pub span: Span<'ast>, } -impl<'ast> fmt::Display for UnaryExpression { +impl<'ast> fmt::Display for UnaryExpression<'ast> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}{}", self.operation, self.expression) } diff --git a/ast/src/leo.pest b/ast/src/leo.pest index cd70691602..63389d4295 100644 --- a/ast/src/leo.pest +++ b/ast/src/leo.pest @@ -71,10 +71,10 @@ let_ = { "let " } // Declared in operations/unary_operation.rs operation_unary = { operation_not - | operation_minus + | operation_negate } operation_not = { "!" } -operation_minus = { "-" } +operation_negate = { "-" } // Declared in operations/binary_operation.rs operation_and = { "&&" } diff --git a/ast/src/operations/unary_operation.rs b/ast/src/operations/unary_operation.rs index b20e6d1b73..fa8c37baa9 100644 --- a/ast/src/operations/unary_operation.rs +++ b/ast/src/operations/unary_operation.rs @@ -7,14 +7,14 @@ use std::fmt; #[derive(Clone, Debug, FromPest, PartialEq, Serialize)] #[pest_ast(rule(Rule::operation_unary))] pub enum UnaryOperation { - Minus(Minus), + Negate(Negate), Not(Not), } impl fmt::Display for UnaryOperation { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - UnaryOperation::Minus(_) => write!(f, "-"), + UnaryOperation::Negate(_) => write!(f, "-"), UnaryOperation::Not(_) => write!(f, "!"), } } @@ -25,5 +25,5 @@ impl fmt::Display for UnaryOperation { pub struct Not {} #[derive(Clone, Debug, FromPest, PartialEq, Serialize)] -#[pest_ast(rule(Rule::operation_minus))] -pub struct Minus {} +#[pest_ast(rule(Rule::operation_negate))] +pub struct Negate {} diff --git a/compiler/src/expression/arithmetic/mod.rs b/compiler/src/expression/arithmetic/mod.rs index ce5d497222..fa81b51c1a 100644 --- a/compiler/src/expression/arithmetic/mod.rs +++ b/compiler/src/expression/arithmetic/mod.rs @@ -6,8 +6,8 @@ pub use self::add::*; pub mod sub; pub use self::sub::*; -pub mod minus; -pub use self::minus::*; +pub mod negate; +pub use self::negate::*; pub mod mul; pub use self::mul::*; diff --git a/compiler/src/expression/arithmetic/minus.rs b/compiler/src/expression/arithmetic/negate.rs similarity index 82% rename from compiler/src/expression/arithmetic/minus.rs rename to compiler/src/expression/arithmetic/negate.rs index 1f92294429..65809e6bad 100644 --- a/compiler/src/expression/arithmetic/minus.rs +++ b/compiler/src/expression/arithmetic/negate.rs @@ -1,4 +1,4 @@ -//! Enforces a unary minus `-` operator in a resolved Leo program. +//! Enforces a unary negate `-` operator in a resolved Leo program. use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType}; use leo_typed::Span; @@ -8,7 +8,7 @@ use snarkos_models::{ gadgets::r1cs::ConstraintSystem, }; -pub fn enforce_minus, CS: ConstraintSystem>( +pub fn enforce_negate, CS: ConstraintSystem>( cs: &mut CS, value: ConstrainedValue, span: Span, diff --git a/compiler/src/expression/expression.rs b/compiler/src/expression/expression.rs index 1f29376306..74f0785492 100644 --- a/compiler/src/expression/expression.rs +++ b/compiler/src/expression/expression.rs @@ -45,11 +45,11 @@ impl> ConstrainedProgram { } // Binary operations - Expression::Minus(expression, span) => { + Expression::Negate(expression, span) => { let resolved_value = self.enforce_expression(cs, file_scope, function_scope, expected_types, *expression)?; - enforce_minus(cs, resolved_value, span) + enforce_negate(cs, resolved_value, span) } Expression::Add(left, right, span) => { let (resolved_left, resolved_right) = self.enforce_binary_expression( diff --git a/typed/src/expression.rs b/typed/src/expression.rs index 951926fe9c..4285b6e466 100644 --- a/typed/src/expression.rs +++ b/typed/src/expression.rs @@ -52,7 +52,7 @@ pub enum Expression { // Boolean operations Not(Box, Span), - Minus(Box, Span), + Negate(Box, Span), Or(Box, Box, Span), And(Box, Box, Span), Eq(Box, Box, Span), @@ -140,7 +140,7 @@ impl<'ast> fmt::Display for Expression { Expression::Integer(ref type_, ref integer, ref _span) => write!(f, "{}{}", integer, type_), // Number operations - Expression::Minus(ref expression, ref _span) => write!(f, "-{}", expression), + Expression::Negate(ref expression, ref _span) => write!(f, "-{}", expression), Expression::Add(ref left, ref right, ref _span) => write!(f, "{} + {}", left, right), Expression::Sub(ref left, ref right, ref _span) => write!(f, "{} - {}", left, right), Expression::Mul(ref left, ref right, ref _span) => write!(f, "{} * {}", left, right), @@ -435,7 +435,7 @@ impl<'ast> From> for Expression { Box::new(Expression::from(*expression.expression)), Span::from(expression.span), ), - UnaryOperation::Minus(_) => Expression::Minus( + UnaryOperation::Negate(_) => Expression::Negate( Box::new(Expression::from(*expression.expression)), Span::from(expression.span), ),