Fix warnings
This commit is contained in:
parent
0fda2c6d4b
commit
2afe480be1
15
src/vm.rs
15
src/vm.rs
@ -219,31 +219,25 @@ pub(crate) struct 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)?;
|
||||
Some(match &*value.borrow() {
|
||||
_ => 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) {
|
||||
match value {
|
||||
StackValue::Value(value) => {
|
||||
*existing.borrow_mut() = value;
|
||||
}
|
||||
StackValue::Ref(reference) => {
|
||||
*existing = reference;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
match value {
|
||||
StackValue::Value(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)]
|
||||
enum StackValue {
|
||||
Value(Value),
|
||||
Ref(Rc<RefCell<Value>>),
|
||||
}
|
||||
|
||||
impl ClosureRunner {
|
||||
@ -566,16 +559,12 @@ impl ClosureRunner {
|
||||
StackValue::Value(value) => {
|
||||
*stack_slot.borrow_mut() = value;
|
||||
}
|
||||
StackValue::Ref(ref_cell) => *stack_slot = ref_cell,
|
||||
}
|
||||
} else {
|
||||
match value {
|
||||
StackValue::Value(value) => {
|
||||
self.stack.insert(idx, Rc::new(RefCell::new(value)));
|
||||
}
|
||||
StackValue::Ref(reference) => {
|
||||
self.stack.insert(idx, reference);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user