implement unify_ginteger to address FIXME in skip_max_list_cycle
This commit is contained in:
@@ -278,6 +278,11 @@ impl MachineState {
|
||||
unifier.unify_fixnum(n1, value);
|
||||
}
|
||||
|
||||
pub fn unify_ginteger(&mut self, n1: GInteger, value: HeapCellValue) {
|
||||
let mut unifier = DefaultUnifier::from(self);
|
||||
unifier.unify_ginteger(n1, value);
|
||||
}
|
||||
|
||||
pub fn unify_big_int(&mut self, n1: TypedArenaPtr<Integer>, value: HeapCellValue) {
|
||||
let mut unifier = DefaultUnifier::from(self);
|
||||
unifier.unify_big_integer(n1, value);
|
||||
|
||||
@@ -744,11 +744,9 @@ impl MachineState {
|
||||
}
|
||||
|
||||
let target_n = self.store(self.deref(self.registers[1]));
|
||||
self.unify_fixnum(
|
||||
/* FIXME this is not safe */
|
||||
unsafe { Fixnum::build_with_unchecked(brent_st.num_steps() as i64) },
|
||||
target_n,
|
||||
);
|
||||
let num_steps = fixnum!(GInteger, brent_st.num_steps() as i64, &mut self.arena);
|
||||
|
||||
self.unify_ginteger(num_steps, target_n);
|
||||
|
||||
if !self.fail {
|
||||
unify!(self, self.registers[4], self.heap[prev_hare]);
|
||||
|
||||
@@ -150,6 +150,13 @@ pub(crate) trait Unifier: DerefMut<Target = MachineState> {
|
||||
);
|
||||
}
|
||||
|
||||
fn unify_ginteger(&mut self, n: GInteger, value: HeapCellValue) {
|
||||
match n {
|
||||
GInteger::Integer(integer) => self.unify_big_int(integer, value),
|
||||
GInteger::Fixnum(fixnum) => self.unify_fixnum(fixnum, value),
|
||||
}
|
||||
}
|
||||
|
||||
fn unify_atom(&mut self, atom: Atom, value: HeapCellValue) {
|
||||
read_heap_cell!(value,
|
||||
(HeapCellValueTag::Atom, (name, arity)) => {
|
||||
|
||||
Reference in New Issue
Block a user