Rename types::Tuple to types::TupleType

This commit is contained in:
Pranav Gaddamadugu 2023-10-06 21:39:33 -04:00 committed by Pranav Gaddamadugu
parent 3fda5aab62
commit 25b7d5cfac
5 changed files with 10 additions and 11 deletions

View File

@ -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::{Block, Identifier, Input, Node, NodeID, Output, Tuple, Type};
use crate::{Block, Identifier, Input, Node, NodeID, Output, TupleType, Type};
use leo_span::Span;
@ -53,7 +53,7 @@ impl Finalize {
let output_type = match output.len() {
0 => Type::Unit,
1 => output[0].type_(),
_ => Type::Tuple(Tuple(output.iter().map(|output| output.type_()).collect())),
_ => Type::Tuple(TupleType(output.iter().map(|output| output.type_()).collect())),
};
Self { identifier, input, output, output_type, block, span, id }

View File

@ -38,7 +38,7 @@ pub use output::*;
pub mod mode;
pub use mode::*;
use crate::{Block, Identifier, Node, NodeID, Tuple, Type};
use crate::{Block, Identifier, Node, NodeID, TupleType, Type};
use leo_span::{sym, Span, Symbol};
use serde::{Deserialize, Serialize};
@ -100,7 +100,7 @@ impl Function {
let output_type = match output.len() {
0 => Type::Unit,
1 => get_output_type(&output[0]),
_ => Type::Tuple(Tuple(output.iter().map(get_output_type).collect())),
_ => Type::Tuple(TupleType(output.iter().map(get_output_type).collect())),
};
Function { annotations, variant, identifier, input, output, output_type, block, finalize, span, id }

View File

@ -23,9 +23,9 @@ use std::{fmt, ops::Deref};
/// A type list of at least two types.
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct Tuple(pub Vec<Type>);
pub struct TupleType(pub Vec<Type>);
impl Deref for Tuple {
impl Deref for TupleType {
type Target = Vec<Type>;
fn deref(&self) -> &Self::Target {
@ -33,7 +33,7 @@ impl Deref for Tuple {
}
}
impl fmt::Display for Tuple {
impl fmt::Display for TupleType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "({})", self.0.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(","))
}

View File

@ -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::{Identifier, IntegerType, MappingType, Tuple};
use crate::{ArrayType, Identifier, IntegerType, MappingType, TupleType};
use itertools::Itertools;
use serde::{Deserialize, Serialize};
@ -23,7 +23,6 @@ use std::fmt;
/// Explicit type used for defining a variable or expression type
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Type {
// Data types
/// The `address` type.
Address,
/// The `bool` type.
@ -45,7 +44,7 @@ pub enum Type {
/// The `string` type.
String,
/// A static tuple of at least one type.
Tuple(Tuple),
Tuple(TupleType),
/// The `unit` type.
Unit,
/// Placeholder for a type that could not be resolved or was not well-formed.

View File

@ -89,7 +89,7 @@ impl ParserContext<'_> {
1 => Err(ParserError::tuple_must_have_at_least_two_elements("type", span).into()),
// Otherwise, parse it into a `Tuple` type.
// Note: This is the only place where `Tuple` type is constructed in the parser.
_ => Ok((Type::Tuple(Tuple(types.into_iter().map(|t| t.0).collect())), span)),
_ => Ok((Type::Tuple(TupleType(types.into_iter().map(|t| t.0).collect())), span)),
}
} else {
self.parse_primitive_type()