Fixed some conversion issues
This commit is contained in:
@@ -918,6 +918,7 @@ op(Priority, OpSpec, Op) :-
|
|||||||
halt :- halt(0).
|
halt :- halt(0).
|
||||||
|
|
||||||
halt(N) :-
|
halt(N) :-
|
||||||
|
must_be_number(N, halt/1),
|
||||||
( -2^31 =< N, N =< 2^31 - 1 ->
|
( -2^31 =< N, N =< 2^31 - 1 ->
|
||||||
'$halt'(N)
|
'$halt'(N)
|
||||||
; throw(error(domain_error(exit_code, N), halt/1))
|
; throw(error(domain_error(exit_code, N), halt/1))
|
||||||
|
|||||||
@@ -1706,6 +1706,12 @@ impl MachineState {
|
|||||||
Ok(Number::Integer(n)) => {
|
Ok(Number::Integer(n)) => {
|
||||||
n.to_string()
|
n.to_string()
|
||||||
}
|
}
|
||||||
|
Ok(Number::Rational(r)) => {
|
||||||
|
// n has already been confirmed as an integer, and
|
||||||
|
// internally, Rational is assumed reduced, so its
|
||||||
|
// denominator must be 1.
|
||||||
|
r.numer().to_string()
|
||||||
|
}
|
||||||
_ => {
|
_ => {
|
||||||
unreachable!()
|
unreachable!()
|
||||||
}
|
}
|
||||||
@@ -3766,6 +3772,12 @@ impl MachineState {
|
|||||||
let code = match Number::try_from((code, &self.heap)) {
|
let code = match Number::try_from((code, &self.heap)) {
|
||||||
Ok(Number::Fixnum(n)) => n as i32,
|
Ok(Number::Fixnum(n)) => n as i32,
|
||||||
Ok(Number::Integer(n)) => n.to_i32().unwrap(),
|
Ok(Number::Integer(n)) => n.to_i32().unwrap(),
|
||||||
|
Ok(Number::Rational(r)) => {
|
||||||
|
// n has already been confirmed as an integer, and
|
||||||
|
// internally, Rational is assumed reduced, so its
|
||||||
|
// denominator must be 1.
|
||||||
|
r.numer().to_i32().unwrap()
|
||||||
|
}
|
||||||
_ => { unreachable!() }
|
_ => { unreachable!() }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user