]> Repositorios git - scryer-prolog.git/commitdiff
cover Addr::Fixnum when not referenced as an Addr::Con, undefine dynamic predicate...
authorMark Thom <[email protected]>
Wed, 17 Jun 2020 01:03:07 +0000 (19:03 -0600)
committerMark Thom <[email protected]>
Wed, 17 Jun 2020 01:03:07 +0000 (19:03 -0600)
src/machine/dynamic_database.rs

index 17a21d06bb001c2445f9fd8e538e6342eec89426..6fc01b4c1a9270e671b0b267d5d67354baf0188e 100644 (file)
@@ -66,6 +66,9 @@ impl Machine {
                     }
                 }
             }
+            Addr::Fixnum(arity) => {
+                usize::try_from(arity).unwrap()
+            }
             Addr::Usize(n) => {
                 n
             }
@@ -98,6 +101,18 @@ impl Machine {
     }
 
     fn make_undefined(&mut self, name: ClauseName, arity: usize) {
+        let module_name = name.owning_module();
+
+        match self.indices.modules.get(&module_name) {
+            Some(ref module) => {
+                if let Some(idx) = module.code_dir.get(&(name.clone(), arity)) {
+                    set_code_index!(idx, IndexPtr::DynamicUndefined, module_name);
+                }
+            }
+            None => {
+            }
+        }
+
         if let Some(idx) = self.indices.code_dir.get(&(name, arity)) {
             set_code_index!(idx, IndexPtr::DynamicUndefined, clause_name!("user"));
         }
@@ -258,7 +273,12 @@ impl Machine {
                         unreachable!()
                     }
                 }
-            _ => unreachable!(),
+            Addr::Fixnum(arity) => {
+                usize::try_from(arity).unwrap()
+            }
+            _ => {
+                unreachable!()
+            }
         };
 
         let (mut name, arity) = self.get_predicate_key(temp_v!(1), temp_v!(2));