use crate::ir::ir_expression::IrExpression; use crate::ir::ir_variable::IrVariable; use std::collections::HashSet; use std::fmt::{Display, Formatter}; use std::rc::Rc; pub struct IrCall { function_name: Rc, arguments: Vec, } impl IrCall { pub fn new(function_name: Rc, arguments: Vec) -> Self { Self { function_name, arguments, } } pub fn uses(&self) -> HashSet> { let mut set = HashSet::new(); for argument in &self.arguments { set.extend(argument.uses()); } set } } impl Display for IrCall { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "{}(", self.function_name)?; for (i, argument) in self.arguments.iter().enumerate() { write!(f, "{}", argument)?; if i < self.arguments.len() - 1 { write!(f, ", ")?; } } write!(f, ")")?; Ok(()) } }