use crate::{Identifier, Mode, Node, NodeID, Type};
use leo_span::Span;
use serde::{Deserialize, Serialize};
use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Input {
pub identifier: Identifier,
pub mode: Mode,
pub type_: Type,
pub span: Span,
pub id: NodeID,
}
impl Input {
fn format(&self, f: &mut fmt::Formatter) -> fmt::Result {
if self.mode == Mode::None {
write!(f, "{}: {}", self.identifier, self.type_)
} else {
write!(f, "{} {}: {}", self.mode, self.identifier, self.type_)
}
}
pub fn identifier(&self) -> &Identifier {
&self.identifier
}
pub fn mode(&self) -> Mode {
self.mode
}
pub fn type_(&self) -> &Type {
&self.type_
}
}
impl fmt::Display for Input {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.format(f)
}
}
crate::simple_node_impl!(Input);