use crate::ir::ir_variable::{IrVariable, IrVariableDescriptor, IrVrVariableDescriptor}; use crate::ir::register_allocation::{OffsetCounter, VrUser}; use std::cell::RefCell; use std::collections::{HashMap, HashSet}; use std::fmt::{Display, Formatter}; use std::rc::Rc; pub struct IrGetFieldRefMut { self_variable: Rc>, field_index: usize, } impl IrGetFieldRefMut { pub fn new(self_variable: Rc>, field_index: usize) -> Self { Self { self_variable, field_index, } } pub fn self_variable(&self) -> &Rc> { &self.self_variable } pub fn field_index(&self) -> usize { self.field_index } } impl Display for IrGetFieldRefMut { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!( f, "&mut {}.{}", self.self_variable.borrow(), self.field_index() ) } } impl VrUser for IrGetFieldRefMut { fn vr_definitions(&self) -> HashSet { HashSet::new() } fn vr_uses(&self) -> HashSet { match self.self_variable.borrow().descriptor() { IrVariableDescriptor::VirtualRegister(vr_variable) => { HashSet::from([vr_variable.clone()]) } IrVariableDescriptor::Stack(stack_variable) => HashSet::new(), } } fn propagate_spills(&mut self, spills: &HashSet) {} fn propagate_register_assignments( &mut self, assignments: &HashMap, ) { } fn propagate_stack_offsets(&mut self, counter: &mut OffsetCounter) {} }