mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-16 09:17:35 +02:00
WIP - bignum2 simplify
This commit is contained in:
parent
e7c50161b5
commit
a956c6fd41
2 changed files with 32 additions and 31 deletions
|
@ -854,6 +854,7 @@ typedef struct {
|
||||||
#define C_bignum_digits(n) (&(((bignum2_type *)n)->sign) + 1)
|
#define C_bignum_digits(n) (&(((bignum2_type *)n)->sign) + 1)
|
||||||
#define C_bignum_size(n) (((bignum2_type *)n)->num_digits)
|
#define C_bignum_size(n) (((bignum2_type *)n)->num_digits)
|
||||||
#define C_bignum_sign(n) (((bignum2_type *)n)->sign)
|
#define C_bignum_sign(n) (((bignum2_type *)n)->sign)
|
||||||
|
#define C_bignum_negativep(n) (((bignum2_type *)n)->sign == 1)
|
||||||
|
|
||||||
// TODO: covert applicable definitions below -
|
// TODO: covert applicable definitions below -
|
||||||
// #ifdef C_SIXTY_FOUR
|
// #ifdef C_SIXTY_FOUR
|
||||||
|
|
62
runtime.c
62
runtime.c
|
@ -2451,37 +2451,37 @@ int bignum2_num_digits(bignum2_type *bn, int radix)
|
||||||
* in scratch space, we mark it as reclaimable. This means any
|
* in scratch space, we mark it as reclaimable. This means any
|
||||||
* references to the original bignum are invalid after simplification!
|
* references to the original bignum are invalid after simplification!
|
||||||
*/
|
*/
|
||||||
//C_regparm C_word C_fcall C_bignum_simplify(C_word big)
|
object C_bignum_simplify(object big)
|
||||||
//{
|
{
|
||||||
// C_uword *start = C_bignum_digits(big),
|
uint32_t *start = C_bignum_digits(big),
|
||||||
// *last_digit = start + C_bignum_size(big) - 1,
|
*last_digit = start + C_bignum_size(big) - 1,
|
||||||
// *scan = last_digit, tmp;
|
*scan = last_digit, tmp;
|
||||||
// int length;
|
int length;
|
||||||
//
|
|
||||||
// while (scan >= start && *scan == 0)
|
while (scan >= start && *scan == 0)
|
||||||
// scan--;
|
scan--;
|
||||||
// length = scan - start + 1;
|
length = scan - start + 1;
|
||||||
//
|
|
||||||
// switch(length) {
|
switch(length) {
|
||||||
// case 0:
|
case 0:
|
||||||
// if (C_in_scratchspacep(C_internal_bignum_vector(big)))
|
//if (C_in_scratchspacep(C_internal_bignum_vector(big)))
|
||||||
// C_mutate_scratch_slot(NULL, C_internal_bignum_vector(big));
|
// C_mutate_scratch_slot(NULL, C_internal_bignum_vector(big));
|
||||||
// return C_fix(0);
|
return obj_int2obj(0);
|
||||||
// case 1:
|
case 1:
|
||||||
// tmp = *start;
|
tmp = *start;
|
||||||
// if (C_bignum_negativep(big) ?
|
if (C_bignum_negativep(big) ?
|
||||||
// !(tmp & C_INT_SIGN_BIT) && C_fitsinfixnump(-(C_word)tmp) :
|
!(tmp & C_INT_SIGN_BIT) && C_fitsinfixnump(-(C_word)tmp) :
|
||||||
// C_ufitsinfixnump(tmp)) {
|
C_ufitsinfixnump(tmp)) {
|
||||||
// if (C_in_scratchspacep(C_internal_bignum_vector(big)))
|
if (C_in_scratchspacep(C_internal_bignum_vector(big)))
|
||||||
// C_mutate_scratch_slot(NULL, C_internal_bignum_vector(big));
|
C_mutate_scratch_slot(NULL, C_internal_bignum_vector(big));
|
||||||
// return C_bignum_negativep(big) ? C_fix(-(C_word)tmp) : C_fix(tmp);
|
return C_bignum_negativep(big) ? C_fix(-(C_word)tmp) : C_fix(tmp);
|
||||||
// }
|
}
|
||||||
// /* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
// default:
|
default:
|
||||||
// if (scan < last_digit) C_bignum_mutate_size(big, length);
|
if (scan < last_digit) C_bignum_mutate_size(big, length);
|
||||||
// return big;
|
return big;
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
|
|
||||||
static uint32_t bignum_digits_destructive_scale_down(uint32_t *start, uint32_t *end, uint32_t denominator)
|
static uint32_t bignum_digits_destructive_scale_down(uint32_t *start, uint32_t *end, uint32_t denominator)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue