]> Repositorios git - scryer-prolog.git/commitdiff
remove SCCCutPolicy panic, revise (;)/2 so that comma'ed cuts are handled properly...
authorMark Thom <[email protected]>
Sun, 19 Apr 2020 02:10:53 +0000 (20:10 -0600)
committerMark Thom <[email protected]>
Sun, 19 Apr 2020 02:10:53 +0000 (20:10 -0600)
src/prolog/lib/builtins.pl
src/prolog/lib/iso_ext.pl
src/prolog/machine/code_repo.rs
src/prolog/machine/system_calls.rs
src/prolog/machine/toplevel.rs
src/prolog/toplevel.pl

index 17235d3bd56bf442ba5574847a7b75ae8004d3f7..7a1a706198a95bde267f9ebda820b1b77de41bb3 100644 (file)
@@ -213,18 +213,36 @@ comma_errors(G1, G2, B) :- '$call_with_default_policy'(','(G1, G2, B)).
 
 ;(G1, G2) :- '$get_b_value'(B), ;(G1, G2, B).
 
+:- non_counted_backtracking semicolon_compound_selector/3.
+semicolon_compound_selector(->(G2, G3), G4, B) :-
+    (  call(G2) ->
+       call(G3)
+       ;  '$set_cp'(B),
+          call(G4)
+    ).
+semicolon_compound_selector(','(G2, G3), G4, B) :-
+    (  ','(G2, G3, B)
+    ;  '$set_cp'(B),
+       call(G4)
+    ).
+semicolon_compound_selector(';'(G2, G3), G4, B) :-
+    (  ';'(G2, G3, B)
+    ;  '$set_cp'(B),
+       call(G4)
+    ).
+
 :- non_counted_backtracking (;)/3.
-;(G1, G4, B) :- compound(G1),
-               '$call_with_default_policy'(G1 = ->(G2, G3)),
-               !,
-               (  call(G2) -> call(G3)
-               ;  '$set_cp'(B),
-                  call(G4)
-               ).
-;(G1, G2, B) :- G1 == !, '$set_cp'(B), call(G2).
-;(G1, G2, B) :- G2 == !, call(G1), '$set_cp'(B).
-;(G, _, _) :- call(G).
-;(_, G, _) :- call(G).
+;(G1, G4, B) :-
+    compound(G1),
+       semicolon_compound_selector(G1, G4, B).
+;(G1, G2, B) :-
+    G1 == !, '$set_cp'(B), call(G2).
+;(G1, G2, B) :-
+    G2 == !, call(G1), '$set_cp'(B).
+;(G, _, _) :-
+    call(G).
+;(_, G, _) :-
+    call(G).
 
 G1 -> G2 :- '$get_b_value'(B), '$call_with_default_policy'(->(G1, G2, B)).
 
index 012b6654eb243842d4bcea5f3dedf71c4d89edf2..a1944d1369b2d6d6e07e6a9c1101e507041c9275 100644 (file)
@@ -68,7 +68,8 @@ scc_helper(C, G, Bb) :-
     ; '$reset_block'(NBb),
       '$fail').
 scc_helper(_, _, Bb) :-
-    '$reset_block'(Bb), '$get_ball'(Ball),
+    '$reset_block'(Bb),
+    '$get_ball'(Ball),
     '$call_with_default_policy'(run_cleaners_with_handling),
     '$erase_ball',
     '$call_with_default_policy'(throw(Ball)).
index 4d6951fcc6eb114937a08d06132f0f38eb407d6d..e56a3571b69a4bc8be29881cd3ba48a450c4b7f4 100644 (file)
@@ -60,7 +60,8 @@ impl CodeRepo {
             .unwrap_or((Predicate::new(), VecDeque::from(vec![])))
     }
 
-    pub(crate) fn add_in_situ_result(
+    pub(crate)
+    fn add_in_situ_result(
         &mut self,
         result: &CompiledResult,
         in_situ_code_dir: &mut InSituCodeDir,
@@ -100,16 +101,19 @@ impl CodeRepo {
     }
 
     #[inline]
-    pub(super) fn size_of_cached_query(&self) -> usize {
+    pub(super)
+    fn size_of_cached_query(&self) -> usize {
         self.cached_query.len()
     }
 
     #[inline]
-    pub(super) fn take_in_situ_code(&mut self) -> Code {
+    pub(super)
+    fn take_in_situ_code(&mut self) -> Code {
         mem::replace(&mut self.in_situ_code, Code::new())
     }
 
-    pub(super) fn lookup_instr<'a>(
+    pub(super)
+    fn lookup_instr<'a>(
         &'a self,
         last_call: bool,
         p: &CodePtr,
index e2cad96a21b05aaf880717c86fb27852e1ab2a7e..ec1ef49a161654234dd267a00f68dc99dbe10fe4 100644 (file)
@@ -2280,7 +2280,8 @@ impl MachineState {
                             }
                         }
                     }
-                    None => panic!("expected SCCCutPolicy trait object."),
+                    None => {
+                    }
                 };
 
                 self.fail = true;
index 7cb56cc60691cb1057b88e65831985cbf579c5d6..e4198a68b6726bd99e704ea7821fc94186480406 100644 (file)
@@ -934,7 +934,7 @@ impl RelationWorker {
                 let mut term = *term;
 
                 if let Term::Clause(cell, name, terms, op_spec) = term {
-                    if name.as_str() == "," {
+                    if name.as_str() == "," && terms.len() == 2 {
                         let term = Term::Clause(cell, name, terms, op_spec);
                         let mut subterms = unfold_by_str(term, ",");
 
index 139a7a25eaf076edf237ff74e86f1ee98106a09b..fd143fc7fb43057bbc4f82edc7e8b15c72b19be9 100644 (file)
@@ -1,14 +1,14 @@
 
-:- module('$toplevel', [repl/1, consult/1, use_module/1, use_module/2]).
+:- module('$toplevel', ['$repl'/1, consult/1, use_module/1, use_module/2]).
 
 :- use_module(library(charsio)).
 :- use_module(library(lists)).
 :- use_module(library(si)).
 
-repl([_|Args]) :-
+'$repl'([_|Args]) :-
     maplist(use_list_of_modules, Args),
     false.
-repl(_) :- repl.
+'$repl'(_) :- repl.
 
 use_list_of_modules(Mod0) :-
     atom_chars(Mod, Mod0),