properly handle undefined predicates declared dynamic

This commit is contained in:
Mark Thom
2019-10-02 22:01:32 -06:00
parent 04bc8ec084
commit 516c66a47d
6 changed files with 68 additions and 41 deletions

View File

@@ -206,6 +206,7 @@ impl HeapCellValue {
#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd)]
pub enum IndexPtr {
DynamicUndefined, // a predicate, declared as dynamic, whose location in code is as yet undefined.
Undefined,
Index(usize),
}
@@ -218,13 +219,20 @@ impl CodeIndex {
pub fn is_undefined(&self) -> bool {
let index_ptr = &self.0.borrow().0;
if let &IndexPtr::Undefined = index_ptr {
true
} else {
false
match index_ptr {
&IndexPtr::Undefined | &IndexPtr::DynamicUndefined => true,
_ => false
}
}
#[inline]
pub fn dynamic_undefined(module_name: ClauseName) -> Self {
CodeIndex(Rc::new(RefCell::new((
IndexPtr::DynamicUndefined,
module_name
))))
}
#[inline]
pub fn module_name(&self) -> ClauseName {
self.0.borrow().1.clone()