diff --git a/compiler/ast/src/functions/function_input.rs b/compiler/ast/src/functions/function_input.rs index d2f65eaa87..15506ff989 100644 --- a/compiler/ast/src/functions/function_input.rs +++ b/compiler/ast/src/functions/function_input.rs @@ -41,7 +41,7 @@ impl fmt::Display for ParamMode { /// A function parameter. #[derive(Clone, PartialEq, Eq, Serialize, Deserialize)] -pub struct FunctionInputVariable { +pub struct FunctionInput { /// The name the parameter is accessible as in the function's body. pub identifier: Identifier, /// The mode of the function parameter. @@ -52,7 +52,7 @@ pub struct FunctionInputVariable { pub span: Span, } -impl FunctionInputVariable { +impl FunctionInput { pub fn new(identifier: Identifier, mode: ParamMode, type_: Type, span: Span) -> Self { Self { identifier, @@ -67,7 +67,7 @@ impl FunctionInputVariable { } } -impl FunctionInputVariable { +impl FunctionInput { fn format(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{} ", self.mode)?; write!(f, "{}: ", self.identifier)?; @@ -75,16 +75,16 @@ impl FunctionInputVariable { } } -impl fmt::Display for FunctionInputVariable { +impl fmt::Display for FunctionInput { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.format(f) } } -impl fmt::Debug for FunctionInputVariable { +impl fmt::Debug for FunctionInput { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.format(f) } } -crate::simple_node_impl!(FunctionInputVariable); +crate::simple_node_impl!(FunctionInput); diff --git a/compiler/ast/src/functions/input_variable.rs b/compiler/ast/src/functions/input_variable.rs deleted file mode 100644 index 9a924f44e1..0000000000 --- a/compiler/ast/src/functions/input_variable.rs +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (C) 2019-2022 Aleo Systems Inc. -// This file is part of the Leo library. - -// The Leo library is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// The Leo library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with the Leo library. If not, see . - -use crate::{FunctionInputVariable, Node}; -use leo_span::Span; - -use serde::{Deserialize, Serialize}; -use std::fmt; - -/// Enumerates the possible inputs to a function. -#[derive(Clone, Serialize, Deserialize)] -pub enum FunctionInput { - /// A normal function parameter. - Variable(FunctionInputVariable), -} - -impl FunctionInput { - /// - /// Returns Option with FunctionInputVariable if the input is a variable. - /// Returns None otherwise. - /// - pub fn get_variable(&self) -> &FunctionInputVariable { - match self { - Self::Variable(var) => var, - } - } - - /// Formats the parameter to `f`. - fn format(&self, f: &mut fmt::Formatter) -> fmt::Result { - match self { - FunctionInput::Variable(function_input) => write!(f, "{}", function_input), - } - } -} - -impl fmt::Display for FunctionInput { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - self.format(f) - } -} - -impl fmt::Debug for FunctionInput { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - self.format(f) - } -} - -impl PartialEq for FunctionInput { - /// Returns true if `self == other`. Does not compare spans. - fn eq(&self, other: &Self) -> bool { - match (self, other) { - (FunctionInput::Variable(left), FunctionInput::Variable(right)) => left.eq(right), - } - } -} - -impl Eq for FunctionInput {} - -impl Node for FunctionInput { - fn span(&self) -> Span { - use FunctionInput::*; - match self { - Variable(variable) => variable.span, - } - } - - fn set_span(&mut self, span: Span) { - use FunctionInput::*; - match self { - Variable(variable) => variable.span = span, - } - } -} diff --git a/compiler/ast/src/functions/mod.rs b/compiler/ast/src/functions/mod.rs index f1a91bb176..652505ac70 100644 --- a/compiler/ast/src/functions/mod.rs +++ b/compiler/ast/src/functions/mod.rs @@ -20,9 +20,6 @@ pub use annotation::*; pub mod function_input; pub use function_input::*; -pub mod input_variable; -pub use input_variable::*; - use crate::{Block, Identifier, Node, Type}; use leo_span::{sym, Span, Symbol};