add compare predicate.

This commit is contained in:
Mark Thom
2018-02-21 23:21:18 -07:00
parent 5de03444eb
commit 9aac3cb086
10 changed files with 146 additions and 7 deletions

View File

@@ -1020,7 +1020,11 @@ impl MachineState {
}
pub(super) fn copy_and_align_ball_to_heap(&mut self) {
let diff = self.ball.0 - self.heap.h;
let diff = if self.ball.0 > self.heap.h {
self.ball.0 - self.heap.h
} else {
self.heap.h - self.ball.0
};
for heap_value in self.ball.1.iter().cloned() {
self.heap.push(match heap_value {
@@ -1830,6 +1834,36 @@ impl MachineState {
}
};
},
&ControlInstruction::CompareCall => {
let a1 = self[temp_v!(1)].clone();
let a2 = self[temp_v!(2)].clone();
let a3 = self[temp_v!(3)].clone();
let c = Addr::Con(match self.compare_term_test(a2, a3) {
Ordering::Greater => atom!(">", self.atom_tbl),
Ordering::Equal => atom!("=", self.atom_tbl),
Ordering::Less => atom!("<", self.atom_tbl)
});
self.unify(a1, c);
self.p += 1;
},
&ControlInstruction::CompareExecute => {
let a1 = self[temp_v!(1)].clone();
let a2 = self[temp_v!(2)].clone();
let a3 = self[temp_v!(3)].clone();
let c = Addr::Con(match self.compare_term_test(a2, a3) {
Ordering::Greater => atom!(">", self.atom_tbl),
Ordering::Equal => atom!("=", self.atom_tbl),
Ordering::Less => atom!("<", self.atom_tbl)
});
self.unify(a1, c);
self.p = self.cp;
},
&ControlInstruction::CompareTermCall(qt) => {
match qt {
CompareTermQT::Equal =>