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!(), reset_block!(),
query![put_var!(perm_v!(1), 1)], query![put_var!(perm_v!(1), 1)],
get_ball!(), 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)], query![put_value!(perm_v!(1), 1)],
deallocate!(), deallocate!(),
goto_execute!(59, 1), goto_execute!(59, 1),
trust_me!(), trust_me!(),
goto_execute!(349, 0), // goto run_cleaners_without_handling/0, 349. allocate!(0),
try_me_else!(10), // run_cleaners_with_handling/0, 337. 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), allocate!(2),
get_level!(perm_v!(1)), get_level!(perm_v!(1)),
query![put_var!(perm_v!(2), 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. goto_call!(5, 3), // goto catch/3, 5.
cut!(perm_v!(1)), cut!(perm_v!(1)),
deallocate!(), 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!(), trust_me!(),
proceed!(), proceed!(),
try_me_else!(10), // run_cleaners_without_handling/1, 349. try_me_else!(10), // run_cleaners_without_handling/1, 352.
allocate!(2), allocate!(2),
get_level!(perm_v!(1)), get_level!(perm_v!(1)),
query![put_var!(perm_v!(2), 1)], query![put_var!(perm_v!(2), 1)],
@@ -513,10 +516,10 @@ fn get_builtins(atom_tbl: TabledData<Atom>) -> Code {
call_n!(1), call_n!(1),
cut!(perm_v!(1)), cut!(perm_v!(1)),
deallocate!(), 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!(), trust_me!(),
proceed!(), proceed!(),
allocate!(1), // sgc_on_success/2, 361. allocate!(1), // sgc_on_success/2, 364.
fact![get_var_in_fact!(perm_v!(1), 2)], fact![get_var_in_fact!(perm_v!(1), 2)],
reset_block!(), reset_block!(),
cut!(perm_v!(1)), cut!(perm_v!(1)),

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); return EvalSession::from(e);
}; };
print_code(&code);
if !code.is_empty() { if !code.is_empty() {
if let Some(name) = tl.name() { if let Some(name) = tl.name() {
wam.add_user_code(name, tl.arity(), code) wam.add_user_code(name, tl.arity(), code)

View File

@@ -1466,7 +1466,7 @@ impl MachineState {
_ => { _ => {
self.num_of_args = 2; self.num_of_args = 2;
self.b0 = self.b; 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.cp = self.p;
self.num_of_args = 0; self.num_of_args = 0;
self.b0 = self.b; 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.
} }
} }
} }