variable revision

This commit is contained in:
Mark Thom
2024-07-31 14:04:55 -06:00
committed by Mark Thom
parent 1ef681bd21
commit f7bbdfe73a
22 changed files with 738 additions and 894 deletions

View File

@@ -479,7 +479,7 @@ pub struct HCPrinter<'a, Outputter> {
toplevel_spec: Option<DirectedOp>,
last_item_idx: usize,
parent_of_first_op: Option<(DirectedOp, usize)>,
pub var_names: IndexMap<HeapCellValue, VarPtr>,
pub var_names: IndexMap<HeapCellValue, Var>,
pub numbervars_offset: Integer,
pub numbervars: bool,
pub quoted: bool,
@@ -795,7 +795,7 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
if let Some(var) = self.var_names.get(&cell) {
read_heap_cell!(cell,
(HeapCellValueTag::Var | HeapCellValueTag::AttrVar | HeapCellValueTag::StackVar) => {
return Some(var.borrow().to_string());
return Some(var.to_string());
}
_ => {
self.iter.push_stack(h);
@@ -837,7 +837,7 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
// short-circuits handle_heap_term.
// self.iter.pop_stack();
let var_str = var.borrow().to_string();
let var_str = var.to_string();
push_space_if_amb!(self, &var_str, {
append_str!(self, &var_str);
@@ -865,7 +865,7 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
Some(var) => {
// If the term is bound to a named variable,
// print the variable's name to output.
let var_str = var.borrow().to_string();
let var_str = var.to_string();
push_space_if_amb!(self, &var_str, {
append_str!(self, &var_str);
@@ -1924,7 +1924,7 @@ mod tests {
printer
.var_names
.insert(list_loc_as_cell!(1), VarPtr::from("L"));
.insert(list_loc_as_cell!(1), Rc::new("L".to_string()));
let output = printer.print();
@@ -1993,7 +1993,7 @@ mod tests {
printer
.var_names
.insert(list_loc_as_cell!(1), VarPtr::from("L"));
.insert(list_loc_as_cell!(1), Rc::new("L".to_string()));
let output = printer.print();