]> Repositorios git - scryer-prolog.git/commitdiff
fix HeapPStrIter bug not recognizing nil focus if PStrLoc points to PStrOffset to...
authorMark Thom <[email protected]>
Tue, 23 Nov 2021 06:06:02 +0000 (23:06 -0700)
committerMark Thom <[email protected]>
Fri, 7 Jan 2022 04:44:41 +0000 (21:44 -0700)
src/loader.pl
src/machine/machine_indices.rs
src/types.rs

index 21489e465de8408d1381d495a39201f98c579cf5..fb5d8ab138e5ca4c605d880ea7f1fbda326a3b8a 100644 (file)
@@ -691,14 +691,10 @@ expand_goal_cases((\+ Goals0), Module, ExpandedGoals, HeadVars) :-
 expand_goal_cases((Module:Goals0), _, ExpandedGoals, HeadVars) :-
     expand_goal(Goals0, Module, Goals1, HeadVars),
     ExpandedGoals = (Module:Goals1).
-expand_goal_cases(call(Goals0), _, ExpandedGoals, HeadVars) :-
-    expand_goal(Goals0, Module, Goals1, HeadVars),
-    ExpandedGoals = call(Goals1).
 
 expand_goal(UnexpandedGoals, Module, ExpandedGoals, HeadVars) :-
     (  var(UnexpandedGoals) ->
-       UnexpandedGoals = ExpandedGoals
-       % expand_module_names(call(UnexpandedGoals), [0], Module, ExpandedGoals, HeadVars)
+       expand_module_names(call(UnexpandedGoals), [0], Module, ExpandedGoals, HeadVars)
     ;  goal_expansion(UnexpandedGoals, Module, UnexpandedGoals1),
        (  Module \== user ->
           goal_expansion(UnexpandedGoals1, user, Goals)
index 6d5be8c140f5b1732edd7e3e333c13d50927db1b..361b084e090056da4a91b213f79bc21c2a03501d 100644 (file)
@@ -45,25 +45,6 @@ pub enum TermOrderCategory {
     Compound,
 }
 
-// the position-dependent heap template:
-
-/*
-        read_heap_cell!(
-            (HeapCellValueTag::AttrVar, n) => {
-            }
-            (HeapCellValueTag::Lis, n) => {
-            }
-            (HeapCellValueTag::Var, n) => {
-            }
-            (HeapCellValueTag::Str, n) => {
-            }
-            (HeapCellValueTag::PStrOffset, n) => {
-            }
-            _ => {
-            }
-        )
-*/
-
 impl PartialEq<Ref> for HeapCellValue {
     fn eq(&self, r: &Ref) -> bool {
         self.as_var() == Some(*r)
@@ -82,7 +63,10 @@ impl PartialOrd<Ref> for HeapCellValue {
                     _ => Some(Ordering::Greater),
                 }
             }
-            (HeapCellValueTag::Var | HeapCellValueTag::AttrVar, h1) => {
+            (HeapCellValueTag::AttrVar | HeapCellValueTag::Var, h1) => {
+            // _ if self.is_ref() => {
+            //     let h1 = self.get_value();
+
                 match r.get_tag() {
                     RefTag::StackCell => Some(Ordering::Less),
                     _ => {
index 57c999ebd77d3fcf35a5f2e34f219c65b2f6354f..57a6c5a31937a5c0ec2097f0434c8bf992cfc184 100644 (file)
@@ -343,21 +343,27 @@ impl HeapCellValue {
     }
 
     #[inline]
-    pub fn is_string_terminator(self, heap: &[HeapCellValue]) -> bool {
-        read_heap_cell!(self,
-            (HeapCellValueTag::Atom, (name, arity)) => {
-                name == atom!("[]") && arity == 0
-            }
-            (HeapCellValueTag::CStr) => {
-                true
-            }
-            (HeapCellValueTag::PStrOffset, pstr_offset) => {
-                heap[pstr_offset].get_tag() == HeapCellValueTag::CStr
-            }
-            _ => {
-                false
-            }
-        )
+    pub fn is_string_terminator(mut self, heap: &[HeapCellValue]) -> bool {
+        loop {
+            return read_heap_cell!(self,
+                (HeapCellValueTag::Atom, (name, arity)) => {
+                    name == atom!("[]") && arity == 0
+                }
+                (HeapCellValueTag::CStr) => {
+                    true
+                }
+                (HeapCellValueTag::PStrLoc, h) => {
+                    self = heap[h];
+                    continue;
+                }
+                (HeapCellValueTag::PStrOffset, pstr_offset) => {
+                    heap[pstr_offset].get_tag() == HeapCellValueTag::CStr
+                }
+                _ => {
+                    false
+                }
+            );
+        }
     }
 
     #[inline(always)]