use crate::ir::ir_expression::IrExpression; use crate::ir::ir_variable::{IrStackVariable, IrVariable, IrVirtualRegisterVariable}; use crate::type_info::TypeInfo; 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 vr_uses(&self) -> HashSet> { let mut set = HashSet::new(); for argument in &self.arguments { set.extend(argument.vr_uses()) } set } pub fn propagate_spills(&mut self, spills: &HashSet>) { for argument in &mut self.arguments { argument.propagate_spills(spills); } } } 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(()) } }