Revert "remove Term"

This reverts commit 3b5879841aedecba5057c70c71da0ba23e5cd84a.
This commit is contained in:
Mark Thom
2025-03-15 13:19:26 -07:00
committed by Mark Thom
parent eef7b06919
commit 9e1e99f961
53 changed files with 3726 additions and 4517 deletions

View File

@@ -477,7 +477,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, Var>,
pub var_names: IndexMap<HeapCellValue, VarPtr>,
pub numbervars_offset: Integer,
pub numbervars: bool,
pub quoted: bool,
@@ -544,11 +544,11 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
stack: &'a mut Stack,
op_dir: &'a OpDir,
output: Outputter,
root_loc: usize,
term_loc: usize,
) -> Self {
HCPrinter {
outputter: output,
iter: stackful_preorder_iter(heap, stack, root_loc),
iter: stackful_preorder_iter(heap, stack, term_loc),
op_dir,
state_stack: vec![],
toplevel_spec: None,
@@ -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.to_string());
return Some(var.borrow().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.to_string();
let var_str = var.borrow().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.to_string();
let var_str = var.borrow().to_string();
push_space_if_amb!(self, &var_str, {
append_str!(self, &var_str);
@@ -1956,7 +1956,7 @@ mod tests {
printer
.var_names
.insert(list_loc_as_cell!(1), Rc::new("L".to_string()));
.insert(list_loc_as_cell!(1), VarPtr::from("L"));
let output = printer.print();
@@ -2033,7 +2033,7 @@ mod tests {
printer
.var_names
.insert(list_loc_as_cell!(1), Rc::new("L".to_string()));
.insert(list_loc_as_cell!(1), VarPtr::from("L"));
let output = printer.print();
@@ -2078,7 +2078,7 @@ mod tests {
wam.machine_st.heap.clear();
wam.machine_st.allocate_pstr("abc").unwrap();
wam.machine_st.heap.allocate_pstr("abc").unwrap();
wam.machine_st.heap.push_cell(heap_loc_as_cell!(1)).unwrap();
wam.machine_st.heap.push_cell(pstr_loc_as_cell!(0)).unwrap();