VM: Refactor bignum to Factor style
parent
6dacc44029
commit
a80271c79c
804
vm/bignum.cpp
804
vm/bignum.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,4 @@
|
|||
namespace factor
|
||||
{
|
||||
namespace factor {
|
||||
|
||||
/*
|
||||
|
||||
|
@ -37,8 +36,7 @@ MIT in each case. */
|
|||
|
||||
#define BIGNUM_OUT_OF_BAND ((bignum*)0)
|
||||
|
||||
enum bignum_comparison
|
||||
{
|
||||
enum bignum_comparison {
|
||||
bignum_comparison_equal = 0,
|
||||
bignum_comparison_less = -1,
|
||||
bignum_comparison_greater = 1
|
||||
|
|
|
@ -33,8 +33,7 @@ Technology nor of any adaptation thereof in any advertising,
|
|||
promotional, or sales literature without prior written consent from
|
||||
MIT in each case. */
|
||||
|
||||
namespace factor
|
||||
{
|
||||
namespace factor {
|
||||
|
||||
/* Internal Interface to Bignum Code */
|
||||
#undef BIGNUM_ZERO_P
|
||||
|
@ -69,25 +68,21 @@ typedef s64 bignum_twodigit_type;
|
|||
#define BIGNUM_DIGIT_MASK (BIGNUM_RADIX - 1)
|
||||
#define BIGNUM_HALF_DIGIT_MASK (BIGNUM_RADIX_ROOT - 1)
|
||||
|
||||
#define BIGNUM_START_PTR(bignum) \
|
||||
((BIGNUM_TO_POINTER (bignum)) + 1)
|
||||
#define BIGNUM_START_PTR(bignum) ((BIGNUM_TO_POINTER(bignum)) + 1)
|
||||
|
||||
#define BIGNUM_LENGTH(bignum) (untag_fixnum((bignum)->capacity) - 1)
|
||||
|
||||
#define BIGNUM_NEGATIVE_P(bignum) (bignum->data()[0] != 0)
|
||||
#define BIGNUM_SET_NEGATIVE_P(bignum, neg) (bignum->data()[0] = neg)
|
||||
|
||||
#define BIGNUM_ZERO_P(bignum) \
|
||||
((BIGNUM_LENGTH (bignum)) == 0)
|
||||
#define BIGNUM_ZERO_P(bignum) ((BIGNUM_LENGTH(bignum)) == 0)
|
||||
|
||||
#define BIGNUM_REF(bignum, index) \
|
||||
(* ((BIGNUM_START_PTR (bignum)) + (index)))
|
||||
#define BIGNUM_REF(bignum, index) (*((BIGNUM_START_PTR(bignum)) + (index)))
|
||||
|
||||
/* These definitions are here to facilitate caching of the constants
|
||||
0, 1, and -1. */
|
||||
#define BIGNUM_ZERO() untag<bignum>(bignum_zero)
|
||||
#define BIGNUM_ONE(neg_p) \
|
||||
untag<bignum>(neg_p ? bignum_neg_one : bignum_pos_one)
|
||||
#define BIGNUM_ONE(neg_p) untag<bignum>(neg_p ? bignum_neg_one : bignum_pos_one)
|
||||
|
||||
#define HD_LOW(digit) ((digit) & BIGNUM_HALF_DIGIT_MASK)
|
||||
#define HD_HIGH(digit) ((digit) >> BIGNUM_HALF_DIGIT_LENGTH)
|
||||
|
|
Loading…
Reference in New Issue