use super::*;
use itertools::Itertools as _;
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct DynamicCallExpression {
pub interface: Type,
pub target_program: Expression,
pub network: Option<Expression>,
pub function: Identifier,
pub arguments: Vec<Expression>,
pub span: Span,
pub id: NodeID,
}
impl fmt::Display for DynamicCallExpression {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if let Some(network) = &self.network {
write!(
f,
"{}@({}, {})::{}({})",
self.interface,
self.target_program,
network,
self.function,
self.arguments.iter().format(", ")
)
} else {
write!(
f,
"{}@({})::{}({})",
self.interface,
self.target_program,
self.function,
self.arguments.iter().format(", ")
)
}
}
}
impl From<DynamicCallExpression> for Expression {
fn from(value: DynamicCallExpression) -> Self {
Expression::DynamicCall(Box::new(value))
}
}
crate::simple_node_impl!(DynamicCallExpression);