]> gitweb.factorcode.org Git - factor.git/commitdiff
VM: changing case of enums values bignum_comparison and generation
authorBjörn Lindqvist <bjourne@gmail.com>
Wed, 19 Oct 2016 06:57:33 +0000 (08:57 +0200)
committerBjörn Lindqvist <bjourne@gmail.com>
Wed, 19 Oct 2016 06:57:33 +0000 (08:57 +0200)
It is consistent if all enum values have all uppercase names.

vm/bignum.cpp
vm/bignum.hpp
vm/data_heap_checker.cpp
vm/math.cpp

index c8dd5eed021dc0367b5294503bd6d0b81594a33b..34b9705454fd5f7c5b055ebb154692e68f748fa9 100644 (file)
@@ -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) {
-  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_comparison_greater
-                                    : bignum_comparison_less)
+                                    ? BIGNUM_COMPARISON_GREATER
+                                    : BIGNUM_COMPARISON_LESS)
                              : (BIGNUM_ZERO_P(y))
-              ? ((BIGNUM_NEGATIVE_P(x)) ? bignum_comparison_less
-                                        : bignum_comparison_greater)
+              ? ((BIGNUM_NEGATIVE_P(x)) ? BIGNUM_COMPARISON_LESS
+                                        : BIGNUM_COMPARISON_GREATER)
               : (BIGNUM_NEGATIVE_P(x))
               ? ((BIGNUM_NEGATIVE_P(y)) ? (bignum_compare_unsigned(y, x))
-                                        : (bignum_comparison_less))
-              : ((BIGNUM_NEGATIVE_P(y)) ? (bignum_comparison_greater)
+                                        : (BIGNUM_COMPARISON_LESS))
+              : ((BIGNUM_NEGATIVE_P(y)) ? (BIGNUM_COMPARISON_GREATER)
                                         : (bignum_compare_unsigned(x, y))));
 }
 
