Skip to content

Commit

Permalink
Remove GroupTuple and related notation.
Browse files Browse the repository at this point in the history
It seems this notation was never really functional; nor did
it really make sense in SnarkVM's Group type.
  • Loading branch information
mikebenfield committed Jan 27, 2025
1 parent ea173f8 commit a252fa0
Show file tree
Hide file tree
Showing 229 changed files with 459 additions and 1,621 deletions.
19 changes: 9 additions & 10 deletions compiler/ast/src/expressions/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{GroupLiteral, IntegerType};
use crate::IntegerType;

use super::*;

Expand All @@ -29,9 +29,8 @@ pub enum Literal {
/// A field literal, e.g., `42field`.
/// A signed number followed by the keyword `field`.
Field(String, #[serde(with = "leo_span::span_json")] Span, NodeID),
/// A group literal, either product or affine.
/// For example, `42group` or `(12, 52)group`.
Group(Box<GroupLiteral>),
/// A group literal, eg `42group`.
Group(String, #[serde(with = "leo_span::span_json")] Span, NodeID),
/// An integer literal, e.g., `42`.
Integer(IntegerType, String, #[serde(with = "leo_span::span_json")] Span, NodeID),
/// A scalar literal, e.g. `1scalar`.
Expand All @@ -47,7 +46,7 @@ impl fmt::Display for Literal {
Self::Address(address, _, _) => write!(f, "{address}"),
Self::Boolean(boolean, _, _) => write!(f, "{boolean}"),
Self::Field(field, _, _) => write!(f, "{field}field"),
Self::Group(group) => write!(f, "{group}group"),
Self::Group(group, _, _) => write!(f, "{group}group"),
Self::Integer(type_, value, _, _) => write!(f, "{value}{type_}"),
Self::Scalar(scalar, _, _) => write!(f, "{scalar}scalar"),
Self::String(string, _, _) => write!(f, "\"{string}\""),
Expand All @@ -61,10 +60,10 @@ impl Node for Literal {
Self::Address(_, span, _)
| Self::Boolean(_, span, _)
| Self::Field(_, span, _)
| Self::Group(_, span, _)
| Self::Integer(_, _, span, _)
| Self::Scalar(_, span, _)
| Self::String(_, span, _) => *span,
Self::Group(group) => *group.span(),
}
}

Expand All @@ -74,9 +73,9 @@ impl Node for Literal {
| Self::Boolean(_, span, _)
| Self::Field(_, span, _)
| Self::Integer(_, _, span, _)
| Self::Group(_, span, _)
| Self::Scalar(_, span, _)
| Self::String(_, span, _) => *span = new_span,
Self::Group(group) => group.set_span(new_span),
}
}

Expand All @@ -85,10 +84,10 @@ impl Node for Literal {
Self::Address(_, _, id)
| Self::Boolean(_, _, id)
| Self::Field(_, _, id)
| Self::Group(_, _, id)
| Self::Integer(_, _, _, id)
| Self::Scalar(_, _, id)
| Self::String(_, _, id) => *id,
Self::Group(group) => *group.id(),
}
}

Expand All @@ -97,10 +96,10 @@ impl Node for Literal {
Self::Address(_, _, old_id)
| Self::Boolean(_, _, old_id)
| Self::Field(_, _, old_id)
| Self::Group(_, _, old_id)
| Self::Integer(_, _, _, old_id)
| Self::Scalar(_, _, old_id)
| Self::String(_, _, old_id) => *old_id = id,
Self::Group(group) => group.set_id(id),
}
}
}
Expand All @@ -122,7 +121,7 @@ impl fmt::Display for DisplayDecimal<'_> {
Literal::Address(address, _, _) => write!(f, "{address}"),
Literal::Boolean(boolean, _, _) => write!(f, "{boolean}"),
Literal::Field(field, _, _) => write!(f, "{field}field"),
Literal::Group(group) => write!(f, "{group}group"),
Literal::Group(group, _, _) => write!(f, "{group}group"),
Literal::Integer(type_, value, _, _) => {
if !value.starts_with("0x")
&& !value.starts_with("-0x")
Expand Down
44 changes: 0 additions & 44 deletions compiler/ast/src/groups/group_coordinate.rs

This file was deleted.

83 changes: 0 additions & 83 deletions compiler/ast/src/groups/group_literal.rs

This file was deleted.

21 changes: 0 additions & 21 deletions compiler/ast/src/groups/mod.rs

This file was deleted.

3 changes: 0 additions & 3 deletions compiler/ast/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ pub use self::expressions::*;
pub mod functions;
pub use self::functions::*;

pub mod groups;
pub use self::groups::*;

mod indent_display;
use indent_display::*;

Expand Down
12 changes: 6 additions & 6 deletions compiler/ast/src/value/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{FromStrRadix as _, GroupLiteral, Identifier, IntegerType, Literal, NodeID, Type};
use crate::{FromStrRadix as _, Identifier, IntegerType, Literal, NodeID, Type};

use leo_errors::{FlattenError, LeoError, Result, type_name};
use leo_span::{Span, Symbol};
Expand Down Expand Up @@ -188,7 +188,7 @@ pub enum Value {
Boolean(bool, Span),
Struct(Identifier, IndexMap<Symbol, Value>),
Field(String, Span),
Group(Box<GroupLiteral>),
Group(String, Span),
I8(i8, Span),
I16(i16, Span),
I32(i32, Span),
Expand Down Expand Up @@ -734,7 +734,7 @@ impl Display for Value {
Struct(val, _) => write!(f, "{}", val.name),
Boolean(val, _) => write!(f, "{val}"),
Field(val, _) => write!(f, "{val}"),
Group(val) => write!(f, "{val}"),
Group(val, _) => write!(f, "{val}"),
I8(val, _) => write!(f, "{val}"),
I16(val, _) => write!(f, "{val}"),
I32(val, _) => write!(f, "{val}"),
Expand Down Expand Up @@ -842,7 +842,7 @@ impl From<&Value> for Type {
Boolean(_, _) => Type::Boolean,
Struct(ident, _) => Type::Identifier(*ident),
Field(_, _) => Type::Field,
Group(_) => Type::Group,
Group(_, _) => Type::Group,
I8(_, _) => Type::Integer(IntegerType::I8),
I16(_, _) => Type::Integer(IntegerType::I16),
I32(_, _) => Type::Integer(IntegerType::I32),
Expand All @@ -868,7 +868,7 @@ impl TryFrom<&Literal> for Value {
Literal::Address(string, span, _) => Self::Address(string.clone(), *span),
Literal::Boolean(bool, span, _) => Self::Boolean(*bool, *span),
Literal::Field(string, span, _) => Self::Field(string.clone(), *span),
Literal::Group(group_literal) => Self::Group(group_literal.clone()),
Literal::Group(string, span, _) => Self::Group(string.clone(), *span),
Literal::Scalar(string, span, _) => Self::Scalar(string.clone(), *span),
Literal::String(string, span, _) => Self::String(string.clone(), *span),
Literal::Integer(integer_type, raw_string, span, _) => {
Expand Down Expand Up @@ -900,7 +900,7 @@ impl Literal {
Boolean(v, span) => Literal::Boolean(v, span, id),
Struct(_ident, _values) => todo!("We need to test if this is hittable"),
Field(v, span) => Literal::Field(v, span, id),
Group(v) => Literal::Group(v),
Group(v, span) => Literal::Group(v, span, id),
I8(v, span) => Literal::Integer(IntegerType::I8, v.to_string(), span, id),
I16(v, span) => Literal::Integer(IntegerType::I16, v.to_string(), span, id),
I32(v, span) => Literal::Integer(IntegerType::I32, v.to_string(), span, id),
Expand Down
Loading

0 comments on commit a252fa0

Please sign in to comment.