ctx->replace(tag<bignum>(bignum_integer_length(untag<bignum>(ctx->peek()))));
}
-/* Allocates memory */
-cell factor_vm::unbox_array_size_slow() {
- if (tagged<object>(ctx->peek()).type() == BIGNUM_TYPE) {
- bignum* zero = untag<bignum>(bignum_zero);
- GC_BIGNUM(zero);
- bignum* max = cell_to_bignum(array_size_max);
- bignum* n = untag<bignum>(ctx->peek());
- if (bignum_compare(n, zero) != bignum_comparison_less &&
- bignum_compare(n, max) == bignum_comparison_less) {
- ctx->pop();
- return bignum_to_cell(n);
- }
- }
-
- general_error(ERROR_ARRAY_SIZE, ctx->pop(), tag_fixnum(array_size_max));
- return 0; /* can't happen */
-}
-
/* Allocates memory */
void factor_vm::primitive_fixnum_to_float() {
ctx->replace(allot_float(fixnum_to_float(ctx->peek())));
}
inline cell factor_vm::unbox_array_size() {
- cell obj = ctx->peek();
- if (TAG(obj) == FIXNUM_TYPE) {
- fixnum n = untag_fixnum(obj);
- if (n >= 0 && n < (fixnum)array_size_max) {
- ctx->pop();
- return n;
- }
+ cell obj = ctx->pop();
+ fixnum n = to_fixnum(obj);
+ if (n >= 0 && n < (fixnum)array_size_max) {
+ return n;
}
-
- return unbox_array_size_slow();
+ general_error(ERROR_ARRAY_SIZE, obj, tag_fixnum(array_size_max));
+ return 0; /* can't happen */
}
VM_C_API cell from_signed_cell(fixnum integer, factor_vm* vm);