add classifications and occurrence counting
This commit is contained in:
@@ -472,7 +472,7 @@ pub struct HCPrinter<'a, Outputter> {
|
||||
state_stack: Vec<TokenOrRedirect>,
|
||||
toplevel_spec: Option<DirectedOp>,
|
||||
last_item_idx: usize,
|
||||
pub var_names: IndexMap<HeapCellValue, Rc<String>>,
|
||||
pub var_names: IndexMap<HeapCellValue, Var>,
|
||||
pub numbervars_offset: Integer,
|
||||
pub numbervars: bool,
|
||||
pub quoted: bool,
|
||||
@@ -803,7 +803,7 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
|
||||
if let Some(var) = self.var_names.get(&addr) {
|
||||
read_heap_cell!(addr,
|
||||
(HeapCellValueTag::Var | HeapCellValueTag::AttrVar | HeapCellValueTag::StackVar) => {
|
||||
return Some(format!("{}", var.as_str()));
|
||||
return Some(var.to_string());
|
||||
}
|
||||
_ => {
|
||||
self.iter.push_stack(h);
|
||||
@@ -847,10 +847,10 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
|
||||
// short-circuits handle_heap_term.
|
||||
// self.iter.pop_stack();
|
||||
|
||||
let var_str = var.as_str();
|
||||
let var_str = var.to_string();
|
||||
|
||||
push_space_if_amb!(self, var_str, {
|
||||
append_str!(self, var_str);
|
||||
push_space_if_amb!(self, &var_str, {
|
||||
append_str!(self, &var_str);
|
||||
});
|
||||
|
||||
None
|
||||
@@ -862,8 +862,10 @@ 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.
|
||||
push_space_if_amb!(self, &var, {
|
||||
append_str!(self, &var);
|
||||
let var_str = var.to_string();
|
||||
|
||||
push_space_if_amb!(self, &var_str, {
|
||||
append_str!(self, &var_str);
|
||||
});
|
||||
}
|
||||
None => {
|
||||
@@ -1715,9 +1717,7 @@ mod tests {
|
||||
heap_loc_as_cell!(0)
|
||||
);
|
||||
|
||||
printer
|
||||
.var_names
|
||||
.insert(list_loc_as_cell!(1), Rc::new("L".to_string()));
|
||||
printer.var_names.insert(list_loc_as_cell!(1), Var::from("L"));
|
||||
|
||||
let output = printer.print();
|
||||
|
||||
@@ -1778,9 +1778,7 @@ mod tests {
|
||||
heap_loc_as_cell!(0)
|
||||
);
|
||||
|
||||
printer
|
||||
.var_names
|
||||
.insert(list_loc_as_cell!(1), Rc::new("L".to_string()));
|
||||
printer.var_names.insert(list_loc_as_cell!(1), Var::from("L"));
|
||||
|
||||
let output = printer.print();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user