Revert "correct call_residue_vars/3 using new copy_term_3 (#1239)"
This reverts commit 9b35a316c9.
This commit is contained in:
@@ -574,8 +574,6 @@ enum SystemClauseType {
|
|||||||
DeleteFromAttributedVarList,
|
DeleteFromAttributedVarList,
|
||||||
#[strum_discriminants(strum(props(Arity = "1", Name = "$delete_all_attributes_from_var")))]
|
#[strum_discriminants(strum(props(Arity = "1", Name = "$delete_all_attributes_from_var")))]
|
||||||
DeleteAllAttributesFromVar,
|
DeleteAllAttributesFromVar,
|
||||||
#[strum_discriminants(strum(props(Arity = "2", Name = "$term_attributed_variables_without_attrs")))]
|
|
||||||
TermAttributedVariablesWithoutAttrs,
|
|
||||||
REPL(REPLCodePtr),
|
REPL(REPLCodePtr),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1638,7 +1636,6 @@ fn generate_instruction_preface() -> TokenStream {
|
|||||||
&Instruction::CallPutToAttributedVarList(_) |
|
&Instruction::CallPutToAttributedVarList(_) |
|
||||||
&Instruction::CallDeleteFromAttributedVarList(_) |
|
&Instruction::CallDeleteFromAttributedVarList(_) |
|
||||||
&Instruction::CallDeleteAllAttributesFromVar(_) |
|
&Instruction::CallDeleteAllAttributesFromVar(_) |
|
||||||
&Instruction::CallTermAttributedVariablesWithoutAttrs(_) |
|
|
||||||
&Instruction::CallFetchGlobalVar(_) |
|
&Instruction::CallFetchGlobalVar(_) |
|
||||||
&Instruction::CallFirstStream(_) |
|
&Instruction::CallFirstStream(_) |
|
||||||
&Instruction::CallFlushOutput(_) |
|
&Instruction::CallFlushOutput(_) |
|
||||||
@@ -1858,7 +1855,6 @@ fn generate_instruction_preface() -> TokenStream {
|
|||||||
&Instruction::ExecutePutToAttributedVarList(_) |
|
&Instruction::ExecutePutToAttributedVarList(_) |
|
||||||
&Instruction::ExecuteDeleteFromAttributedVarList(_) |
|
&Instruction::ExecuteDeleteFromAttributedVarList(_) |
|
||||||
&Instruction::ExecuteDeleteAllAttributesFromVar(_) |
|
&Instruction::ExecuteDeleteAllAttributesFromVar(_) |
|
||||||
&Instruction::ExecuteTermAttributedVariablesWithoutAttrs(_) |
|
|
||||||
&Instruction::ExecuteFetchGlobalVar(_) |
|
&Instruction::ExecuteFetchGlobalVar(_) |
|
||||||
&Instruction::ExecuteFirstStream(_) |
|
&Instruction::ExecuteFirstStream(_) |
|
||||||
&Instruction::ExecuteFlushOutput(_) |
|
&Instruction::ExecuteFlushOutput(_) |
|
||||||
|
|||||||
@@ -115,9 +115,7 @@ user:goal_expansion(Term, M:get_atts(Var, Attr)) :-
|
|||||||
call_residue_vars(Goal, Vars) :-
|
call_residue_vars(Goal, Vars) :-
|
||||||
'$get_attr_var_queue_delim'(B),
|
'$get_attr_var_queue_delim'(B),
|
||||||
call(Goal),
|
call(Goal),
|
||||||
'$get_attr_var_queue_beyond'(B, AttrVars),
|
'$get_attr_var_queue_beyond'(B, Vars).
|
||||||
'$project_atts':copy_term(AttrVars, AttrVars, Gs),
|
|
||||||
'$term_attributed_variables_without_attrs'(Gs, Vars).
|
|
||||||
|
|
||||||
term_attributed_variables(Term, Vars) :-
|
term_attributed_variables(Term, Vars) :-
|
||||||
'$term_attributed_variables'(Term, Vars).
|
'$term_attributed_variables'(Term, Vars).
|
||||||
|
|||||||
@@ -4392,11 +4392,11 @@ impl Machine {
|
|||||||
step_or_fail!(self, self.machine_st.p = self.machine_st.cp);
|
step_or_fail!(self, self.machine_st.p = self.machine_st.cp);
|
||||||
}
|
}
|
||||||
&Instruction::CallTermVariables(_) => {
|
&Instruction::CallTermVariables(_) => {
|
||||||
self.term_variables(|value| value.is_var());
|
self.term_variables();
|
||||||
step_or_fail!(self, self.machine_st.p += 1);
|
step_or_fail!(self, self.machine_st.p += 1);
|
||||||
}
|
}
|
||||||
&Instruction::ExecuteTermVariables(_) => {
|
&Instruction::ExecuteTermVariables(_) => {
|
||||||
self.term_variables(|value| value.is_var());
|
self.term_variables();
|
||||||
step_or_fail!(self, self.machine_st.p = self.machine_st.cp);
|
step_or_fail!(self, self.machine_st.p = self.machine_st.cp);
|
||||||
}
|
}
|
||||||
&Instruction::CallTermVariablesUnderMaxDepth(_) => {
|
&Instruction::CallTermVariablesUnderMaxDepth(_) => {
|
||||||
@@ -5239,14 +5239,6 @@ impl Machine {
|
|||||||
self.delete_all_attributes_from_var();
|
self.delete_all_attributes_from_var();
|
||||||
self.machine_st.p = self.machine_st.cp;
|
self.machine_st.p = self.machine_st.cp;
|
||||||
}
|
}
|
||||||
&Instruction::CallTermAttributedVariablesWithoutAttrs(_) => {
|
|
||||||
self.term_variables(|value| value.is_attr_var());
|
|
||||||
step_or_fail!(self, self.machine_st.p += 1);
|
|
||||||
}
|
|
||||||
&Instruction::ExecuteTermAttributedVariablesWithoutAttrs(_) => {
|
|
||||||
self.term_variables(|value| value.is_attr_var());
|
|
||||||
step_or_fail!(self, self.machine_st.p = self.machine_st.cp);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -508,24 +508,23 @@ impl MachineState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(crate) fn filter_cell_set<S: BuildHasher>(
|
pub(crate) fn variable_set<S: BuildHasher>(
|
||||||
&mut self,
|
&mut self,
|
||||||
seen_set: &mut IndexSet<HeapCellValue, S>,
|
seen_set: &mut IndexSet<HeapCellValue, S>,
|
||||||
value: HeapCellValue,
|
value: HeapCellValue,
|
||||||
filter_fn: impl Fn(HeapCellValue) -> bool,
|
|
||||||
) {
|
) {
|
||||||
let mut iter = stackful_preorder_iter(&mut self.heap, value);
|
let mut iter = stackful_preorder_iter(&mut self.heap, value);
|
||||||
|
|
||||||
while let Some(value) = iter.next() {
|
while let Some(value) = iter.next() {
|
||||||
let value = unmark_cell_bits!(value);
|
let value = unmark_cell_bits!(value);
|
||||||
|
|
||||||
if filter_fn(value) {
|
if value.is_var() {
|
||||||
let value = unmark_cell_bits!(heap_bound_store(
|
let value = unmark_cell_bits!(heap_bound_store(
|
||||||
iter.heap,
|
iter.heap,
|
||||||
heap_bound_deref(iter.heap, value)
|
heap_bound_deref(iter.heap, value)
|
||||||
));
|
));
|
||||||
|
|
||||||
if filter_fn(value) {
|
if value.is_var() {
|
||||||
seen_set.insert(value);
|
seen_set.insert(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1244,11 +1243,7 @@ impl Machine {
|
|||||||
// complete_partial_goal prior to goal_expansion.
|
// complete_partial_goal prior to goal_expansion.
|
||||||
let mut supp_vars = IndexSet::with_hasher(FxBuildHasher::default());
|
let mut supp_vars = IndexSet::with_hasher(FxBuildHasher::default());
|
||||||
|
|
||||||
self.machine_st.filter_cell_set(
|
self.machine_st.variable_set(&mut supp_vars, self.machine_st.registers[2]);
|
||||||
&mut supp_vars,
|
|
||||||
self.machine_st.registers[2],
|
|
||||||
|value| value.is_var(),
|
|
||||||
);
|
|
||||||
|
|
||||||
struct GoalAnalysisResult {
|
struct GoalAnalysisResult {
|
||||||
is_simple_goal: bool,
|
is_simple_goal: bool,
|
||||||
@@ -1268,11 +1263,7 @@ impl Machine {
|
|||||||
// fill expanded_vars with variables of the partial
|
// fill expanded_vars with variables of the partial
|
||||||
// goal pre-completion by complete_partial_goal.
|
// goal pre-completion by complete_partial_goal.
|
||||||
for idx in s + 1 .. s + arity - supp_vars.len() + 1 {
|
for idx in s + 1 .. s + arity - supp_vars.len() + 1 {
|
||||||
self.machine_st.filter_cell_set(
|
self.machine_st.variable_set(&mut expanded_vars, self.machine_st.heap[idx]);
|
||||||
&mut expanded_vars,
|
|
||||||
self.machine_st.heap[idx],
|
|
||||||
|value| value.is_var(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let is_simple_goal = if arity >= supp_vars.len() {
|
let is_simple_goal = if arity >= supp_vars.len() {
|
||||||
@@ -4646,9 +4637,7 @@ impl Machine {
|
|||||||
|
|
||||||
if self.machine_st.heap[match_site + 1].get_tag() == HeapCellValueTag::Lis {
|
if self.machine_st.heap[match_site + 1].get_tag() == HeapCellValueTag::Lis {
|
||||||
let prev_tail_value = self.machine_st.heap[match_site + 1].get_value();
|
let prev_tail_value = self.machine_st.heap[match_site + 1].get_value();
|
||||||
|
|
||||||
self.machine_st.heap[prev_tail].set_value(prev_tail_value);
|
self.machine_st.heap[prev_tail].set_value(prev_tail_value);
|
||||||
self.machine_st.attr_var_init.attr_var_queue.push(attr_var_list - 1);
|
|
||||||
} else {
|
} else {
|
||||||
self.machine_st.heap[prev_tail] = heap_loc_as_cell!(prev_tail);
|
self.machine_st.heap[prev_tail] = heap_loc_as_cell!(prev_tail);
|
||||||
}
|
}
|
||||||
@@ -4696,8 +4685,6 @@ impl Machine {
|
|||||||
self.machine_st.heap.push(str_loc_as_cell!(h+1));
|
self.machine_st.heap.push(str_loc_as_cell!(h+1));
|
||||||
self.machine_st.heap.extend(functor!(atom!(":"), [cell(module), cell(attr)]));
|
self.machine_st.heap.extend(functor!(atom!(":"), [cell(module), cell(attr)]));
|
||||||
|
|
||||||
self.machine_st.attr_var_init.attr_var_queue.push(attr_var_list - 1);
|
|
||||||
|
|
||||||
match self.match_attribute(self.machine_st.heap[attr_var_list], module, attr) {
|
match self.match_attribute(self.machine_st.heap[attr_var_list], module, attr) {
|
||||||
Some(AttrListMatch { match_site, .. }) => {
|
Some(AttrListMatch { match_site, .. }) => {
|
||||||
let (match_site, l) = match match_site {
|
let (match_site, l) = match match_site {
|
||||||
@@ -4727,6 +4714,7 @@ impl Machine {
|
|||||||
self.machine_st.heap.push(heap_loc_as_cell!(h));
|
self.machine_st.heap.push(heap_loc_as_cell!(h));
|
||||||
self.machine_st.heap.push(heap_loc_as_cell!(h+5));
|
self.machine_st.heap.push(heap_loc_as_cell!(h+5));
|
||||||
|
|
||||||
|
self.machine_st.attr_var_init.attr_var_queue.push(attr_var_list - 1);
|
||||||
self.machine_st.trail(TrailRef::AttrVarListLink(attr_var_list, attr_var_list));
|
self.machine_st.trail(TrailRef::AttrVarListLink(attr_var_list, attr_var_list));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6136,7 +6124,7 @@ impl Machine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub(crate) fn term_variables(&mut self, filter_fn: impl Fn(HeapCellValue) -> bool) {
|
pub(crate) fn term_variables(&mut self) {
|
||||||
let stored_v = self.deref_register(1);
|
let stored_v = self.deref_register(1);
|
||||||
let a2 = self.deref_register(2);
|
let a2 = self.deref_register(2);
|
||||||
|
|
||||||
@@ -6147,7 +6135,7 @@ impl Machine {
|
|||||||
|
|
||||||
let mut seen_set = IndexSet::with_hasher(FxBuildHasher::default());
|
let mut seen_set = IndexSet::with_hasher(FxBuildHasher::default());
|
||||||
|
|
||||||
self.machine_st.filter_cell_set(&mut seen_set, stored_v, filter_fn);
|
self.machine_st.variable_set(&mut seen_set, stored_v);
|
||||||
|
|
||||||
let outcome = heap_loc_as_cell!(
|
let outcome = heap_loc_as_cell!(
|
||||||
iter_to_heap_list(&mut self.machine_st.heap, seen_set.into_iter())
|
iter_to_heap_list(&mut self.machine_st.heap, seen_set.into_iter())
|
||||||
|
|||||||
@@ -469,11 +469,6 @@ impl HeapCellValue {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn is_attr_var(self) -> bool {
|
|
||||||
self.get_tag() == HeapCellValueTag::AttrVar
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub(crate) fn as_var(self) -> Option<Ref> {
|
pub(crate) fn as_var(self) -> Option<Ref> {
|
||||||
read_heap_cell!(self,
|
read_heap_cell!(self,
|
||||||
|
|||||||
Reference in New Issue
Block a user