use super::*;
use leo_span::Symbol;
use itertools::Itertools as _;
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct IntrinsicExpression {
pub name: Symbol,
pub type_parameters: Vec<(Type, Span)>,
pub input_types: Vec<(Mode, Type, Span)>,
pub return_types: Vec<(Mode, Type, Span)>,
pub arguments: Vec<Expression>,
pub span: Span,
pub id: NodeID,
}
impl fmt::Display for IntrinsicExpression {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let type_parameters = if !self.type_parameters.is_empty() {
format!("::[{}]", self.type_parameters.iter().map(|(t, _)| t.to_string()).format(", "))
} else {
String::new()
};
write!(f, "{}{type_parameters}({})", self.name, self.arguments.iter().format(", "))
}
}
impl From<IntrinsicExpression> for Expression {
fn from(value: IntrinsicExpression) -> Self {
Expression::Intrinsic(Box::new(value))
}
}
crate::simple_node_impl!(IntrinsicExpression);