@@ -203,17 +203,17 @@ void factor_vm::bignum_divide(bignum* numerator, bignum* denominator,
     int q_negative_p =
         ((BIGNUM_NEGATIVE_P(denominator)) ? (!r_negative_p) : r_negative_p);
     switch (bignum_compare_unsigned(numerator, denominator)) {
-      case bignum_comparison_equal: {
+      case BIGNUM_COMPARISON_EQUAL: {
         (*quotient) = (BIGNUM_ONE(q_negative_p));
         (*remainder) = (BIGNUM_ZERO());
         break;
       }
-      case bignum_comparison_less: {
+      case BIGNUM_COMPARISON_LESS: {
         (*quotient) = (BIGNUM_ZERO());
         (*remainder) = numerator;
         break;
       }
-      case bignum_comparison_greater: {
+      case BIGNUM_COMPARISON_GREATER: {
         if ((BIGNUM_LENGTH(denominator)) == 1) {
           bignum_digit_type digit = (BIGNUM_REF(denominator, 0));
           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(numerator)));
     switch (bignum_compare_unsigned(numerator, denominator)) {
-      case bignum_comparison_equal:
+      case BIGNUM_COMPARISON_EQUAL:
         return (BIGNUM_ONE(q_negative_p));
-      case bignum_comparison_less:
+      case BIGNUM_COMPARISON_LESS:
         return (BIGNUM_ZERO());
-      case bignum_comparison_greater:
+      case BIGNUM_COMPARISON_GREATER:
       default: // to appease gcc -Wall
                {
         bignum* quotient;
@@ -291,11 +291,11 @@ bignum* factor_vm::bignum_remainder(bignum* numerator, bignum* denominator) {
   if (BIGNUM_ZERO_P(numerator))
     return numerator;
   switch (bignum_compare_unsigned(numerator, denominator)) {
-    case bignum_comparison_equal:
+    case BIGNUM_COMPARISON_EQUAL:
       return (BIGNUM_ZERO());
-    case bignum_comparison_less:
+    case BIGNUM_COMPARISON_LESS:
       return numerator;
-    case bignum_comparison_greater:
+    case BIGNUM_COMPARISON_GREATER:
     default: // to appease gcc -Wall
              {
       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 y_length = (BIGNUM_LENGTH(y));
   if (x_length < y_length)
-    return (bignum_comparison_less);
+    return BIGNUM_COMPARISON_LESS;
   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* 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_y = (*--scan_y);
       if (digit_x < digit_y)
-        return (bignum_comparison_less);
+        return BIGNUM_COMPARISON_LESS;
       if (digit_x > digit_y)
-        return (bignum_comparison_greater);
+        return BIGNUM_COMPARISON_GREATER;
     }
   }
-  return (bignum_comparison_equal);
+  return BIGNUM_COMPARISON_EQUAL;
 }
 
 // Addition
@@ -565,13 +565,13 @@ bignum* factor_vm::bignum_subtract_unsigned(bignum* x_, bignum* y_) {
 
   int negative_p = 0;
   switch (bignum_compare_unsigned(x.untagged(), y.untagged())) {
-    case bignum_comparison_equal:
+    case BIGNUM_COMPARISON_EQUAL:
       return (BIGNUM_ZERO());
-    case bignum_comparison_less:
+    case BIGNUM_COMPARISON_LESS:
       swap(x, y);
       negative_p = 1;
       break;
-    case bignum_comparison_greater:
+    case BIGNUM_COMPARISON_GREATER:
       negative_p = 0;
       break;
   }
@@ -1748,7 +1748,7 @@ bignum* factor_vm::bignum_gcd(bignum* a_, bignum* b_) {
   b = d;
 
   // 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);
     std::swap(size_a, size_b);
   }
index 43b1ee0ed6bf10fb64c2654f903f9a9e986f6c6e..333eb618c69852bd47969c55d95068fedd2453ab 100644 (file)
@@ -35,9 +35,9 @@ namespace factor {
 #define BIGNUM_OUT_OF_BAND ((bignum*)0)
 
 enum bignum_comparison {
-  bignum_comparison_equal = 0,
-  bignum_comparison_less = -1,
-  bignum_comparison_greater = 1
+  BIGNUM_COMPARISON_EQUAL = 0,
+  BIGNUM_COMPARISON_LESS = -1,
+  BIGNUM_COMPARISON_GREATER = 1
 };
 
 cell bignum_maybe_to_fixnum(bignum* bn);
index 1b76c11798720c88c4d004e47ea279a41742d2e1..dc61e189cd99528e7fd0b42d45fdb66ed55f1604 100644 (file)
@@ -6,18 +6,18 @@
 namespace factor {
 
 enum generation {
-  nursery_generation,
-  aging_generation,
-  tenured_generation
+  NURSERY_GENERATION,
+  AGING_GENERATION,
+  TENURED_GENERATION
 };
 
 inline generation generation_of(factor_vm* parent, object* obj) {
   if (parent->data->nursery->contains_p(obj))
-    return nursery_generation;
+    return NURSERY_GENERATION;
   else if (parent->data->aging->contains_p(obj))
-    return aging_generation;
+    return AGING_GENERATION;
   else if (parent->data->tenured->contains_p(obj))
-    return tenured_generation;
+    return TENURED_GENERATION;
   else {
     critical_error("Bad object", (cell)obj);
     return (generation)-1;
@@ -62,12 +62,12 @@ struct slot_checker {
       return;
 
     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);
-    } else if (gen == tenured_generation) {
-      if (target == nursery_generation) {
+    } else if (gen == TENURED_GENERATION) {
+      if (target == NURSERY_GENERATION) {
         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);
       }
     }
index 98be48275bfcc32fb609c89ea98aa16b9da6a7c8..d78bf93c2ff1e681c2674facb343a9ca4fc0b25f 100644 (file)
@@ -174,22 +174,22 @@ void factor_vm::primitive_bignum_shift() {
 
 void factor_vm::primitive_bignum_less() {
   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() {
   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() {
   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() {
   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() {