]> Repositorios git - scryer-prolog.git/commitdiff
fix setup_call_cleanup bug
authorMark Thom <[email protected]>
Fri, 2 Feb 2018 06:39:03 +0000 (23:39 -0700)
committerMark Thom <[email protected]>
Fri, 2 Feb 2018 06:39:03 +0000 (23:39 -0700)
src/prolog/builtins.rs
src/prolog/codegen.rs
src/prolog/io.rs
src/prolog/machine/machine_state_impl.rs

index 7cae5c8c085ab15ffa5fd16653748af5c211d057..aa644bdd9f57ceb203d1ddc93be1aaec35287374 100644 (file)
@@ -484,13 +484,16 @@ fn get_builtins(atom_tbl: TabledData<Atom>) -> Code {
          reset_block!(),
          query![put_var!(perm_v!(1), 1)],
          get_ball!(),
-         goto_call!(337, 0), // goto run_cleaners_with_handling/0, 337.
+         goto_call!(340, 0), // goto run_cleaners_with_handling/0, 340.
          query![put_value!(perm_v!(1), 1)],
          deallocate!(),
          goto_execute!(59, 1),
          trust_me!(),
-         goto_execute!(349, 0), // goto run_cleaners_without_handling/0, 349.
-         try_me_else!(10), // run_cleaners_with_handling/0, 337.
+         allocate!(0),
+         goto_call!(352, 0), // goto run_cleaners_without_handling/0, 352.
+         fail!(),
+         deallocate!(),
+         try_me_else!(10), // run_cleaners_with_handling/0, 340.
          allocate!(2),
          get_level!(perm_v!(1)),
          query![put_var!(perm_v!(2), 1)],
@@ -501,10 +504,10 @@ fn get_builtins(atom_tbl: TabledData<Atom>) -> Code {
          goto_call!(5, 3), // goto catch/3, 5.
          cut!(perm_v!(1)),
          deallocate!(),
-         goto_execute!(337, 0), // goto run_cleaners_with_handling/0, 337.
+         goto_execute!(340, 0), // goto run_cleaners_with_handling/0, 340.
          trust_me!(),
          proceed!(),
-         try_me_else!(10), // run_cleaners_without_handling/1, 349.
+         try_me_else!(10), // run_cleaners_without_handling/1, 352.
          allocate!(2),
          get_level!(perm_v!(1)),
          query![put_var!(perm_v!(2), 1)],
@@ -513,10 +516,10 @@ fn get_builtins(atom_tbl: TabledData<Atom>) -> Code {
          call_n!(1),
          cut!(perm_v!(1)),
          deallocate!(),         
-         goto_execute!(349, 0), // goto run_cleaners_without_handling/1, 349.
+         goto_execute!(352, 0), // goto run_cleaners_without_handling/0, 352.
          trust_me!(),
          proceed!(),
-         allocate!(1), // sgc_on_success/2, 361.
+         allocate!(1), // sgc_on_success/2, 364.
          fact![get_var_in_fact!(perm_v!(1), 2)],
          reset_block!(),
          cut!(perm_v!(1)),
index 5e6e416ad5bd4231af13a082d9a4c91f1e6b8521..ac6ce83e66464af1dde5370add2ebffa5c03c339 100644 (file)
@@ -246,7 +246,7 @@ impl<'a, TermMarker: Allocator<'a>> CodeGenerator<'a, TermMarker>
     {
         match qt {
             &QueryTerm::SetupCallCleanup(_) =>
-                code.push(goto_call!(294, 3)),            
+                code.push(goto_call!(294, 3)),
             &QueryTerm::Arg(_) => {
                 let call = ControlInstruction::ArgCall;
                 code.push(Line::Control(call));
@@ -495,7 +495,7 @@ impl<'a, TermMarker: Allocator<'a>> CodeGenerator<'a, TermMarker>
         let mut code = Vec::new();
 
         if let &QueryTerm::Term(ref term) = p0 {
-            self.marker.reset_arg(term.arity());            
+            self.marker.reset_arg(term.arity());
             self.compile_seq_prelude(&conjunct_info, &mut code);
 
             if let &Term::Clause(..) = term {
@@ -508,7 +508,7 @@ impl<'a, TermMarker: Allocator<'a>> CodeGenerator<'a, TermMarker>
             }
 
             self.marker.reset_arg_at_head(term);
-            
+
             let iter = ChunkedIterator::from_rule_body(p1, clauses);
             try!(self.compile_seq(iter, &conjunct_info, &mut code, false));
 
index 5d467db6e494adede1a367e1f2c0d091f06886e1..1e7f11139af75277e9edeb52947195a6cf935bb7 100644 (file)
@@ -494,6 +494,8 @@ fn compile_decl<'a, 'b: 'a>(wam: &'a mut Machine, tl: &'b TopLevel, queue: &'b V
                 return EvalSession::from(e);
             };
 
+            print_code(&code);
+            
             if !code.is_empty() {
                 if let Some(name) = tl.name() {
                     wam.add_user_code(name, tl.arity(), code)
index caea4b3dda8660d6a4d1a6bc1ea3e8c6d2e6889b..a61426762ce926038f358195f38f60cadbad3677 100644 (file)
@@ -1466,7 +1466,7 @@ impl MachineState {
                     _ => {
                         self.num_of_args = 2;
                         self.b0 = self.b;
-                        self.p = CodePtr::DirEntry(361); // goto sgc_on_success/2, 361.
+                        self.p = CodePtr::DirEntry(364); // goto sgc_on_success/2, 364.
                     }
                 };
             },
@@ -1797,7 +1797,7 @@ impl MachineState {
                     self.cp = self.p;
                     self.num_of_args = 0;
                     self.b0 = self.b;
-                    self.p  = CodePtr::DirEntry(349); // goto_call run_cleaners_without_handling/0.
+                    self.p  = CodePtr::DirEntry(352); // goto_call run_cleaners_without_handling/0.
                 }
             }
         }