]> Repositorios git - scryer-prolog.git/commitdiff
correct off by 1 error in verify_attrs_interrupt, revert to previous lists.pl
authorMark Thom <[email protected]>
Sun, 13 Oct 2019 01:14:33 +0000 (19:14 -0600)
committerMark Thom <[email protected]>
Sun, 13 Oct 2019 01:14:33 +0000 (19:14 -0600)
Cargo.toml
src/prolog/instructions.rs
src/prolog/lib/lists.pl
src/prolog/machine/mod.rs
src/prolog/machine/system_calls.rs
src/prolog/write.rs

index d435e6a8ad8f508ac175cc172d7e39a2f66d8030..c9f70a8baf3848ec1cdc926847316078af444e0a 100644 (file)
@@ -1,6 +1,6 @@
 [package]
 name = "scryer-prolog"
-version = "0.8.106"
+version = "0.8.107"
 authors = ["Mark Thom <[email protected]>"]
 build = "build.rs"
 repository = "https://github.com/mthom/scryer-prolog"
index 4a5fc0c879058a6e4749427780aa6ca861d2a7e5..e71351bc0144b2c8e625cf3a58373e53876760b5 100644 (file)
@@ -151,7 +151,6 @@ impl Line {
             &Line::Cut(_) => true,
             &Line::Fact(_) => true,
             &Line::Query(_) => true,
-            &Line::Control(ControlInstruction::Proceed) => true,
             _ => false,
         }
     }
index 5d130841ddf6637b3033bdcb3ede1ddbcfe69ed3..c7d8e6a3a44dc31eda1e7960590263f8d8a9ad9e 100644 (file)
@@ -50,58 +50,42 @@ reverse([], [], YsRev, YsRev).
 reverse([X1|Xs], [Y1|Ys], YsPreludeRev, Xss) :-
     reverse(Xs, Ys, [Y1|YsPreludeRev], Xss).
 
-maplist_([], _).
-maplist_([E1|E1s], Cont) :-
-    call(Cont, E1),
-    maplist_(E1s, Cont).
-
-maplist(Cont, Es) :- maplist_(Es, Cont).
-
-maplist_([], _, []).
-maplist_([E1|E1s], Cont, [E2|E2s]) :-
-    call(Cont, E1, E2),
-    maplist_(E1s, Cont, E2s).
-
-maplist(Cont, Es1, Es2) :- maplist_(Es1, Cont, Es2).
-
-maplist_([], Cont, [], []).
-maplist_([E1|E1s], Cont, [E2|E2s], [E3|E3s]) :-
-    call(Cont, E1, E2, E3),
-    maplist_(E1s, Cont, E2s, E3s).
-
-maplist(Cont, Es1, Es2, Es3) :- maplist_(Es1, Cont, Es2, Es3).
-
-maplist_([], _, [], [], []).
-maplist_([E1|E1s], Cont, [E2|E2s], [E3|E3s], [E4|E4s]) :-
+maplist(_, []).
+maplist(Cont1, [E1|E1s]) :-
+    call(Cont1, E1),
+    maplist(Cont1, E1s).
+
+maplist(_, [], []).
+maplist(Cont2, [E1|E1s], [E2|E2s]) :-
+    call(Cont2, E1, E2),
+    maplist(Cont2, E1s, E2s).
+
+maplist(_, [], [], []).
+maplist(Cont3, [E1|E1s], [E2|E2s], [E3|E3s]) :-
+    call(Cont3, E1, E2, E3),
+    maplist(Cont3, E1s, E2s, E3s).
+
+maplist(_, [], [], [], []).
+maplist(Cont, [E1|E1s], [E2|E2s], [E3|E3s], [E4|E4s]) :-
     call(Cont, E1, E2, E3, E4),
-    maplist_(E1s, Cont, E2s, E3s, E4s).
+    maplist(Cont, E1s, E2s, E3s, E4s).
 
-maplist(Cont, Es1, Es2, Es3, Es4) :- maplist_(Es1, Cont, Es2, Es3, Es4).
-
-maplist_([], _, [], [], [], []).
-maplist_([E1|E1s], Cont, [E2|E2s], [E3|E3s], [E4|E4s], [E5|E5s]) :-
+maplist(_, [], [], [], [], []).
+maplist(Cont, [E1|E1s], [E2|E2s], [E3|E3s], [E4|E4s], [E5|E5s]) :-
     call(Cont, E1, E2, E3, E4, E5),
-    maplist_(E1s, Cont, E2s, E3s, E4s, E5s).
-
-maplist(Cont, Es1, Es2, Es3, Es4, Es5) :- maplist_(Es1, Cont, Es2, Es3, Es4, Es5).
+    maplist(Cont, E1s, E2s, E3s, E4s, E5s).
 
-maplist_([], _, [], [], [], [], []).
-maplist_([E1|E1s], Cont, [E2|E2s], [E3|E3s], [E4|E4s], [E5|E5s], [E6|E6s]) :-
+maplist(_, [], [], [], [], [], []).
+maplist(Cont, [E1|E1s], [E2|E2s], [E3|E3s], [E4|E4s], [E5|E5s], [E6|E6s]) :-
     call(Cont, E1, E2, E3, E4, E5, E6),
