]> Repositorios git - scryer-prolog.git/commitdiff
detect module resolved cut in interpreted (,)
authorMark Thom <[email protected]>
Mon, 22 Nov 2021 06:09:39 +0000 (23:09 -0700)
committerMark Thom <[email protected]>
Fri, 7 Jan 2022 04:44:41 +0000 (21:44 -0700)
src/arena.rs
src/lib/builtins.pl
src/loader.pl
src/toplevel.pl
tests/scryer/helper.rs

index 2ba73d27e450756556470aad6a8259975e3496a2..0d6ad6a083493e2037c76004c08a6977477956f5 100644 (file)
@@ -37,11 +37,9 @@ pub enum ArenaHeaderTag {
     OutputFileStream = 0b10100,
     NamedTcpStream = 0b011100,
     NamedTlsStream = 0b100000,
-    // PausedPrologStream = 0b101100,
     ReadlineStream = 0b110000,
     StaticStringStream = 0b110100,
     ByteStream = 0b111000,
-    // StandardInputStream = 0b100,
     StandardOutputStream = 0b1100,
     StandardErrorStream = 0b11000,
     NullStream = 0b111100,
index 730b97bd376db4d3e36ffff094a3b9946d78df6c..d0f7245ed8a3b591542d65ae27137c8ac43925fd 100644 (file)
@@ -220,6 +220,12 @@ _ ; G :- call('$call'(G)).
 
 set_cp(B) :- '$set_cp'(B).
 
+:- non_counted_backtracking comma_dispatch/3.
+
+comma_dispatch(G1, G2, B) :-
+    comma_dispatch_prep((G1, G2), B, Conts),
+    comma_dispatch_call_list(Conts).
+
 :- non_counted_backtracking comma_dispatch_prep/3.
 
 comma_dispatch_prep(Gs, B, [Cont|Conts]) :-
@@ -227,20 +233,18 @@ comma_dispatch_prep(Gs, B, [Cont|Conts]) :-
        (  functor(Gs, ',', 2) ->
           arg(1, Gs, G1),
           arg(2, Gs, G2),
-          (  G1 == ! ->
+          (  nonvar(G1), ( G1 = ! ; G1 = _:! ) ->
              Cont = builtins:set_cp(B)
-          ;  callable(G1) ->
-             Cont = G1
-          ;  Cont = throw(error(type_error(callable, G1), call/1))
+          ;  Cont = G1
           ),
           comma_dispatch_prep(G2, B, Conts)
+       ;  ( Gs = ! ; Gs = _:! ) ->
+          Cont = builtins:set_cp(B),
+          Conts = []
        ;  Cont = Gs,
           Conts = []
        )
-    ;  Gs == ! ->
-       Cont = builtins:set_cp(B),
-       Conts = []
-    ;  Cont = throw(error(type_error(callable, Gs), call/1)),
+    ;  Cont = Gs,
        Conts = []
     ).
 
@@ -302,13 +306,6 @@ comma_dispatch_call_list([G1]) :-
     '$call'(G1).
 
 
-:- non_counted_backtracking comma_dispatch/3.
-
-comma_dispatch(G1, G2, B) :-
-    comma_dispatch_prep((G1, G2), B, Conts),
-    comma_dispatch_call_list(Conts).
-
-
 % univ.
 
 :- non_counted_backtracking univ_errors/3.
index fb5d8ab138e5ca4c605d880ea7f1fbda326a3b8a..21489e465de8408d1381d495a39201f98c579cf5 100644 (file)
@@ -691,10 +691,14 @@ expand_goal_cases((\+ Goals0), Module, ExpandedGoals, HeadVars) :-
 expand_goal_cases((Module:Goals0), _, ExpandedGoals, HeadVars) :-
     expand_goal(Goals0, Module, Goals1, HeadVars),
     ExpandedGoals = (Module:Goals1).
+expand_goal_cases(call(Goals0), _, ExpandedGoals, HeadVars) :-
+    expand_goal(Goals0, Module, Goals1, HeadVars),
+    ExpandedGoals = call(Goals1).
 
 expand_goal(UnexpandedGoals, Module, ExpandedGoals, HeadVars) :-
     (  var(UnexpandedGoals) ->
-       expand_module_names(call(UnexpandedGoals), [0], Module, ExpandedGoals, HeadVars)
+       UnexpandedGoals = ExpandedGoals
+       % expand_module_names(call(UnexpandedGoals), [0], Module, ExpandedGoals, HeadVars)
     ;  goal_expansion(UnexpandedGoals, Module, UnexpandedGoals1),
        (  Module \== user ->
           goal_expansion(UnexpandedGoals1, user, Goals)
index 441d470a0e0a43b5394a5733721fcb671f176904..492fef8339e13db4d9a174ac70dbf8342cef397a 100644 (file)
@@ -185,7 +185,7 @@ submit_query_and_print_results(Term0, VarList) :-
     (  functor(Term0, call, _) ->
        Term = Term0 % prevent pre-mature expansion of incomplete goal
                     % in the first argument, which is done by call/N
-    ;  expand_goal(call(Term0), user, call(Term))
+    ;  expand_goal(Term0, user, Term)
     ),
     setup_call_cleanup(bb_put('$first_answer', true),
                        submit_query_and_print_results_(Term, VarList),
index 93e7b7ca33a811c0b95784b3bc68b942a6d4ddc7..3dec7e3e3739a4677efe3dd809bcaae18ff75e1f 100644 (file)
@@ -45,7 +45,7 @@ pub(crate) fn load_module_test<T: Expectable>(file: &str, expected: T) {
     //         &mut wam.machine_st.arena,
     //     ),
     // );
-    // 
+    //
     // let output = output.bytes().unwrap();
     // expected.assert_eq(output.as_slice());
 }