From: Mark Thom Date: Mon, 18 Nov 2019 00:18:11 +0000 (-0400) Subject: correct failure to observe last call position in queries' X-Git-Tag: v0.8.118~38^2~20 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=de88fdc4dcc12ac6d89a51d06f8d806731f98e9a;p=scryer-prolog.git correct failure to observe last call position in queries' --- diff --git a/src/prolog/machine/code_repo.rs b/src/prolog/machine/code_repo.rs index df80644f..fee126e9 100644 --- a/src/prolog/machine/code_repo.rs +++ b/src/prolog/machine/code_repo.rs @@ -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)) } diff --git a/src/prolog/machine/machine_indices.rs b/src/prolog/machine/machine_indices.rs index ef3b7d2c..384bd3fc 100644 --- a/src/prolog/machine/machine_indices.rs +++ b/src/prolog/machine/machine_indices.rs @@ -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 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) } } diff --git a/src/prolog/machine/machine_state.rs b/src/prolog/machine/machine_state.rs index 8bcd2018..edb5f419 100644 --- a/src/prolog/machine/machine_state.rs +++ b/src/prolog/machine/machine_state.rs @@ -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());