}
}
-/* Allocates memory */
/* make an alien */
+/* Allocates memory */
cell factor_vm::allot_alien(cell delegate_, cell displacement)
{
if(displacement == 0)
return allot_alien(false_object,(cell)address);
}
-/* Allocates memory */
/* make an alien pointing at an offset of another alien */
+/* Allocates memory */
void factor_vm::primitive_displaced_alien()
{
cell alien = ctx->pop();
}
}
-/* Allocates memory (from_unsigned_cell can allocate) */
/* address of an object representing a C pointer. Explicitly throw an error
if the object is a byte array, as a sanity check. */
+/* Allocates memory (from_unsigned_cell can allocate) */
void factor_vm::primitive_alien_address()
{
ctx->replace(from_unsigned_cell((cell)pinned_alien_offset(ctx->peek())));
ctx->push(library.value());
}
-/* Allocates memory */
/* look up a symbol in a native library */
+/* Allocates memory */
void factor_vm::primitive_dlsym()
{
data_root<object> library(ctx->pop(),this);
ctx->replace(allot_alien(ffi_dlsym(NULL,sym)));
}
-/* Allocates memory */
/* look up a symbol in a native library */
+/* Allocates memory */
void factor_vm::primitive_dlsym_raw()
{
data_root<object> library(ctx->pop(),this);
: (bignum_compare_unsigned (x, y))));
}
-/* allocates memory */
+/* Allocates memory */
bignum *factor_vm::bignum_add(bignum * x, bignum * y)
{
return
: (bignum_add_unsigned (x, y, 0)))));
}
-/* allocates memory */
+/* Allocates memory */
bignum *factor_vm::bignum_subtract(bignum * x, bignum * y)
{
return
: (bignum_subtract_unsigned (x, y))))));
}
-/* allocates memory */
+/* Allocates memory */
bignum *factor_vm::bignum_multiply(bignum * x, bignum * y)
{
bignum_length_type x_length = (BIGNUM_LENGTH (x));
return (bignum_multiply_unsigned (x, y, negative_p));
}
-/* allocates memory */
+/* Allocates memory */
void factor_vm::bignum_divide(bignum * numerator, bignum * denominator, bignum * * quotient, bignum * * remainder)
{
if (BIGNUM_ZERO_P (denominator))
}
}
-/* allocates memory */
+/* Allocates memory */
bignum *factor_vm::bignum_quotient(bignum * numerator, bignum * denominator)
{
if (BIGNUM_ZERO_P (denominator))
}
}
-/* allocates memory */
+/* Allocates memory */
bignum *factor_vm::bignum_remainder(bignum * numerator, bignum * denominator)
{
if (BIGNUM_ZERO_P (denominator))
}
}
-/* allocates memory */
+/* Allocates memory */
/* cell_to_bignum, fixnum_to_bignum, long_long_to_bignum, ulong_long_to_bignum */
#define FOO_TO_BIGNUM(name,type,stype,utype) \
bignum * factor_vm::name##_to_bignum(type n) \
#define inf std::numeric_limits<double>::infinity()
-/* allocates memory */
+/* Allocates memory */
bignum *factor_vm::double_to_bignum(double x)
{
if (x == inf || x == -inf || x != x) return (BIGNUM_ZERO ());
/* Addition */
-/* allocates memory */
+/* Allocates memory */
bignum *factor_vm::bignum_add_unsigned(bignum * x, bignum * y, int negative_p)
{
GC_BIGNUM(x); GC_BIGNUM(y);
/* Subtraction */
-/* allocates memory */
+/* Allocates memory */
bignum *factor_vm::bignum_subtract_unsigned(bignum * x, bignum * y)
{
GC_BIGNUM(x); GC_BIGNUM(y);
Maximum value for carry: ((R * (R - 1)) + (R - 1))
where R == BIGNUM_RADIX_ROOT */
-/* allocates memory */
+/* Allocates memory */
bignum *factor_vm::bignum_multiply_unsigned(bignum * x, bignum * y, int negative_p)
{
GC_BIGNUM(x); GC_BIGNUM(y);
}
}
-/* allocates memory */
+/* Allocates memory */
bignum *factor_vm::bignum_multiply_unsigned_small_factor(bignum * x, bignum_digit_type y, int negative_p)
{
GC_BIGNUM(x);
volume 2, "Seminumerical Algorithms"
section 4.3.1, "Multiple-Precision Arithmetic". */
-/* allocates memory */
+/* Allocates memory */
void factor_vm::bignum_divide_unsigned_large_denominator(bignum * numerator, bignum * denominator, bignum * * quotient, bignum * * remainder, int q_negative_p, int r_negative_p)
{
GC_BIGNUM(numerator); GC_BIGNUM(denominator);
return (guess - 1);
}
-/* allocates memory */
+/* Allocates memory */
void factor_vm::bignum_divide_unsigned_medium_denominator(bignum * numerator,bignum_digit_type denominator, bignum * * quotient, bignum * * remainder,int q_negative_p, int r_negative_p)
{
GC_BIGNUM(numerator);
#undef BDDS_MULSUB
#undef BDDS_ADD
-/* allocates memory */
+/* Allocates memory */
void factor_vm::bignum_divide_unsigned_small_denominator(bignum * numerator, bignum_digit_type denominator, bignum * * quotient, bignum * * remainder,int q_negative_p, int r_negative_p)
{
GC_BIGNUM(numerator);
#undef quotient_high
}
-/* allocates memory */
+/* Allocates memory */
bignum * factor_vm::bignum_remainder_unsigned_small_denominator(bignum * n, bignum_digit_type d, int negative_p)
{
bignum_digit_type two_digits;
return (bignum_digit_to_bignum (r, negative_p));
}
-/* allocates memory */
+/* Allocates memory */
bignum *factor_vm::bignum_digit_to_bignum(bignum_digit_type digit, int negative_p)
{
if (digit == 0)
}
}
-/* allocates memory */
+/* Allocates memory */
bignum *factor_vm::allot_bignum(bignum_length_type length, int negative_p)
{
BIGNUM_ASSERT ((length >= 0) || (length < BIGNUM_RADIX));
return (result);
}
-/* allocates memory */
+/* Allocates memory */
bignum * factor_vm::allot_bignum_zeroed(bignum_length_type length, int negative_p)
{
bignum * result = allot_bignum(length,negative_p);
#define BIGNUM_REDUCE_LENGTH(source, length) \
source = reallot_array(source,length + 1)
-/* allocates memory */
+/* Allocates memory */
bignum *factor_vm::bignum_shorten_length(bignum * bignum, bignum_length_type length)
{
bignum_length_type current_length = (BIGNUM_LENGTH (bignum));
return (bignum);
}
-/* allocates memory */
+/* Allocates memory */
bignum *factor_vm::bignum_trim(bignum * bignum)
{
bignum_digit_type * start = (BIGNUM_START_PTR (bignum));
/* Copying */
-/* allocates memory */
+/* Allocates memory */
bignum *factor_vm::bignum_new_sign(bignum * x, int negative_p)
{
GC_BIGNUM(x);
return (result);
}
-/* allocates memory */
+/* Allocates memory */
bignum *factor_vm::bignum_maybe_new_sign(bignum * x, int negative_p)
{
if ((BIGNUM_NEGATIVE_P (x)) ? negative_p : (! negative_p))
* Added bitwise operations (and oddp).
*/
-/* allocates memory */
+/* Allocates memory */
bignum *factor_vm::bignum_bitwise_not(bignum * x)
{
GC_BIGNUM (x);
}
}
-/* allocates memory */
+/* Allocates memory */
bignum *factor_vm::bignum_arithmetic_shift(bignum * arg1, fixnum n)
{
if (BIGNUM_NEGATIVE_P(arg1) && n < 0)
#define IOR_OP 1
#define XOR_OP 2
-/* allocates memory */
+/* Allocates memory */
bignum *factor_vm::bignum_bitwise_and(bignum * arg1, bignum * arg2)
{
return(
);
}
-/* allocates memory */
+/* Allocates memory */
bignum *factor_vm::bignum_bitwise_ior(bignum * arg1, bignum * arg2)
{
return(
);
}
-/* allocates memory */
+/* Allocates memory */
bignum *factor_vm::bignum_bitwise_xor(bignum * arg1, bignum * arg2)
{
return(
);
}
-/* allocates memory */
+/* Allocates memory */
/* ash for the magnitude */
/* assume arg1 is a big number, n is a long */
bignum *factor_vm::bignum_magnitude_ash(bignum * arg1, fixnum n)
return (bignum_trim (result));
}
-/* allocates memory */
+/* Allocates memory */
bignum *factor_vm::bignum_pospos_bitwise_op(int op, bignum * arg1, bignum * arg2)
{
GC_BIGNUM(arg1); GC_BIGNUM(arg2);
return bignum_trim(result);
}
-/* allocates memory */
+/* Allocates memory */
bignum *factor_vm::bignum_posneg_bitwise_op(int op, bignum * arg1, bignum * arg2)
{
GC_BIGNUM(arg1); GC_BIGNUM(arg2);
return bignum_trim(result);
}
-/* allocates memory */
+/* Allocates memory */
bignum *factor_vm::bignum_negneg_bitwise_op(int op, bignum * arg1, bignum * arg2)
{
GC_BIGNUM(arg1); GC_BIGNUM(arg2);
ctx->replace(tag<bignum>(bignum_integer_length(untag<bignum>(ctx->peek()))));
}
-/* allocates memory */
+/* Allocates memory */
cell factor_vm::unbox_array_size_slow()
{
if(tagged<object>(ctx->peek()).type() == BIGNUM_TYPE)
return 0; /* can't happen */
}
+/* Allocates memory */
void factor_vm::primitive_fixnum_to_float()
{
ctx->replace(allot_float(fixnum_to_float(ctx->peek())));
}
+/* Allocates memory */
void factor_vm::primitive_format_float()
{
byte_array *array = allot_byte_array(100);
ctx->replace(tag_boolean(x == y));
}
+/* Allocates memory */
void factor_vm::primitive_float_add()
{
POP_FLOATS(x,y);
ctx->replace(allot_float(x + y));
}
+/* Allocates memory */
void factor_vm::primitive_float_subtract()
{
POP_FLOATS(x,y);
ctx->replace(allot_float(x - y));
}
+/* Allocates memory */
void factor_vm::primitive_float_multiply()
{
POP_FLOATS(x,y);
ctx->replace(allot_float(x * y));
}
+/* Allocates memory */
void factor_vm::primitive_float_divfloat()
{
POP_FLOATS(x,y);
ctx->push(from_unsigned_8(double_bits(untag_float_check(ctx->pop()))));
}
+/* Allocates memory */
void factor_vm::primitive_bits_double()
{
ctx->push(allot_float(bits_double(to_unsigned_8(ctx->pop()))));
return parent->to_signed_8(obj);
}
+/* Allocates memory */
cell factor_vm::from_unsigned_8(u64 n)
{
if(n > (u64)fixnum_max)