From: Mark Thom Date: Sat, 11 Dec 2021 00:16:15 +0000 (-0700) Subject: dereference variables when looking for string terminators X-Git-Tag: v0.9.0^2~100 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=3974b6e6cd3c38e108b8ce8678828622fc7c44c4;p=scryer-prolog.git dereference variables when looking for string terminators --- diff --git a/src/types.rs b/src/types.rs index 16805981..b4278f41 100644 --- a/src/types.rs +++ b/src/types.rs @@ -344,6 +344,8 @@ impl HeapCellValue { #[inline] pub fn is_string_terminator(mut self, heap: &[HeapCellValue]) -> bool { + use crate::machine::heap::*; + loop { return read_heap_cell!(self, (HeapCellValueTag::Atom, (name, arity)) => { @@ -356,6 +358,16 @@ impl HeapCellValue { self = heap[h]; continue; } + (HeapCellValueTag::AttrVar | HeapCellValueTag::Var, h) => { + let cell = heap_bound_store(heap, heap_bound_deref(heap, heap[h])); + + if cell.is_var() { + return false; + } + + self = cell; + continue; + } (HeapCellValueTag::PStrOffset, pstr_offset) => { heap[pstr_offset].get_tag() == HeapCellValueTag::CStr }