pop AND stack frames after unwinding the trail (#250)

This commit is contained in:
Mark Thom
2019-12-03 23:11:57 -07:00
parent 43b39538ff
commit 9ae029b04d
2 changed files with 11 additions and 7 deletions

View File

@@ -510,8 +510,8 @@ pub(crate) trait CallPolicy: Any {
machine_st.registers[i] = machine_st.or_stack[b][i].clone();
}
machine_st.pop_stack_frames();
let old_e = machine_st.e;
machine_st.num_of_args = n;
machine_st.e = machine_st.or_stack[b].e;
machine_st.cp = machine_st.or_stack[b].cp.clone();
@@ -522,6 +522,8 @@ pub(crate) trait CallPolicy: Any {
machine_st.unwind_trail(old_tr, curr_tr);
machine_st.tr = machine_st.or_stack[b].tr;
machine_st.pop_stack_frames(old_e);
machine_st.trail.truncate(machine_st.tr);
let old_pstr_tr = machine_st.or_stack[b].pstr_tr;
@@ -558,7 +560,7 @@ pub(crate) trait CallPolicy: Any {
machine_st.registers[i] = machine_st.or_stack[b][i].clone();
}
machine_st.pop_stack_frames();
let old_e = machine_st.e;
machine_st.num_of_args = n;
machine_st.e = machine_st.or_stack[b].e;
@@ -570,6 +572,8 @@ pub(crate) trait CallPolicy: Any {
machine_st.unwind_trail(old_tr, curr_tr);
machine_st.tr = machine_st.or_stack[b].tr;
machine_st.pop_stack_frames(old_e);
machine_st.trail.truncate(machine_st.tr);
let old_pstr_tr = machine_st.or_stack[b].pstr_tr;

View File

@@ -3172,9 +3172,9 @@ impl MachineState {
self.p += 1;
}
pub(super) fn pop_stack_frames(&mut self) {
if self.and_stack.len() > self.e {
let and_gi = self.and_stack[self.e].global_index;
pub(super) fn pop_stack_frames(&mut self, e: usize) {
if self.and_stack.len() > e {
let and_gi = self.and_stack[e].global_index;
let or_gi = self
.or_stack
.top()
@@ -3182,7 +3182,7 @@ impl MachineState {
.unwrap_or(0);
if and_gi > or_gi {
self.and_stack.truncate(self.e + 1);
self.and_stack.truncate(e + 1);
}
}
}