generate heap_loc cells to refer to 0-arity atoms in read.rs
@@ -292,6 +292,7 @@ fn term_as_addr(&mut self, term: &TermRef<'a>, h: usize) -> HeapCellValue {
},
&TermRef::PartialString(..) => pstr_loc_as_cell!(h),
&TermRef::Literal(_, _, literal) => HeapCellValue::from(*literal),
+ &TermRef::Clause(_,_,_,subterms) if subterms.len() == 0 => heap_loc_as_cell!(h),
&TermRef::Clause(..) => str_loc_as_cell!(h),
}
}
@@ -319,7 +320,11 @@ fn write_term_to_heap(mut self, term: &'a Term) -> TermWriteResult {
self.push_stub_addr();
}
&TermRef::Clause(Level::Root, _, ref ct, subterms) => {
- self.heap.push(str_loc_as_cell!(heap_loc + 1));
+ self.heap.push(if subterms.len() == 0 {
+ heap_loc_as_cell!(heap_loc + 1)
+ } else {
+ str_loc_as_cell!(heap_loc + 1)
+ });
self.queue.push_back((subterms.len(), h + 2));
let named = atom_as_cell!(ct.name(), subterms.len());
