Fix warnings

This commit is contained in:
Sofia 2026-03-17 22:26:39 +02:00
parent 0fda2c6d4b
commit 2afe480be1

View File

@ -219,31 +219,25 @@ pub(crate) struct Environment {
} }
impl Environment { impl Environment {
pub fn get_global(&mut self, key: &Constant) -> Option<StackValue> { fn get_global(&mut self, key: &Constant) -> Option<StackValue> {
let value = self.globals.get_mut(key)?; let value = self.globals.get_mut(key)?;
Some(match &*value.borrow() { Some(match &*value.borrow() {
_ => StackValue::Value(value.borrow().clone()), _ => StackValue::Value(value.borrow().clone()),
}) })
} }
pub fn set_global(&mut self, key: Constant, value: StackValue) { fn set_global(&mut self, key: Constant, value: StackValue) {
if let Some(existing) = self.globals.get_mut(&key) { if let Some(existing) = self.globals.get_mut(&key) {
match value { match value {
StackValue::Value(value) => { StackValue::Value(value) => {
*existing.borrow_mut() = value; *existing.borrow_mut() = value;
} }
StackValue::Ref(reference) => {
*existing = reference;
}
} }
} else { } else {
match value { match value {
StackValue::Value(value) => { StackValue::Value(value) => {
self.globals.insert(key, Rc::new(RefCell::new(value))); self.globals.insert(key, Rc::new(RefCell::new(value)));
} }
StackValue::Ref(reference) => {
self.globals.insert(key, reference);
}
} }
} }
} }
@ -556,7 +550,6 @@ pub struct ClosureRunner {
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
enum StackValue { enum StackValue {
Value(Value), Value(Value),
Ref(Rc<RefCell<Value>>),
} }
impl ClosureRunner { impl ClosureRunner {
@ -566,16 +559,12 @@ impl ClosureRunner {
StackValue::Value(value) => { StackValue::Value(value) => {
*stack_slot.borrow_mut() = value; *stack_slot.borrow_mut() = value;
} }
StackValue::Ref(ref_cell) => *stack_slot = ref_cell,
} }
} else { } else {
match value { match value {
StackValue::Value(value) => { StackValue::Value(value) => {
self.stack.insert(idx, Rc::new(RefCell::new(value))); self.stack.insert(idx, Rc::new(RefCell::new(value)));
} }
StackValue::Ref(reference) => {
self.stack.insert(idx, reference);
}
} }
} }
} }