]> Repositorios git - scryer-prolog.git/commitdiff
use copy_term/3 as source of attribute goals
authorMark Thom <[email protected]>
Mon, 4 May 2020 01:34:18 +0000 (19:34 -0600)
committerMark Thom <[email protected]>
Mon, 4 May 2020 01:34:18 +0000 (19:34 -0600)
src/prolog/machine/mod.rs
src/prolog/toplevel.pl

index da14cc8009a45a0d59ee5863852c46983058d8c3..03deda017e64b2b0f3e0a5f093d14750ef7bcf10 100644 (file)
@@ -445,15 +445,6 @@ impl Machine {
                             )
         );
 
-        compile_user_module(&mut wam,
-                            Stream::from(ORDSETS),
-                            true,
-                            ListingSource::from_file_and_path(
-                                clause_name!("si"),
-                                lib_path.clone(),
-                            )
-        );
-
         if wam.compile_top_level().is_err() {
             panic!("Loading '$toplevel' module failed");
         }
index 461e71959bb57da95c3c14018480468e34279334..a939a40d4088207b6975f02438cdc00f9ac9b77a 100644 (file)
@@ -3,7 +3,6 @@
 
 :- use_module(library(charsio)).
 :- use_module(library(lists)).
-:- use_module(library(ordsets)).
 :- use_module(library(si)).
 
 :- dynamic(argv/1).
@@ -231,10 +230,12 @@ trailing_period_is_ambiguous(Value) :-
 write_eqs_and_read_input(B, VarList) :-
     term_variables(VarList, Vars0),
     '$term_attributed_variables'(VarList, AttrVars),
-    append(Vars0, AttrVars, Vars),
+    copy_term(AttrVars, AttrVars, AttrGoals),
+    term_variables(AttrGoals, AttrGoalVars),
+    append([Vars0, AttrVars, AttrGoalVars], Vars),
     charsio:extend_var_list(Vars, VarList, NewVarList, fabricated),
     '$get_b_value'(B0),
-    gather_goals(NewVarList, NewVarList, VarList, Goals),
+    gather_equations(NewVarList, Goals, AttrGoals),
     (   bb_get('$first_answer', true) ->
         write('   '),
         bb_put('$first_answer', false)
@@ -296,31 +297,14 @@ is_a_different_variable([_ = Binding | Pairs], Value) :-
     ;  is_a_different_variable(Pairs, Value)
     ).
 
-filter_goals([Goal|Goals], FGoals, QueryVars) :-
-    term_variables(Goal, GoalVars0),
-    sort(GoalVars0, GoalVars),
-    (  ord_intersect(GoalVars, QueryVars) ->
-       append(GoalVars, QueryVars, QueryVars0),
-       sort(QueryVars0, QueryVars1),
-       FGoals = [Goal | FGoals0],
-       filter_goals(Goals, FGoals0, QueryVars1)
-    ;
-       filter_goals(Goals, FGoals, QueryVars)
-    ).
-filter_goals([], [], _).
-
-gather_goals([], VarList, QueryVarList, Goals) :-
-    gather_query_vars(VarList, Vars),
-    term_variables(QueryVarList, QueryVars),
-    copy_term(Vars, Vars, Goals0),
-    filter_goals(Goals0, Goals, QueryVars).
-gather_goals([Var = Value | Pairs], VarList, QueryVarList, Goals) :-
+gather_equations([], Goals, Goals).
+gather_equations([Var = Value | Pairs], Goals, Goals1) :-
     (  (  nonvar(Value)
        ;  is_a_different_variable(Pairs, Value)
        ) ->
        Goals = [Var = Value | Goals0],
-       gather_goals(Pairs, VarList, QueryVarList, Goals0)
-    ;  gather_goals(Pairs, VarList, QueryVarList, Goals)
+       gather_equations(Pairs, Goals0, Goals1)
+    ;  gather_equations(Pairs, Goals, Goals1)
     ).
 
 print_exception(E) :-