]> Repositorios git - scryer-prolog.git/commitdiff
correct failure to observe last call position in queries'
authorMark Thom <[email protected]>
Mon, 18 Nov 2019 00:18:11 +0000 (20:18 -0400)
committerMark Thom <[email protected]>
Mon, 18 Nov 2019 00:18:11 +0000 (20:18 -0400)
src/prolog/machine/code_repo.rs
src/prolog/machine/machine_indices.rs
src/prolog/machine/machine_state.rs

index df80644f67ef0a2a39a9bdebd5be1b6446268c74..fee126e9f3c66cb0a8422755dcb749a658b64fe9 100644 (file)
@@ -134,7 +134,7 @@ impl CodeRepo {
                 );
                 Some(RefOrOwned::Owned(call_clause))
             }
-            &CodePtr::CallN(arity, _) => {
+            &CodePtr::CallN(arity, _, last_call) => {
                 let call_clause = call_clause!(ClauseType::CallN, arity, 0, last_call);
                 Some(RefOrOwned::Owned(call_clause))
             }
index ef3b7d2c21e1b906e1a394fa47736cef48e9ec06..384bd3fcbc8f394c52aa565d6c36840aa0e03bb2 100644 (file)
@@ -309,7 +309,7 @@ pub enum REPLCodePtr {
 #[derive(Clone, PartialEq)]
 pub enum CodePtr {
     BuiltInClause(BuiltInClauseType, LocalCodePtr), // local is the successor call.
-    CallN(usize, LocalCodePtr),                     // arity, local.
+    CallN(usize, LocalCodePtr, bool),               // arity, local, last call.
     Local(LocalCodePtr),
     DynamicTransaction(DynamicTransactionType, LocalCodePtr), // the type of transaction, the return pointer.
     REPL(REPLCodePtr, LocalCodePtr),                          // the REPL code, the return pointer.
@@ -320,7 +320,7 @@ impl CodePtr {
     pub fn local(&self) -> LocalCodePtr {
         match self {
             &CodePtr::BuiltInClause(_, ref local)
-          | &CodePtr::CallN(_, ref local)
+          | &CodePtr::CallN(_, ref local, _)
           | &CodePtr::Local(ref local) => local.clone(),
             &CodePtr::VerifyAttrInterrupt(p) => LocalCodePtr::DirEntry(p),
             &CodePtr::REPL(_, p) | &CodePtr::DynamicTransaction(_, p) => p,
@@ -418,7 +418,7 @@ impl Add<usize> for CodePtr {
           | p @ CodePtr::VerifyAttrInterrupt(_)
           | p @ CodePtr::DynamicTransaction(..) => p,
             CodePtr::Local(local) => CodePtr::Local(local + rhs),
-            CodePtr::CallN(_, local) | CodePtr::BuiltInClause(_, local) => {
+            CodePtr::CallN(_, local, _) | CodePtr::BuiltInClause(_, local) => {
                 CodePtr::Local(local + rhs)
             }
         }
index 8bcd20188c399c4412517ac5d75696fbf3450bf2..edb5f419183bbc075d971c1aecf47c46ccb5026f 100644 (file)
@@ -854,7 +854,7 @@ pub(crate) trait CallPolicy: Any {
                         return Ok(());
                     }
 
-                    machine_st.p = CodePtr::CallN(arity, machine_st.p.local());
+                    machine_st.p = CodePtr::CallN(arity, machine_st.p.local(), machine_st.last_call);
                 }
                 ClauseType::BuiltIn(built_in) => {
                     machine_st.setup_built_in_call(built_in.clone());