-    maplist_(E1s, Cont, E2s, E3s, E4s, E5s, E6s).
-
-maplist(Cont, Es1, Es2, Es3, Es4, Es5, Es6) :- maplist_(Es1, Cont, Es2, Es3, Es4, Es6, Es6).
+    maplist(Cont, E1s, E2s, E3s, E4s, E5s, E6s).
 
-maplist_([], _, [], [], [], [], [], []).
-maplist_([E1|E1s], Cont, [E2|E2s], [E3|E3s], [E4|E4s], [E5|E5s], [E6|E6s], [E7|E7s]) :-
+maplist(_, [], [], [], [], [], [], []).
+maplist(Cont, [E1|E1s], [E2|E2s], [E3|E3s], [E4|E4s], [E5|E5s], [E6|E6s], [E7|E7s]) :-
     call(Cont, E1, E2, E3, E4, E5, E6, E7),
-    maplist_(E1s, Cont, E2s, E3s, E4s, E5s, E6s, E7s).
+    maplist(Cont, E1s, E2s, E3s, E4s, E5s, E6s, E7s).
 
-maplist(Cont, Es1, Es2, Es3, Es4, Es5, Es6, Es7) :- maplist_(Es1, Cont, Es2, Es3, Es4, Es6, Es6, Es7).
-
-maplist_([], _, [], [], [], [], [], [], []).
-maplist_([E1|E1s], Cont, [E2|E2s], [E3|E3s], [E4|E4s], [E5|E5s], [E6|E6s], [E7|E7s], [E8|E8s]) :-
-    call(Cont, E1, E2, E3, E4, E5, E6, E7, E8),
-    maplist_(E1s, Cont, E2s, E3s, E4s, E5s, E6s, E7s, E8s).
-
-maplist(Cont, Es1, Es2, Es3, Es4, Es5, Es6, Es7, Es8) :- maplist_(Es1, Cont, Es2, Es3, Es4, Es6, Es6, Es7, Es8).
+maplist(_, [], [], [], [], [], [], [], []).
+maplist(Cont, [E1|E1s], [E2|E2s], [E3|E3s], [E4|E4s], [E5|E5s], [E6|E6s], [E7|E7s], [E8|E8s]) :-
+    call(Cont, E1, E2, E3, E4, E5, E6, E7),
+    maplist(Cont, E1s, E2s, E3s, E4s, E5s, E6s, E7s, E8s).
index d5ae71ec6be181a350c9582bc83c9825b8ff5efb..32cfd9c580e0f069d1d03ec061137713658618cf 100644 (file)
@@ -383,7 +383,7 @@ impl Machine {
 
     fn throw_session_error(&mut self, err: SessionError, key: PredicateKey) {
         let h = self.machine_st.heap.h;
-        
+
         let err = MachineError::session_error(h, err);
         let stub = MachineError::functor_stub(key.0, key.1);
         let err = self.machine_st.error_form(err, stub);
@@ -600,7 +600,7 @@ impl Machine {
         self.machine_st.absorb_snapshot(snapshot);
         self.machine_st.ball = ball;
 
-        let h = self.machine_st.heap.h;        
+        let h = self.machine_st.heap.h;
         let stub = self.machine_st.ball.copy_and_align(h);
 
         self.machine_st.throw_exception(stub);
@@ -1046,7 +1046,7 @@ impl MachineState {
 
             match self.p {
                 CodePtr::VerifyAttrInterrupt(_) => {
-                    self.p = CodePtr::Local(self.attr_var_init.cp + 1);
+                    self.p = CodePtr::Local(self.attr_var_init.cp);// + 1);
 
                     if !self.verify_attr_stepper(indices, policies, code_repo, prolog_stream) {
                         if self.fail {
index 14730e906336249a6e1e8303574a845f647cf251..eab3ba478eac5f3f8c05bfecb9684aa8a8105fd7 100644 (file)
@@ -1617,10 +1617,10 @@ impl MachineState {
                 if let &Addr::Con(Constant::Usize(num_of_args)) = &self.and_stack[e][frame_len] {
                     self.num_of_args = num_of_args;
                 }
-
-                self.p = CodePtr::Local(self.and_stack[e].interrupt_cp);
+                
                 self.deallocate();
-
+                self.p = CodePtr::Local(self.and_stack[e].interrupt_cp);
+                
                 return Ok(());
             }
             &SystemClauseType::RestoreCutPolicy => {
index a4d6706c279219d7e3478145b05a6ee86f825e04..423e17e362503b10db0eb5bdaa5827a656c8d9be 100644 (file)
@@ -283,6 +283,21 @@ impl fmt::Display for SessionError {
     }
 }
 
+impl fmt::Display for Line {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        match self {
+            &Line::Arithmetic(ref arith_instr) => write!(f, "{}", arith_instr),
+            &Line::Choice(ref choice_instr) => write!(f, "{}", choice_instr), 
+            &Line::Control(ref control_instr) => write!(f, "{}", control_instr),
+            &Line::Cut(ref cut_instr) => write!(f, "{}", cut_instr), 
+            &Line::Fact(ref fact_instr) => write!(f, "{}", fact_instr),
+            &Line::Indexing(ref indexing_instr) => write!(f, "{}", indexing_instr), 
+            &Line::IndexedChoice(ref indexed_choice_instr) => write!(f, "{}", indexed_choice_instr), 
+            &Line::Query(ref query_instr) => write!(f, "{}", query_instr), 
+        }
+    }
+}
+
 impl fmt::Display for Number {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match self {