clear ball before setting it (#246)
This commit is contained in:
@@ -42,19 +42,27 @@ impl AndStack {
|
||||
AndStack(mem::replace(&mut self.0, vec![]))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn push(&mut self, global_index: usize, e: usize, cp: LocalCodePtr, n: usize) {
|
||||
let len = self.0.len();
|
||||
self.0.push(Frame::new(global_index, len, e, cp, n));
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn len(&self) -> usize {
|
||||
self.0.len()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn clear(&mut self) {
|
||||
self.0.clear()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn top(&self) -> Option<&Frame> {
|
||||
self.0.last()
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
// See MachineState::allocate for why this is commented out.
|
||||
|
||||
@@ -486,7 +486,6 @@ pub(crate) trait CallPolicy: Any {
|
||||
machine_st.pstr_tr = machine_st.or_stack[b].pstr_tr;
|
||||
|
||||
machine_st.pstr_trail.truncate(machine_st.pstr_tr);
|
||||
|
||||
machine_st.heap.truncate(machine_st.or_stack[b].h);
|
||||
|
||||
let attr_var_init_queue_b = machine_st.or_stack[b].attr_var_init_queue_b;
|
||||
@@ -532,7 +531,6 @@ pub(crate) trait CallPolicy: Any {
|
||||
machine_st.pstr_tr = machine_st.or_stack[b].pstr_tr;
|
||||
|
||||
machine_st.pstr_trail.truncate(machine_st.pstr_tr);
|
||||
|
||||
machine_st.heap.truncate(machine_st.or_stack[b].h);
|
||||
|
||||
let attr_var_init_queue_b = machine_st.or_stack[b].attr_var_init_queue_b;
|
||||
@@ -578,8 +576,8 @@ pub(crate) trait CallPolicy: Any {
|
||||
let curr_pstr_tr = machine_st.pstr_tr;
|
||||
|
||||
machine_st.unwind_pstr_trail(old_pstr_tr, curr_pstr_tr);
|
||||
machine_st.pstr_tr = machine_st.or_stack[b].pstr_tr;
|
||||
|
||||
machine_st.pstr_tr = machine_st.or_stack[b].pstr_tr;
|
||||
machine_st.pstr_trail.truncate(machine_st.pstr_tr);
|
||||
|
||||
machine_st.heap.truncate(machine_st.or_stack[b].h);
|
||||
|
||||
@@ -125,16 +125,14 @@ impl MachineState {
|
||||
|
||||
pub(super) fn next_global_index(&self) -> usize {
|
||||
max(
|
||||
if self.and_stack.len() > 0 {
|
||||
self.and_stack[self.e].global_index
|
||||
} else {
|
||||
0
|
||||
},
|
||||
if self.b > 0 {
|
||||
self.or_stack[self.b - 1].global_index
|
||||
} else {
|
||||
0
|
||||
},
|
||||
self.or_stack
|
||||
.top()
|
||||
.map(|or_fr| or_fr.global_index)
|
||||
.unwrap_or(0),
|
||||
self.and_stack
|
||||
.top()
|
||||
.map(|or_fr| or_fr.global_index)
|
||||
.unwrap_or(0),
|
||||
) + 1
|
||||
}
|
||||
|
||||
@@ -2039,8 +2037,11 @@ impl MachineState {
|
||||
}
|
||||
|
||||
pub(super) fn set_ball(&mut self) {
|
||||
self.ball.reset();
|
||||
|
||||
let addr = self[temp_v!(1)].clone();
|
||||
self.ball.boundary = self.heap.h;
|
||||
|
||||
copy_term(
|
||||
CopyBallTerm::new(&mut self.and_stack, &mut self.heap, &mut self.ball.stub),
|
||||
addr,
|
||||
|
||||
@@ -42,8 +42,7 @@
|
||||
( expand_goals(Term0, Term) -> true
|
||||
; Term = Term0
|
||||
),
|
||||
( '$get_b_value'(B), call(Term),
|
||||
'$write_eqs_and_read_input'(B, VarList),
|
||||
( '$get_b_value'(B), call(Term), '$write_eqs_and_read_input'(B, VarList),
|
||||
!
|
||||
; write('false.'), nl
|
||||
).
|
||||
|
||||
Reference in New Issue
Block a user