Get cart assignments working

pull/2/head
Alex Bethel 2021-10-23 15:08:10 -06:00
parent 978aee3597
commit fe6f7599fb
1 changed files with 13 additions and 7 deletions

View File

@ -255,14 +255,20 @@ impl ExecEnv {
for index in indices {
let index = self.eval_expr(index)?;
let value = cell.borrow().to_owned();
let mut value = value.into_cart();
if let Some(x) = value.get(&index) {
cell = Rc::clone(x);
} else {
cell = Rc::new(RefCell::new(Value::Cart(Default::default())));
value.insert(index, Rc::clone(&cell));
let next_cell;
match &mut *cell.borrow_mut() {
Value::Cart(c) => {
if let Some(x) = c.get(&index) {
next_cell = Rc::clone(x);
} else {
next_cell =
Rc::new(RefCell::new(Value::Cart(Default::default())));
c.insert(index, Rc::clone(&next_cell));
}
}
_ => todo!(),
}
cell = next_cell;
}
cell.replace(value);
}