981 Reimplement as library system call

This commit is contained in:
Regan-Koopmans
2021-06-17 12:10:25 +02:00
parent 176daeec03
commit 72a7765b58
3 changed files with 21 additions and 1 deletions

View File

@@ -5539,6 +5539,19 @@ impl MachineState {
&SystemClauseType::DebugHook => {
self.fail = false;
}
&SystemClauseType::PopCount => {
let number = self.store(self.deref(self[temp_v!(1)]));
let count = match Number::try_from((number, &self.heap)) {
Ok(Number::Fixnum(n)) => Integer::from(n.count_ones()),
Ok(Number::Integer(n)) => Integer::from((&*n).count_ones().unwrap()),
_ => {
unreachable!()
}
};
let pop_count = self.heap.to_unifiable(HeapCellValue::Integer(Rc::new(count)));
(self.unify_fn)(self, self[temp_v!(2)], pop_count);
}
};
return_from_clause!(self.last_call, self)