VM: changing case of enums values bignum_comparison and generation
It is consistent if all enum values have all uppercase names.char-rename
parent
4f6381587c
commit
df171b0485
|
@ -62,17 +62,17 @@ int factor_vm::bignum_equal_p(bignum* x, bignum* y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
enum bignum_comparison factor_vm::bignum_compare(bignum* x, bignum* y) {
|
enum bignum_comparison factor_vm::bignum_compare(bignum* x, bignum* y) {
|
||||||
return ((BIGNUM_ZERO_P(x)) ? ((BIGNUM_ZERO_P(y)) ? bignum_comparison_equal
|
return ((BIGNUM_ZERO_P(x)) ? ((BIGNUM_ZERO_P(y)) ? BIGNUM_COMPARISON_EQUAL
|
||||||
: (BIGNUM_NEGATIVE_P(y))
|
: (BIGNUM_NEGATIVE_P(y))
|
||||||
? bignum_comparison_greater
|
? BIGNUM_COMPARISON_GREATER
|
||||||
: bignum_comparison_less)
|
: BIGNUM_COMPARISON_LESS)
|
||||||
: (BIGNUM_ZERO_P(y))
|
: (BIGNUM_ZERO_P(y))
|
||||||
? ((BIGNUM_NEGATIVE_P(x)) ? bignum_comparison_less
|
? ((BIGNUM_NEGATIVE_P(x)) ? BIGNUM_COMPARISON_LESS
|
||||||
: bignum_comparison_greater)
|
: BIGNUM_COMPARISON_GREATER)
|
||||||
: (BIGNUM_NEGATIVE_P(x))
|
: (BIGNUM_NEGATIVE_P(x))
|
||||||
? ((BIGNUM_NEGATIVE_P(y)) ? (bignum_compare_unsigned(y, x))
|
? ((BIGNUM_NEGATIVE_P(y)) ? (bignum_compare_unsigned(y, x))
|
||||||
: (bignum_comparison_less))
|
: (BIGNUM_COMPARISON_LESS))
|
||||||
: ((BIGNUM_NEGATIVE_P(y)) ? (bignum_comparison_greater)
|
: ((BIGNUM_NEGATIVE_P(y)) ? (BIGNUM_COMPARISON_GREATER)
|
||||||
: (bignum_compare_unsigned(x, y))));
|
: (bignum_compare_unsigned(x, y))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,17 +203,17 @@ void factor_vm::bignum_divide(bignum* numerator, bignum* denominator,
|
||||||
int q_negative_p =
|
int q_negative_p =
|
||||||
((BIGNUM_NEGATIVE_P(denominator)) ? (!r_negative_p) : r_negative_p);
|
((BIGNUM_NEGATIVE_P(denominator)) ? (!r_negative_p) : r_negative_p);
|
||||||
switch (bignum_compare_unsigned(numerator, denominator)) {
|
switch (bignum_compare_unsigned(numerator, denominator)) {
|
||||||
case bignum_comparison_equal: {
|
case BIGNUM_COMPARISON_EQUAL: {
|
||||||
(*quotient) = (BIGNUM_ONE(q_negative_p));
|
(*quotient) = (BIGNUM_ONE(q_negative_p));
|
||||||
(*remainder) = (BIGNUM_ZERO());
|
(*remainder) = (BIGNUM_ZERO());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case bignum_comparison_less: {
|
case BIGNUM_COMPARISON_LESS: {
|
||||||
(*quotient) = (BIGNUM_ZERO());
|
(*quotient) = (BIGNUM_ZERO());
|
||||||
(*remainder) = numerator;
|
(*remainder) = numerator;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case bignum_comparison_greater: {
|
case BIGNUM_COMPARISON_GREATER: {
|
||||||
if ((BIGNUM_LENGTH(denominator)) == 1) {
|
if ((BIGNUM_LENGTH(denominator)) == 1) {
|
||||||
bignum_digit_type digit = (BIGNUM_REF(denominator, 0));
|
bignum_digit_type digit = (BIGNUM_REF(denominator, 0));
|
||||||
if (digit == 1) {
|
if (digit == 1) {
|
||||||
|
@ -254,11 +254,11 @@ bignum* factor_vm::bignum_quotient(bignum* numerator, bignum* denominator) {
|
||||||
((BIGNUM_NEGATIVE_P(denominator)) ? (!(BIGNUM_NEGATIVE_P(numerator)))
|
((BIGNUM_NEGATIVE_P(denominator)) ? (!(BIGNUM_NEGATIVE_P(numerator)))
|
||||||
: (BIGNUM_NEGATIVE_P(numerator)));
|
: (BIGNUM_NEGATIVE_P(numerator)));
|
||||||
switch (bignum_compare_unsigned(numerator, denominator)) {
|
switch (bignum_compare_unsigned(numerator, denominator)) {
|
||||||
case bignum_comparison_equal:
|
case BIGNUM_COMPARISON_EQUAL:
|
||||||
return (BIGNUM_ONE(q_negative_p));
|
return (BIGNUM_ONE(q_negative_p));
|
||||||
case bignum_comparison_less:
|
case BIGNUM_COMPARISON_LESS:
|
||||||
return (BIGNUM_ZERO());
|
return (BIGNUM_ZERO());
|
||||||
case bignum_comparison_greater:
|
case BIGNUM_COMPARISON_GREATER:
|
||||||
default: // to appease gcc -Wall
|
default: // to appease gcc -Wall
|
||||||
{
|
{
|
||||||
bignum* quotient;
|
bignum* quotient;
|
||||||
|
@ -291,11 +291,11 @@ bignum* factor_vm::bignum_remainder(bignum* numerator, bignum* denominator) {
|
||||||
if (BIGNUM_ZERO_P(numerator))
|
if (BIGNUM_ZERO_P(numerator))
|
||||||
return numerator;
|
return numerator;
|
||||||
switch (bignum_compare_unsigned(numerator, denominator)) {
|
switch (bignum_compare_unsigned(numerator, denominator)) {
|
||||||
case bignum_comparison_equal:
|
case BIGNUM_COMPARISON_EQUAL:
|
||||||
return (BIGNUM_ZERO());
|
return (BIGNUM_ZERO());
|
||||||
case bignum_comparison_less:
|
case BIGNUM_COMPARISON_LESS:
|
||||||
return numerator;
|
return numerator;
|
||||||
case bignum_comparison_greater:
|
case BIGNUM_COMPARISON_GREATER:
|
||||||
default: // to appease gcc -Wall
|
default: // to appease gcc -Wall
|
||||||
{
|
{
|
||||||
bignum* remainder;
|
bignum* remainder;
|
||||||
|
@ -480,9 +480,9 @@ enum bignum_comparison factor_vm::bignum_compare_unsigned(bignum* x,
|
||||||
bignum_length_type x_length = (BIGNUM_LENGTH(x));
|
bignum_length_type x_length = (BIGNUM_LENGTH(x));
|
||||||
bignum_length_type y_length = (BIGNUM_LENGTH(y));
|
bignum_length_type y_length = (BIGNUM_LENGTH(y));
|
||||||
if (x_length < y_length)
|
if (x_length < y_length)
|
||||||
return (bignum_comparison_less);
|
return BIGNUM_COMPARISON_LESS;
|
||||||
if (x_length > y_length)
|
if (x_length > y_length)
|
||||||
return (bignum_comparison_greater);
|
return BIGNUM_COMPARISON_GREATER;
|
||||||
{
|
{
|
||||||
bignum_digit_type* start_x = (BIGNUM_START_PTR(x));
|
bignum_digit_type* start_x = (BIGNUM_START_PTR(x));
|
||||||
bignum_digit_type* scan_x = (start_x + x_length);
|
bignum_digit_type* scan_x = (start_x + x_length);
|
||||||
|
@ -491,12 +491,12 @@ enum bignum_comparison factor_vm::bignum_compare_unsigned(bignum* x,
|
||||||
bignum_digit_type digit_x = (*--scan_x);
|
bignum_digit_type digit_x = (*--scan_x);
|
||||||
bignum_digit_type digit_y = (*--scan_y);
|
bignum_digit_type digit_y = (*--scan_y);
|
||||||
if (digit_x < digit_y)
|
if (digit_x < digit_y)
|
||||||
return (bignum_comparison_less);
|
return BIGNUM_COMPARISON_LESS;
|
||||||
if (digit_x > digit_y)
|
if (digit_x > digit_y)
|
||||||
return (bignum_comparison_greater);
|
return BIGNUM_COMPARISON_GREATER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (bignum_comparison_equal);
|
return BIGNUM_COMPARISON_EQUAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Addition
|
// Addition
|
||||||
|
@ -565,13 +565,13 @@ bignum* factor_vm::bignum_subtract_unsigned(bignum* x_, bignum* y_) {
|
||||||
|
|
||||||
int negative_p = 0;
|
int negative_p = 0;
|
||||||
switch (bignum_compare_unsigned(x.untagged(), y.untagged())) {
|
switch (bignum_compare_unsigned(x.untagged(), y.untagged())) {
|
||||||
case bignum_comparison_equal:
|
case BIGNUM_COMPARISON_EQUAL:
|
||||||
return (BIGNUM_ZERO());
|
return (BIGNUM_ZERO());
|
||||||
case bignum_comparison_less:
|
case BIGNUM_COMPARISON_LESS:
|
||||||
swap(x, y);
|
swap(x, y);
|
||||||
negative_p = 1;
|
negative_p = 1;
|
||||||
break;
|
break;
|
||||||
case bignum_comparison_greater:
|
case BIGNUM_COMPARISON_GREATER:
|
||||||
negative_p = 0;
|
negative_p = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1748,7 +1748,7 @@ bignum* factor_vm::bignum_gcd(bignum* a_, bignum* b_) {
|
||||||
b = d;
|
b = d;
|
||||||
|
|
||||||
// Initial reduction: make sure that 0 <= b <= a.
|
// Initial reduction: make sure that 0 <= b <= a.
|
||||||
if (bignum_compare(a.untagged(), b.untagged()) == bignum_comparison_less) {
|
if (bignum_compare(a.untagged(), b.untagged()) == BIGNUM_COMPARISON_LESS) {
|
||||||
swap(a, b);
|
swap(a, b);
|
||||||
std::swap(size_a, size_b);
|
std::swap(size_a, size_b);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,9 +35,9 @@ namespace factor {
|
||||||
#define BIGNUM_OUT_OF_BAND ((bignum*)0)
|
#define BIGNUM_OUT_OF_BAND ((bignum*)0)
|
||||||
|
|
||||||
enum bignum_comparison {
|
enum bignum_comparison {
|
||||||
bignum_comparison_equal = 0,
|
BIGNUM_COMPARISON_EQUAL = 0,
|
||||||
bignum_comparison_less = -1,
|
BIGNUM_COMPARISON_LESS = -1,
|
||||||
bignum_comparison_greater = 1
|
BIGNUM_COMPARISON_GREATER = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
cell bignum_maybe_to_fixnum(bignum* bn);
|
cell bignum_maybe_to_fixnum(bignum* bn);
|
||||||
|
|
|
@ -6,18 +6,18 @@
|
||||||
namespace factor {
|
namespace factor {
|
||||||
|
|
||||||
enum generation {
|
enum generation {
|
||||||
nursery_generation,
|
NURSERY_GENERATION,
|
||||||
aging_generation,
|
AGING_GENERATION,
|
||||||
tenured_generation
|
TENURED_GENERATION
|
||||||
};
|
};
|
||||||
|
|
||||||
inline generation generation_of(factor_vm* parent, object* obj) {
|
inline generation generation_of(factor_vm* parent, object* obj) {
|
||||||
if (parent->data->nursery->contains_p(obj))
|
if (parent->data->nursery->contains_p(obj))
|
||||||
return nursery_generation;
|
return NURSERY_GENERATION;
|
||||||
else if (parent->data->aging->contains_p(obj))
|
else if (parent->data->aging->contains_p(obj))
|
||||||
return aging_generation;
|
return AGING_GENERATION;
|
||||||
else if (parent->data->tenured->contains_p(obj))
|
else if (parent->data->tenured->contains_p(obj))
|
||||||
return tenured_generation;
|
return TENURED_GENERATION;
|
||||||
else {
|
else {
|
||||||
critical_error("Bad object", (cell)obj);
|
critical_error("Bad object", (cell)obj);
|
||||||
return (generation)-1;
|
return (generation)-1;
|
||||||
|
@ -62,12 +62,12 @@ struct slot_checker {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
generation target = generation_of(parent, untag<object>(*slot_ptr));
|
generation target = generation_of(parent, untag<object>(*slot_ptr));
|
||||||
if (gen == aging_generation && target == nursery_generation) {
|
if (gen == AGING_GENERATION && target == NURSERY_GENERATION) {
|
||||||
check_write_barrier(slot_ptr, target, card_points_to_nursery);
|
check_write_barrier(slot_ptr, target, card_points_to_nursery);
|
||||||
} else if (gen == tenured_generation) {
|
} else if (gen == TENURED_GENERATION) {
|
||||||
if (target == nursery_generation) {
|
if (target == NURSERY_GENERATION) {
|
||||||
check_write_barrier(slot_ptr, target, card_points_to_nursery);
|
check_write_barrier(slot_ptr, target, card_points_to_nursery);
|
||||||
} else if (target == aging_generation) {
|
} else if (target == AGING_GENERATION) {
|
||||||
check_write_barrier(slot_ptr, target, card_points_to_aging);
|
check_write_barrier(slot_ptr, target, card_points_to_aging);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,22 +174,22 @@ void factor_vm::primitive_bignum_shift() {
|
||||||
|
|
||||||
void factor_vm::primitive_bignum_less() {
|
void factor_vm::primitive_bignum_less() {
|
||||||
POP_BIGNUMS(x, y);
|
POP_BIGNUMS(x, y);
|
||||||
ctx->replace(tag_boolean(bignum_compare(x, y) == bignum_comparison_less));
|
ctx->replace(tag_boolean(bignum_compare(x, y) == BIGNUM_COMPARISON_LESS));
|
||||||
}
|
}
|
||||||
|
|
||||||
void factor_vm::primitive_bignum_lesseq() {
|
void factor_vm::primitive_bignum_lesseq() {
|
||||||
POP_BIGNUMS(x, y);
|
POP_BIGNUMS(x, y);
|
||||||
ctx->replace(tag_boolean(bignum_compare(x, y) != bignum_comparison_greater));
|
ctx->replace(tag_boolean(bignum_compare(x, y) != BIGNUM_COMPARISON_GREATER));
|
||||||
}
|
}
|
||||||
|
|
||||||
void factor_vm::primitive_bignum_greater() {
|
void factor_vm::primitive_bignum_greater() {
|
||||||
POP_BIGNUMS(x, y);
|
POP_BIGNUMS(x, y);
|
||||||
ctx->replace(tag_boolean(bignum_compare(x, y) == bignum_comparison_greater));
|
ctx->replace(tag_boolean(bignum_compare(x, y) == BIGNUM_COMPARISON_GREATER));
|
||||||
}
|
}
|
||||||
|
|
||||||
void factor_vm::primitive_bignum_greatereq() {
|
void factor_vm::primitive_bignum_greatereq() {
|
||||||
POP_BIGNUMS(x, y);
|
POP_BIGNUMS(x, y);
|
||||||
ctx->replace(tag_boolean(bignum_compare(x, y) != bignum_comparison_less));
|
ctx->replace(tag_boolean(bignum_compare(x, y) != BIGNUM_COMPARISON_LESS));
|
||||||
}
|
}
|
||||||
|
|
||||||
void factor_vm::primitive_bignum_not() {
|
void factor_vm::primitive_bignum_not() {
|
||||||
|
|
Loading…
Reference in New Issue