home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 2 / AACD 2.iso / AACD / Programming / jikes-1.02 / src / long.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-08-20  |  5.1 KB  |  153 lines

  1. // $Id: long.h,v 1.5 1999/08/20 14:44:21 shields Exp $
  2. //
  3. // This software is subject to the terms of the IBM Jikes Compiler
  4. // License Agreement available at the following URL:
  5. // http://www.ibm.com/research/jikes.
  6. // Copyright (C) 1996, 1998, International Business Machines Corporation
  7. // and others.  All Rights Reserved.
  8. // You must accept the terms of that agreement to use this software.
  9. //
  10. #ifndef Long_INCLUDED
  11. #define Long_INCLUDED
  12.  
  13. #include "config.h"
  14. #include <math.h>
  15.  
  16. class IEEEdouble;
  17. class IEEEfloat;
  18.  
  19. class LongInt;
  20. class ULongInt;
  21.  
  22. class BaseLong
  23. {
  24. protected:
  25.     union
  26.     {
  27.         double double_words;
  28.         u4 word[2];
  29.     } value;
  30.  
  31. public:
  32.  
  33. #ifdef BIGENDIAN
  34.     u4 &HighWord() { return value.word[0]; }
  35.     u4 &LowWord()  { return value.word[1]; }
  36. #else
  37.     u4 &LowWord()  { return value.word[0]; }
  38.     u4 &HighWord() { return value.word[1]; }
  39. #endif
  40.  
  41.     double &DoubleView() { return value.double_words; }
  42.  
  43.     BaseLong(u4 a, u4 b);
  44.     BaseLong(u4 a);
  45.     BaseLong(i4 a);
  46.     inline BaseLong (void) {}
  47.  
  48.     BaseLong  operator+  (BaseLong); // binary addition
  49.     BaseLong  operator+  ();         // unary plus
  50.     BaseLong& operator+= (BaseLong); // add and assign
  51.     BaseLong  operator++ (int);      // postfix increment
  52.     BaseLong  operator++ ();         // prefix increment
  53.  
  54.     BaseLong  operator-  (BaseLong); // binary subtraction
  55.     BaseLong  operator-  ();         // unary minus
  56.     BaseLong& operator-= (BaseLong); // subtract and assign
  57.     BaseLong  operator-- (int);      // postfix decrement
  58.     BaseLong  operator-- ();         // prefix decrement
  59.  
  60.     BaseLong  operator* (BaseLong);  // multiplication
  61.     BaseLong& operator*=(BaseLong);  // multiply and assign
  62.  
  63.     BaseLong  operator<< (BaseLong); // left shift
  64.     BaseLong& operator<<=(BaseLong); // left shift and assign
  65.  
  66.     bool      operator== (BaseLong); // equal
  67.     bool      operator!= (BaseLong); // not equal
  68.     bool      operator!  ();         // logical complement
  69.  
  70.     BaseLong  operator~  ();         // bitwise complement
  71.     BaseLong  operator^  (BaseLong); // bitwise XOR
  72.     BaseLong& operator^= (BaseLong); // bitwise XOR and assign
  73.     BaseLong  operator|  (BaseLong); // bitwise OR
  74.     BaseLong& operator|= (BaseLong); // bitwise OR and assign
  75.     BaseLong  operator&  (BaseLong); // bitwise AND
  76.     BaseLong& operator&= (BaseLong); // bitwise AND and assign
  77.  
  78.     bool      operator&& (BaseLong); // logical AND (not short-circuit)
  79.     bool      operator|| (BaseLong); // logical OR (not short circuit)
  80.  
  81.     static void Divide(BaseLong, BaseLong, BaseLong &, BaseLong &);
  82.  
  83.     operator LongInt();                 // Cast to LongInt
  84.     operator ULongInt();                // Cast to ULongInt
  85. };
  86.  
  87.  
  88. class LongInt : public BaseLong
  89. {
  90. public:
  91.  
  92.     inline LongInt (u4 a, u4 b) : BaseLong (a, b) {}
  93.     inline LongInt (u4 a) : BaseLong (a) {}
  94.     inline LongInt (i4 a) : BaseLong (a) {}
  95.     inline LongInt (void) : BaseLong () {}
  96.     LongInt (IEEEdouble) ; //BaseLong (a) {};
  97.     LongInt (IEEEfloat) ; //BaseLong (a) {};
  98.  
  99.     LongInt  operator/  (LongInt); // divide
  100.     LongInt& operator/= (LongInt); // divide and assign
  101.  
  102.     LongInt  operator%  (LongInt); // modulus
  103.     LongInt& operator%= (LongInt); // modulus and assign
  104.  
  105.     LongInt  operator>> (LongInt); // right shift
  106.     LongInt& operator>>=(LongInt); // right shift and assign
  107.  
  108.     bool  operator<  (LongInt); // less-than
  109.     bool  operator>  (LongInt); // greater-than
  110.     bool  operator<= (LongInt); // less-than or equal
  111.     bool  operator>= (LongInt); // greater-than or equal
  112.  
  113.     double Double();           // convert ULongInt value to a double value
  114.  
  115.     void OctString(char *, bool = false); // convert LongInt value to its character string representation in octal format
  116.     void DecString(char *);               // convert LongInt value to its character string representation in decimal format
  117.     void HexString(char *, bool = false); // convert LongInt value to its character string representation in hexadecimal format
  118. };
  119.  
  120.  
  121. class ULongInt : public BaseLong
  122. {
  123. public:
  124.  
  125.     inline ULongInt (u4 a, u4 b) : BaseLong (a, b) {}
  126.     inline ULongInt (u4 a) : BaseLong (a) {}
  127.     inline ULongInt (i4 a) : BaseLong (a) {}
  128.     inline ULongInt (void) : BaseLong () {}
  129.  
  130.     ULongInt  operator/  (ULongInt); // divide
  131.     ULongInt& operator/= (ULongInt); // divide and assign
  132.  
  133.     ULongInt  operator%  (ULongInt); // modulus
  134.     ULongInt& operator%= (ULongInt); // modulus and assign
  135.  
  136.     ULongInt  operator>> (ULongInt); // right shift
  137.     ULongInt& operator>>=(ULongInt); // right shift and assign
  138.  
  139.     bool   operator<  (ULongInt); // less-than
  140.     bool   operator>  (ULongInt); // greater-than
  141.     bool   operator<= (ULongInt); // less-than or equal
  142.     bool   operator>= (ULongInt); // greater-than or equal
  143.  
  144.     double Double();      // convert LongInt value to a double value
  145.  
  146.     void OctString(char *, bool = false); // convert ULongInt value to its character string representation in octal format
  147.     void DecString(char *);               // convert ULongInt value to its character string representation in decimal format
  148.     void HexString(char *, bool = false); // convert ULongInt value to its character string representation in hexadecimal format
  149. };
  150.  
  151.  
  152. #endif
  153.