fix setup_call_cleanup bug

This commit is contained in:
Mark Thom
2018-02-01 23:39:03 -07:00
parent 7b5a2786da
commit 9c2e8dfd72
4 changed files with 17 additions and 12 deletions

View 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)),

View 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));

View 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)

View 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.
}
}
}