]> Repositorios git - scryer-prolog.git/commitdiff
generate heap_loc cells to refer to 0-arity atoms in read.rs
authorMark Thom <[email protected]>
Sun, 12 Dec 2021 04:51:45 +0000 (21:51 -0700)
committerMark Thom <[email protected]>
Fri, 7 Jan 2022 04:44:41 +0000 (21:44 -0700)
src/read.rs

index b4c4dbcc8770563cc6ec44f97ff3bdbc3f9abdc5..eced1d72b96a5a9d874306ef34f915b46721a650 100644 (file)
@@ -292,6 +292,7 @@ impl<'a, 'b> TermWriter<'a, 'b> {
                 },
             &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 @@ impl<'a, 'b> TermWriter<'a, 'b> {
                     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());