]> Repositorios git - scryer-prolog.git/commitdiff
consider an '$aux' a relation of the unexpanded goal's variables in compile_inline_or...
authorMark <[email protected]>
Sun, 1 Oct 2023 23:11:26 +0000 (17:11 -0600)
committerMark <[email protected]>
Mon, 2 Oct 2023 05:49:55 +0000 (23:49 -0600)
build/instructions_template.rs
src/loader.pl
src/machine/system_calls.rs

index 15881bfd252aa467f967b3dead7a5dc89156989f..0aca72f66e51cf4442aa2124c08bbce916a19fad 100644 (file)
@@ -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),
index 467644e063f0692c63ac817f2721d9ff044840e3..d0fb65a8e7d31b728c939ce2b7468b893ad22852 100644 (file)
@@ -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).
 
 
index 5029fcb8e7e15b2e65a3ed500ffe5ea76a9b8f8a..40881c54df02105bed72384d3fa35a0705dc9996 100644 (file)
@@ -1411,7 +1411,6 @@ impl Machine {
             is_simple_goal: bool,
             goal: HeapCellValue,
             key: PredicateKey,
-            expanded_vars: IndexSet<HeapCellValue, BuildHasherDefault<FxHasher>>,
             supp_vars: IndexSet<HeapCellValue, BuildHasherDefault<FxHasher>>,
         }
 
@@ -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::<HeapCellValue, BuildHasherDefault<FxHasher>>::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);
                     }