From: Mark Date: Sun, 1 Oct 2023 23:11:26 +0000 (-0600) Subject: consider an '$aux' a relation of the unexpanded goal's variables in compile_inline_or... X-Git-Tag: remove~60 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=a1ceeb697ac3c005898eb9ffe1cee61aeb0786cb;p=scryer-prolog.git consider an '$aux' a relation of the unexpanded goal's variables in compile_inline_or_expanded_goal (#2062) --- diff --git a/build/instructions_template.rs b/build/instructions_template.rs index 15881bfd..0aca72f6 100644 --- a/build/instructions_template.rs +++ b/build/instructions_template.rs @@ -574,7 +574,7 @@ enum SystemClauseType { PredicateDefined, #[strum_discriminants(strum(props(Arity = "3", Name = "$strip_module")))] StripModule, - #[strum_discriminants(strum(props(Arity = "4", Name = "$compile_inline_or_expanded_goal")))] + #[strum_discriminants(strum(props(Arity = "5", Name = "$compile_inline_or_expanded_goal")))] CompileInlineOrExpandedGoal, #[strum_discriminants(strum(props(Arity = "arity", Name = "$fast_call")))] FastCallN(usize), diff --git a/src/loader.pl b/src/loader.pl index 467644e0..d0fb65a8 100644 --- a/src/loader.pl +++ b/src/loader.pl @@ -739,7 +739,7 @@ expand_subgoal(UnexpandedGoals, MS, M, ExpandedGoals, HeadVars) :- expand_module_names(UnexpandedGoals4, MetaSpecs, Module1, ExpandedGoals0, HeadVars) ; ExpandedGoals0 = UnexpandedGoals4 ), - '$compile_inline_or_expanded_goal'(ExpandedGoals0, SuppArgs, ExpandedGoals1, Module1), + '$compile_inline_or_expanded_goal'(ExpandedGoals0, SuppArgs, ExpandedGoals1, Module1, UnexpandedGoals0), expand_module_name(ExpandedGoals1, MS, Module1, ExpandedGoals). diff --git a/src/machine/system_calls.rs b/src/machine/system_calls.rs index 5029fcb8..40881c54 100644 --- a/src/machine/system_calls.rs +++ b/src/machine/system_calls.rs @@ -1411,7 +1411,6 @@ impl Machine { is_simple_goal: bool, goal: HeapCellValue, key: PredicateKey, - expanded_vars: IndexSet>, supp_vars: IndexSet>, } @@ -1436,7 +1435,7 @@ impl Machine { // insertion as well as the previous // supp_vars.len() argument's variables being // disjoint from them. if they are not, the - // expanded goal are not simple. + // expanded goal is not simple. let post_supp_args = self.machine_st.heap[s+arity-supp_vars.len()+1 .. s+arity+1] .iter() @@ -1482,7 +1481,6 @@ impl Machine { is_simple_goal, goal, key: (name, arity), - expanded_vars, supp_vars } } @@ -1496,7 +1494,6 @@ impl Machine { is_simple_goal: true, goal: str_loc_as_cell!(h), key: (name, 0), - expanded_vars: IndexSet::with_hasher(FxBuildHasher::default()), supp_vars, } } @@ -1510,7 +1507,6 @@ impl Machine { is_simple_goal: true, goal: str_loc_as_cell!(h), key: (name, 0), - expanded_vars: IndexSet::with_hasher(FxBuildHasher::default()), supp_vars, } } @@ -1532,9 +1528,12 @@ impl Machine { .push(untyped_arena_ptr_as_cell!(UntypedArenaPtr::from(idx))); result.goal } else { + let mut unexpanded_vars = IndexSet::with_hasher(FxBuildHasher::default()); + self.machine_st.variable_set(&mut unexpanded_vars, self.machine_st.registers[5]); + // all supp_vars must appear later! let vars = IndexSet::>::from_iter( - result.expanded_vars.difference(&result.supp_vars).cloned(), + unexpanded_vars.difference(&result.supp_vars).cloned(), ); let vars: Vec<_> = vars @@ -1556,7 +1555,7 @@ impl Machine { self.machine_st.heap.push(atom_as_cell!(atom!("$aux"), 0)); - for value in result.expanded_vars.difference(&result.supp_vars).cloned() { + for value in unexpanded_vars.difference(&result.supp_vars).cloned() { self.machine_st.heap.push(value); }