IntegerClass.cpp
Go to the documentation of this file.
1 /*----------------------------------------------------------------------------*/
2 /* */
3 /* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */
4 /* Copyright (c) 2005-2009 Rexx Language Association. All rights reserved. */
5 /* */
6 /* This program and the accompanying materials are made available under */
7 /* the terms of the Common Public License v1.0 which accompanies this */
8 /* distribution. A copy is also available at the following address: */
9 /* http://www.oorexx.org/license.html */
10 /* */
11 /* Redistribution and use in source and binary forms, with or */
12 /* without modification, are permitted provided that the following */
13 /* conditions are met: */
14 /* */
15 /* Redistributions of source code must retain the above copyright */
16 /* notice, this list of conditions and the following disclaimer. */
17 /* Redistributions in binary form must reproduce the above copyright */
18 /* notice, this list of conditions and the following disclaimer in */
19 /* the documentation and/or other materials provided with the distribution. */
20 /* */
21 /* Neither the name of Rexx Language Association nor the names */
22 /* of its contributors may be used to endorse or promote products */
23 /* derived from this software without specific prior written permission. */
24 /* */
25 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
26 /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
27 /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
28 /* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
29 /* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
30 /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
31 /* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
32 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */
33 /* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
34 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
35 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
36 /* */
37 /*----------------------------------------------------------------------------*/
38 /******************************************************************************/
39 /* REXX Kernel IntegerClass.c */
40 /* */
41 /* Primitive Integer Class */
42 /* */
43 /******************************************************************************/
44 #include <ctype.h>
45 #include <string.h>
46 #include <stdlib.h>
47 #include <math.h>
48 #include "RexxCore.h"
49 #include "StringClass.hpp"
50 #include "ArrayClass.hpp"
51 #include "RexxActivation.hpp"
52 #include "RexxActivity.hpp"
53 #include "Numerics.hpp"
54 #include "RexxCompoundTail.hpp"
55 #include "DirectoryClass.hpp"
56 
57 
58 
59 // singleton class instance
61 
65 
77  /* define an operator forwarding */
78  /* method */
79 
80 #define string_forwarder_cpp(method)\
81 RexxObject *RexxInteger::##method(RexxObject *operand)\
82  {\
83  return (RexxObject *)this->string()->method(operand);\
84  }
85 
86 
87 /**
88  * Get the primitive hash value of this String object.
89  *
90  * @return The calculated string hash for the string.
91  */
93 {
94  return stringValue()->getHashValue();
95 }
96 
97 
98 void RexxInteger::live(size_t liveMark)
99 /******************************************************************************/
100 /* Function: Normal garbage collection live marking */
101 /******************************************************************************/
102 {
103  memory_mark(this->objectVariables);
104  memory_mark(this->stringrep);
105 }
106 
107 void RexxInteger::liveGeneral(int reason)
108 /******************************************************************************/
109 /* Function: Generalized object marking */
110 /******************************************************************************/
111 {
112  memory_mark_general(this->objectVariables);
114 }
115 
117 /******************************************************************************/
118 /* Function: Flatten an object */
119 /******************************************************************************/
120 {
122 
123  flatten_reference(newThis->objectVariables, envelope);
124  flatten_reference(newThis->stringrep, envelope);
125 
127 }
128 
130 /******************************************************************************/
131 /* Function: Handle a REQUEST('STRING') request for a REXX integer object */
132 /******************************************************************************/
133 {
134  return this->stringValue(); /* return the string value */
135 }
136 
137 
138 /**
139  * Override for the default object makearray method.
140  *
141  * @return The results of our string representation's makearray.
142  */
144 {
145  return this->stringValue()->makeArray(); // have the string value handle this
146 }
147 
149 /******************************************************************************/
150 /* Function: Handle a HASMETHOD request for an integer */
151 /******************************************************************************/
152 {
153  /* return the string value's answer */
154  return this->stringValue()->hasMethod(methodName);
155 }
156 
158 /******************************************************************************/
159 /* Function: Handle a REQUEST('STRING') request for a REXX integer object */
160 /******************************************************************************/
161 {
162  if (this->stringrep != OREF_NULL) /* have a string already? */
163  {
164  return this->stringrep; /* return it directly */
165  }
166  char stringBuffer[32]; /* integer formatting buffer */
167  /* convert value into string */
168  Numerics::formatWholeNumber(this->value, stringBuffer);
169 
170  /* return as a string */
171  RexxString *string = new_string(stringBuffer, strlen(stringBuffer));
172  /* cache this away for later */
173  OrefSet(this, this->stringrep, string);
174  this->setHasReferences(); // now have references that need marking
175  return string; /* return the new string */
176 }
177 
179 /******************************************************************************/
180 /* Function: Return the string value for an integer */
181 /******************************************************************************/
182 {
183  if (this->stringrep != OREF_NULL) /* have a string already? */
184  {
185  return this->stringrep; /* return it directly */
186  }
187 
188  char stringBuffer[32]; /* integer formatting buffer */
189  /* convert value into string */
190  Numerics::formatWholeNumber(this->value, stringBuffer);
191  /* return as a string */
192  RexxString *string = new_string(stringBuffer, strlen(stringBuffer));
193  /* cache this away for later */
194  OrefSet(this, this->stringrep, string);
195  this->setHasReferences(); /* we now have references */
196  return string; /* return the new string */
197 }
198 
200 /******************************************************************************/
201 /* Function: Copy the value of an integer into a compound variable name */
202 /******************************************************************************/
203 {
204  if (this->stringrep != OREF_NULL) /* have a string already? */
205  {
206  /* copying directly from an existing string rep is faster */
207  /* than formatting a new value and copying. */
209  return;
210  }
211  char stringBuffer[32]; /* integer formatting buffer */
212  /* convert value into string */
213  Numerics::formatWholeNumber(this->value, stringBuffer);
214  /* append this to the buffer */
215  tail->append(stringBuffer, strlen(stringBuffer));
216 }
217 
218 
220 /******************************************************************************/
221 /* Function: Convert an integer into a numberstring value */
222 /******************************************************************************/
223 {
224  if (this->stringrep != OREF_NULL) /* have a cached string value? */
225  {
226  /* use its numberstring value */
227  return this->stringrep->numberString();
228  }
229  else /* create a new numberstring */
230  {
232  }
233 }
234 
235 
236 /**
237  * Convert an integer object into a double value.
238  *
239  * @param value The returned value.
240  *
241  * @return true if this converted ok, false for any errors. This always
242  * returns true for the Integer class.
243  */
244 bool RexxInteger::doubleValue(double &result)
245 {
246  // just let the compiler convert
247  result = (double)this->wholeNumber();
248  return true;
249 }
250 
251 
252 /**
253  * Convert an integer object into a whole number value using the
254  * default digits setting.
255  *
256  * @param result The returned result.
257  *
258  * @return true if the number converts ok under the current digits setting. false
259  * for any conversion errors.
260  */
262 {
263  /* is the long value expressable as a*/
264  /* whole number in REXX term. */
266  {
267  return false; /* nope, not a valid long. */
268  }
269  result = value; // return the value
270  return true; // this was convertable
271 }
272 
273 
274 /**
275  * Convert an integer object into a whole number value using the
276  * current digits setting.
277  *
278  * @param result The returned result.
279  * @param digits The digits setting to apply to the conversion.
280  *
281  * @return true if the number converts ok under the current digits setting. false
282  * for any conversion errors.
283  */
284 bool RexxInteger::numberValue(wholenumber_t &result, size_t digits)
285 {
286  /* is the long value expressable as a*/
287  /* whole number in REXX term. */
289  {
290  return false; /* nope, not a valid long. */
291  }
292  result = value; // return the value
293  return true; // this was convertable
294 }
295 
296 
297 /**
298  * Convert an integer object into an unsigned whole number value
299  * using the default digits setting.
300  *
301  * @param result The returned result.
302  *
303  * @return true if the number converts ok under the current digits setting. false
304  * for any conversion errors.
305  */
307 {
308  // this must be non-negative and not out of range
309  if (value < 0 || value > Numerics::MAX_WHOLENUMBER)
310  {
311  return false;
312  }
313  result = wholeNumber(); // return the value
314  return true; // this was convertable
315 }
316 
317 
318 /**
319  * Convert an integer object into an unsigned whole number value
320  * using the current digits setting.
321  *
322  * @param result The returned result.
323  * @param digits The digits setting to apply to the conversion.
324  *
325  * @return true if the number converts ok under the current digits setting. false
326  * for any conversion errors.
327  */
328 bool RexxInteger::unsignedNumberValue(stringsize_t &result, size_t digits)
329 {
330  /* is the long value expressable as a*/
331  /* whole number in REXX term. */
332  if (value < 0 || (digits < Numerics::DEFAULT_DIGITS && value >= Numerics::validMaxWhole[digits - 1]))
333  {
334  return false; /* nope, not a valid long. */
335  }
336  result = wholeNumber(); // return the value
337  return true; // this was convertable
338 }
339 
341  size_t digits) /* required precision (ignored) */
342 /******************************************************************************/
343 /* Function: Convert an integer to an integer (real easy!) */
344 /******************************************************************************/
345 {
346  return this; /* just return directly */
347 }
348 
350  RexxString *string ) /* new string value */
351 /******************************************************************************/
352 /* Function: Add a string value to the string look-a-side. */
353 /******************************************************************************/
354 {
355  /* set the strign */
356  OrefSet(this, this->stringrep, string);
357  this->setHasReferences(); /* we now have references */
358 }
359 
361  int errorcode ) /* error to raise if not good */
362 /******************************************************************************/
363 /* Function: Determine the truth value of an integer object */
364 /******************************************************************************/
365 {
366  if (this->value == 0) /* have a zero? */
367  {
368  return false; /* this is false */
369  }
370  else if (this->value != 1) /* how about a one? */
371  {
372  reportException(errorcode, this);/* report the error */
373  }
374  return true; /* this is true */
375 }
376 
377 
378 /**
379  * Convert an object to a logical value without raising an
380  * error.
381  *
382  * @param result The converted value.
383  *
384  * @return true if this converted ok, false for an invalid logical.
385  */
387 {
388  if (this->value == 0) /* have a zero? */
389  {
390  result = false; // this is false and the conversion worked
391  return true;
392  }
393  else if (this->value == 1) /* how about a one? */
394  {
395  result = true; // this is true and the conversion worked
396  return true;
397  }
398  else
399  {
400  return false; // bad conversion
401  }
402 }
403 
404 /******************************************************************************/
405 /* Function: Macro to forward a method against the numberstring value of */
406 /* an integer object. */
407 /******************************************************************************/
408 
409 #define integer_forward(s,m,o) ((s)->numberString()->m(o))
410 
412  RexxString *msgname, /* unknown message name */
413  RexxArray *arguments, /* arguments to the unknown message */
414  RexxDirectory *named_arguments)
415 /******************************************************************************/
416 /* Function: Intercept unknown messages to an integer object and reissue */
417 /* them against the string value. */
418 /******************************************************************************/
419 {
420  /* just reissue this */
421  return this->stringValue()->sendMessage(msgname, arguments, named_arguments);
422 }
423 
424 
425 /**
426  * Wrapper around the compareTo() method that does string sort
427  * comparisons.
428  *
429  * @param other The other comparison object
430  *
431  * @return -1, 0, 1 depending on the comparison result.
432  */
434 {
435  // just send this as a message directly to the string object.
436  return stringValue()->compareTo(other);
437 }
438 
439 
440 /**
441  * Override for the normal isinstanceof method. This version
442  * allows the IntegerClass to "lie" about being a string.
443  *
444  * @param other The comparison class
445  *
446  * @return True if the string value is an instance of the target class.
447  */
449 {
450  return stringValue()->isInstanceOf(other);
451 }
452 
453 
454 /**
455  * Retrieve the method instance for an object's defined method.
456  *
457  * @param method_name
458  * The method name.
459  *
460  * @return The method object that implements the object method.
461  */
463 {
464  return stringValue()->instanceMethod(method_name);
465 }
466 
467 
468 /**
469  * Return a supplier containing the methods implemented by an
470  * object. Depending on the argument, this is either A) all of
471  * the methods, B) just the explicitly set instance methods, or
472  * C) the methods provided by a given class.
473  *
474  * @param class_object
475  * The target class object (optional).
476  *
477  * @return A supplier with the appropriate method set.
478  */
480 {
481  return stringValue()->instanceMethods(class_object);
482 }
483 
484 
486  RexxString *other ) /* other object for concatenation */
487 /******************************************************************************/
488 /* Function: Concatenate an object to an integer */
489 /******************************************************************************/
490 {
491  // JLF same as RexxNumberString, give a chance for an alternative operator
492  return this->stringValue()->concatBlank(other);
493 
494  requiredArgument(other, OREF_positional, ARG_ONE); /* this is required */
495  other = REQUEST_STRING(other); /* ensure a string value */
496  ProtectedObject p(other);
497  /* do the concatenate */
498  return this->stringValue()->concatWith(other, ' ');
499 }
500 
502  RexxString *other ) /* other object for concatenation */
503 /******************************************************************************/
504 /* Function: Concatenate an object to an integer */
505 /******************************************************************************/
506 {
507  // JLF same as RexxNumberString, give a chance for an alternative operator
508  return this->stringValue()->concatRexx(other);
509 
510  requiredArgument(other, OREF_positional, ARG_ONE); /* this is required */
511  other = REQUEST_STRING(other); /* ensure a string value */
512  ProtectedObject p(other);
513  /* do the concatenate */
514  return this->stringValue()->concat(other);
515 }
516 
518  RexxInteger *other) /* target other object */
519 /******************************************************************************/
520 /* Function: Add an integer to another object */
521 /******************************************************************************/
522 {
523  /* are we using default digits? */
525  /* nope, we can't do integer arith */
526  return integer_forward(this, plus, other);
527  if (other == OREF_NULL) /* unary */
528  return this; /* just return ourselves */
529  else { /* binary */
530  if (isOfClass(Integer, other)) { /* adding two integers together? */
531  /* add the numbers */
532  wholenumber_t tempVal = this->value + other->value;
533  /* result still within range? */
534  if (tempVal <= Numerics::MAX_WHOLENUMBER && tempVal >= Numerics::MIN_WHOLENUMBER)
535  return new_integer(tempVal); /* return as an integer number */
536  }
537  /* need to do full arithmetic */
538  return integer_forward(this, plus, other);
539  }
540 }
541 
543  RexxInteger *other) /* target other object */
544 /******************************************************************************/
545 /* Function: Subtract another object from an integer */
546 /******************************************************************************/
547 {
548  /* are we using default digits? */
550  /* nope, then we can do integer arith*/
551  return integer_forward(this, minus, other);
552 
553  if (other == OREF_NULL) { /* unary subtraction operator */
554  return new_integer(-this->value); /* and return a new integer */
555  }
556  else { /* binary subtraction operation */
557  if (isOfClass(Integer, other)) { /* subtracting two integers? */
558  /* subtract the numbers */
559  wholenumber_t tempVal = this->value - other->value;
560  /* result still within range? */
561  if (tempVal <= Numerics::MAX_WHOLENUMBER && tempVal >= Numerics::MIN_WHOLENUMBER)
562  return new_integer(tempVal); /* return as an integer number */
563  }
564  /* need to do full arithmetic */
565  return integer_forward(this, minus, other);
566  }
567 }
568 
570  RexxInteger *other) /* target other object */
571 /******************************************************************************/
572 /* Function: Multiply an integer by another object */
573 /******************************************************************************/
574 {
575  /* are we using default digits? */
577  /* nope, we can't do integer math */
578  return integer_forward(this, multiply, other);
579  requiredArgument(other, OREF_positional, ARG_ONE); /* make sure the argument is there */
580  /* is the other an integer and will */
581  /* the result be in a good range? */
582  if (isOfClass(Integer, other) && Numerics::abs(this->value) <= 99999 && Numerics::abs(other->value) <= 9999)
583  {
584  /* multiply directly */
585  return new_integer(this->value * other->value);
586  }
587  else /* do the slow way */
588  return integer_forward(this, multiply, other);
589 }
590 
592  RexxInteger *other) /* target other object */
593 /******************************************************************************/
594 /* Function: Perform division (actually done as numberstring math) */
595 /******************************************************************************/
596 {
597  /* just forward this */
598  return integer_forward(this, divide, other);
599 }
600 
602  RexxInteger *other) /* target other object */
603 /******************************************************************************/
604 /* Function: Perform integer division */
605 /******************************************************************************/
606 {
607  /* are we using default digits? */
609  /* nope, we can't do integer arith */
610  return integer_forward(this, integerDivide, other);
611  requiredArgument(other, OREF_positional, ARG_ONE); /* make sure this is really there */
612 
613  if (isOfClass(Integer, other)) { /* is right object an integer? */
614  /* is right number 0? */
615  if (other->value != 0)
616  {
617  // do the division directly
618  return new_integer(this->value / other->value);
619  }
620  else /* yes, raise error. */
622  }
623  /* not integer, forward to */
624  /*numberstring. */
625  return integer_forward(this, integerDivide, other);
626 }
627 
629  RexxInteger *other) /* target other object */
630 /******************************************************************************/
631 /* Function: Perform remainder division */
632 /******************************************************************************/
633 {
634  /* are we using default digits? */
636  /* nope, we can't do integer arith */
637  return integer_forward(this, remainder, other);
638  requiredArgument(other, OREF_positional, ARG_ONE); /* make sure this is really there */
639 
640  if (isOfClass(Integer, other)) { /* is right object an integer? */
641  /* is right number 0? */
642  if (other->value != 0)
643  {
644  // we can do this directly
645  return new_integer(this->value % other->value);
646  }
647  else /* yes, raise error. */
649  }
650  /* not integer, forward to */
651  /*numberstring. */
652  return integer_forward(this, remainder, other);
653 }
654 
656  RexxObject *other) /* power exponent value */
657 /******************************************************************************/
658 /* Function: Process integer power operator (actually just a forwarder) */
659 /******************************************************************************/
660 {
661  /* just send along */
662  return integer_forward(this, power, other);
663 }
664 
666  RexxObject *other) /* other comparison object */
667 /******************************************************************************/
668 /* Function: Primitive strict equal\not equal method. This determines */
669 /* only strict equality, not greater or less than values. */
670 /******************************************************************************/
671 {
672  if (this->isSubClassOrEnhanced()) /* not a primitive? */
673  {
674  /* do the full lookup compare */
675  RexxObject *result = this->sendMessage(OREF_STRICT_EQUAL, other);
676  if (result == OREF_NULL)
677  {
679  }
680  return result->truthValue(Error_Logical_value_method);
681  }
682 
683  if (isOfClass(Integer, other)) /* two integers? */
684  /* just directly compare the values */
685  return this->value == ((RexxInteger *)other)->value;
686  /* go do a string compare */
687  return this->stringValue()->isEqual(other);
688 }
689 
691  RexxObject *other, RexxString *alternativeOperator, RexxInteger **alternativeOperatorResultPtr) /* other comparison value */
692 /******************************************************************************/
693 /* Function: Compare the two values. */
694 /* */
695 /* Returned: return <0 if other is greater than this */
696 /* return 0 if this equals other */
697 /* return >0 if this is greater than other */
698 /******************************************************************************/
699 {
700  requiredArgument(other, OREF_positional, ARG_ONE); /* make sure this is really there */
701  if (isOfClass(Integer, other)) /* string compare is simple */
702  /* just return their difference */
703  return this->value - ((RexxInteger *)other)->value;
704  else /* go do a string compare */
705  return this->stringValue()->strictComp(/*(RexxString *)*/other, alternativeOperator, alternativeOperatorResultPtr);
706 }
707 
708 
709 /**
710  * Do a comparison operation between an Integer object and
711  * another object.
712  *
713  * @param other The other object.
714  *
715  * @return true if the two objects compare equal, false for an
716  * unequal result.
717  */
718 wholenumber_t RexxInteger::comp(RexxObject *other, RexxString *alternativeOperator, RexxInteger **alternativeOperatorResultPtr)
719 {
720  requiredArgument(other, OREF_positional, ARG_ONE); /* make sure this is really there */
721  /* able to compare here? */
722  if (this->isSameType(other) && number_digits() == Numerics::DEFAULT_DIGITS)
723  {
724  /* just return the difference */
725  return this->value - ((RexxInteger *)other)->value;
726  }
727  else /* do a numberstring compare */
728  {
729  return this->numberString()->comp(other, alternativeOperator, alternativeOperatorResultPtr);
730  }
731 }
732 
733 
734 /**
735  * Exported version of the HASHCODE method for retrieving the
736  * object's hash.
737  *
738  * @return A string version of the hash (generally holds binary characters).
739  */
741 {
742  // get the hash value, which is actually derived from the integer string value
743  HashCode hashVal = this->hash();
744  return new_string((char *)&hashVal, sizeof(HashCode));
745 }
746 
747 
749  RexxObject *other) /* other comparison value */
750 /******************************************************************************/
751 /* Function: Perform the primitive level "==" compare, including the hash */
752 /* value processing. */
753 /******************************************************************************/
754 {
755  if (other == TheNilObject) // all conditionals return .false when compared to .nil
756  {
757  return TheFalseObject;
758  }
759  // return this->strictComp(other) == 0 ? TheTrueObject : TheFalseObject;
760  RexxInteger *alternativeResult = OREF_NULL;
761  wholenumber_t result = this->strictComp(other, OREF_STRICT_EQUAL_RIGHT, &alternativeResult);
762  if (alternativeResult != OREF_NULL) return alternativeResult;
763  return (result == 0) ? TheTrueObject : TheFalseObject;
764 }
765 
766 
768  RexxObject *other) /* other comparison value */
769 /******************************************************************************/
770 /* Function: Strict inequality operation */
771 /******************************************************************************/
772 {
773  if (other == TheNilObject) // all conditionals return .false when compared to .nil
774  {
775  return TheTrueObject;
776  }
777  /* return strict compare result */
778  // return (this->strictComp(other) != 0) ? TheTrueObject : TheFalseObject;
779  RexxInteger *alternativeResult = OREF_NULL;
780  wholenumber_t result = this->strictComp(other, OREF_STRICT_BACKSLASH_EQUAL_RIGHT, &alternativeResult);
781  if (alternativeResult != OREF_NULL) return alternativeResult;
782  return (result != 0) ? TheTrueObject : TheFalseObject;
783 }
784 
786  RexxObject *other) /* other comparison value */
787 /******************************************************************************/
788 /* Function: non-strict "=" operator */
789 /******************************************************************************/
790 {
791  if (other == TheNilObject) // all conditionals return .false when compared to .nil
792  {
793  return TheFalseObject;
794  }
795  // return this->comp(other) == 0 ? TheTrueObject : TheFalseObject;
796  RexxInteger *alternativeResult = OREF_NULL;
797  wholenumber_t result = this->comp(other, OREF_EQUAL_RIGHT, &alternativeResult);
798  if (alternativeResult != OREF_NULL) return alternativeResult;
799  return (result == 0) ? TheTrueObject : TheFalseObject;
800 }
801 
803  RexxObject *other) /* other comparison value */
804 /******************************************************************************/
805 /* Function: non-strict "\=" operator */
806 /******************************************************************************/
807 {
808  if (other == TheNilObject) // all conditionals return .false when compared to .nil
809  {
810  return TheTrueObject;
811  }
812  // return this->comp(other) != 0 ? TheTrueObject : TheFalseObject;
813  RexxInteger *alternativeResult = OREF_NULL;
814  wholenumber_t result = this->comp(other, OREF_BACKSLASH_EQUAL_RIGHT, &alternativeResult);
815  if (alternativeResult != OREF_NULL) return alternativeResult;
816  return (result != 0) ? TheTrueObject : TheFalseObject;
817 }
818 
820  RexxObject *other) /* other comparison value */
821 /******************************************************************************/
822 /* Function: non-strict ">" operator */
823 /******************************************************************************/
824 {
825  if (other == TheNilObject) // all conditionals return .false when compared to .nil
826  {
827  return TheFalseObject;
828  }
829  // return this->comp(other) > 0 ? TheTrueObject : TheFalseObject;
830  RexxInteger *alternativeResult = OREF_NULL;
831  wholenumber_t result = this->comp(other, OREF_GREATERTHAN_RIGHT, &alternativeResult);
832  if (alternativeResult != OREF_NULL) return alternativeResult;
833  return (result > 0) ? TheTrueObject : TheFalseObject;
834 }
835 
837  RexxObject *other) /* other comparison value */
838 /******************************************************************************/
839 /* Function: non-strict "<" operator */
840 /******************************************************************************/
841 {
842  if (other == TheNilObject) // all conditionals return .false when compared to .nil
843  {
844  return TheFalseObject;
845  }
846  // return this->comp(other) < 0 ? TheTrueObject : TheFalseObject;
847  RexxInteger *alternativeResult = OREF_NULL;
848  wholenumber_t result = this->comp(other, OREF_LESSTHAN_RIGHT, &alternativeResult);
849  if (alternativeResult != OREF_NULL) return alternativeResult;
850  return (result < 0) ? TheTrueObject : TheFalseObject;
851 }
852 
854  RexxObject *other) /* other comparison value */
855 /******************************************************************************/
856 /* Function: non-strict ">=" operator */
857 /******************************************************************************/
858 {
859  if (other == TheNilObject) // all conditionals return .false when compared to .nil
860  {
861  return TheFalseObject;
862  }
863  // return this->comp(other) >= 0 ? TheTrueObject : TheFalseObject;
864  RexxInteger *alternativeResult = OREF_NULL;
865  wholenumber_t result = this->comp(other, OREF_GREATERTHAN_EQUAL_RIGHT, &alternativeResult);
866  if (alternativeResult != OREF_NULL) return alternativeResult;
867  return (result >= 0) ? TheTrueObject : TheFalseObject;
868 }
869 
871  RexxObject *other) /* other comparison value */
872 /******************************************************************************/
873 /* Function: non-strict "<=" operator */
874 /******************************************************************************/
875 {
876  if (other == TheNilObject) // all conditionals return .false when compared to .nil
877  {
878  return TheFalseObject;
879  }
880  // return this->comp(other) <= 0 ? TheTrueObject : TheFalseObject;
881  RexxInteger *alternativeResult = OREF_NULL;
882  wholenumber_t result = this->comp(other, OREF_LESSTHAN_EQUAL_RIGHT, &alternativeResult);
883  if (alternativeResult != OREF_NULL) return alternativeResult;
884  return (result <= 0) ? TheTrueObject : TheFalseObject;
885 }
886 
887 
889  RexxObject *other) /* other comparison value */
890 /******************************************************************************/
891 /* Function: strict ">>" operator */
892 /******************************************************************************/
893 {
894  if (other == TheNilObject) // all conditionals return .false when compared to .nil
895  {
896  return TheFalseObject;
897  }
898  // return this->strictComp(other) > 0 ? TheTrueObject : TheFalseObject;
899  RexxInteger *alternativeResult = OREF_NULL;
900  wholenumber_t result = this->strictComp(other, OREF_STRICT_GREATERTHAN_RIGHT, &alternativeResult);
901  if (alternativeResult != OREF_NULL) return alternativeResult;
902  return (result > 0) ? TheTrueObject : TheFalseObject;
903 }
904 
906  RexxObject *other) /* other comparison value */
907 /******************************************************************************/
908 /* Function: strict "<<" operator */
909 /******************************************************************************/
910 {
911  if (other == TheNilObject) // all conditionals return .false when compared to .nil
912  {
913  return TheFalseObject;
914  }
915  // return this->strictComp(other) < 0 ? TheTrueObject : TheFalseObject;
916  RexxInteger *alternativeResult = OREF_NULL;
917  wholenumber_t result = this->strictComp(other, OREF_STRICT_LESSTHAN_RIGHT, &alternativeResult);
918  if (alternativeResult != OREF_NULL) return alternativeResult;
919  return (result < 0) ? TheTrueObject : TheFalseObject;
920 }
921 
923  RexxObject *other) /* other comparison value */
924 /******************************************************************************/
925 /* Function: strict ">>=" operator */
926 /******************************************************************************/
927 {
928  if (other == TheNilObject) // all conditionals return .false when compared to .nil
929  {
930  return TheFalseObject;
931  }
932  // return this->strictComp(other) >= 0 ? TheTrueObject : TheFalseObject;
933  RexxInteger *alternativeResult = OREF_NULL;
934  wholenumber_t result = this->strictComp(other, OREF_STRICT_GREATERTHAN_EQUAL_RIGHT, &alternativeResult);
935  if (alternativeResult != OREF_NULL) return alternativeResult;
936  return (result >= 0) ? TheTrueObject : TheFalseObject;
937 }
938 
940  RexxObject *other) /* other comparison value */
941 /******************************************************************************/
942 /* Function: strict "<<=" operator */
943 /******************************************************************************/
944 {
945  if (other == TheNilObject) // all conditionals return .false when compared to .nil
946  {
947  return TheFalseObject;
948  }
949  // return this->strictComp(other) <= 0 ? TheTrueObject : TheFalseObject;
950  RexxInteger *alternativeResult = OREF_NULL;
951  wholenumber_t result = this->strictComp(other, OREF_STRICT_LESSTHAN_EQUAL_RIGHT, &alternativeResult);
952  if (alternativeResult != OREF_NULL) return alternativeResult;
953  return (result <= 0) ? TheTrueObject : TheFalseObject;
954 }
955 
957 /******************************************************************************/
958 /* Function: Perform the logical not of an integer object */
959 /******************************************************************************/
960 {
961  /* perform the operation */
963 }
964 
966  RexxObject *dummy ) /* dummy for polymorphic operators */
967 /******************************************************************************/
968 /* Function: Perform the logical not of an integer object */
969 /******************************************************************************/
970 {
971  /* perform the operation */
973 }
974 
976  RexxObject *other) /* other logical value */
977 /******************************************************************************/
978 /* Function: Logically AND two objects together */
979 /******************************************************************************/
980 {
981  RexxObject *otherTruth; /* truth value of the other object */
982 
983  requiredArgument(other, OREF_positional, ARG_ONE); /* make sure the argument is there */
984 
985  // Before doing a logical value operation, try the alternative operator, if any.
986  // Do that only if 'other' is not a string and not a number and not an integer (no performance degradation)
987  if (!isPolymorphicString(other))
988  {
989  // Try an alternative operator
990  ProtectedObject result;
991  RexxObject *args[1];
992  args[0] = this; // positional argument
993  bool alternativeResult = other->messageSend(OREF_AND_RIGHT, args, 1, 0, result, false);
994  if (alternativeResult && (RexxObject *)result != OREF_NULL) return (RexxObject *)result;
995  }
996 
997  /* validate the boolean */
999  /* perform the operation */
1000  return (!this->truthValue(Error_Logical_value_method)) ? TheFalseObject : otherTruth;
1001 }
1002 
1004  RexxObject *other) /* other logical value */
1005 /******************************************************************************/
1006 /* Function: Logically OR two objects together */
1007 /******************************************************************************/
1008 {
1009  RexxObject *otherTruth; /* truth value of the other object */
1010 
1011  requiredArgument(other, OREF_positional, ARG_ONE); /* make sure the argument is there */
1012 
1013  // Before doing a logical value operation, try the alternative operator, if any.
1014  // Do that only if 'other' is not a string and not a number and not an integer (no performance degradation)
1015  if (!isPolymorphicString(other))
1016  {
1017  // Try an alternative operator
1018  ProtectedObject result;
1019  RexxObject *args[1];
1020  args[0] = this; // positional argument
1021  bool alternativeResult = other->messageSend(OREF_OR_RIGHT, args, 1, 0, result, false);
1022  if (alternativeResult && (RexxObject *)result != OREF_NULL) return (RexxObject *)result;
1023  }
1024 
1025  /* validate the boolean */
1027  /* perform the operation */
1028  return (this->truthValue(Error_Logical_value_method)) ? TheTrueObject : otherTruth;
1029 }
1030 
1032  RexxObject *other) /* other logical value */
1033 /******************************************************************************/
1034 /* Function: Logically XOR two objects together */
1035 /******************************************************************************/
1036 {
1037  requiredArgument(other, OREF_positional, ARG_ONE); /* make sure the argument is there */
1038 
1039  // Before doing a logical value operation, try the alternative operator, if any.
1040  // Do that only if 'other' is not a string and not a number and not an integer (no performance degradation)
1041  if (!isPolymorphicString(other))
1042  {
1043  // Try an alternative operator
1044  ProtectedObject result;
1045  RexxObject *args[1];
1046  args[0] = this; // positional argument
1047  bool alternativeResult = other->messageSend(OREF_XOR_RIGHT, args, 1, 0, result, false);
1048  if (alternativeResult && (RexxObject *)result != OREF_NULL) return (RexxObject *)result;
1049  }
1050 
1051  /* get as a boolean */
1052  bool truth = other->truthValue(Error_Logical_value_method);
1053  /* first one false? */
1055  /* value is always the second */
1056  return truth ? TheTrueObject : TheFalseObject;
1057  else /* value is inverse of second */
1058  return (truth) ? TheFalseObject : TheTrueObject;
1059 }
1060 
1062 /******************************************************************************/
1063 /* Function: Take the absolute value of an integer object */
1064 /******************************************************************************/
1065 {
1066  /* working under the default digits? */
1068  /* if we're already positive, this is a quick return */
1069  if (value >= 0) {
1070  return this;
1071  }
1072  return new_integer(-value); /* return as an integer object */
1073  }
1074  else
1075  return this->numberString()->abs(); /* do a numberstring operation */
1076 }
1077 
1079 /******************************************************************************/
1080 /* Function: SIGN() function on an integer object */
1081 /******************************************************************************/
1082 {
1083  RexxObject *result; /* returned result */
1084 
1085  if (this->value > 0) /* positive number? */
1086  result = IntegerOne; /* result is "1" */
1087  else if (this->value < 0) /* negative number? */
1088  result = new_integer(-1); /* result is "-1" */
1089  else
1090  result = IntegerZero; /* exactly zero */
1091  return result; /* return the value */
1092 }
1093 
1095  RexxObject **args, /* array of comparison values */
1096  size_t argCount, /* count of arguments */
1097  size_t named_argCount)
1098 /******************************************************************************/
1099 /* Function: Perform MAX function on integer objects */
1100 /******************************************************************************/
1101 {
1102  wholenumber_t maxvalue; /* current maximum */
1103  size_t arg; /* current arg position */
1104  RexxObject * argument; /* current argument object */
1105 
1106 
1107  /* are we using default digits? */
1109  /* nope, we can't do integer max. */
1110  return this->numberString()->Max(args, argCount, named_argCount);
1111 
1112  if (argCount < 1) /* no comparisons to do? */
1113  return (RexxObject *)this; /* just return this as the result */
1114 
1115  maxvalue = this->value; /* assume first number is our max. */
1116 
1117  /* check each numbers to see if */
1118  /* larger than the max. */
1119  for (arg = 0; arg < argCount; arg++) {
1120  argument = args[arg]; /* get next argument element */
1121 
1122  if (argument == OREF_NULL) /* was argument missging ? */
1123  /* Yes, report the error. */
1124  reportException(Error_Incorrect_method_noarg, OREF_positional, arg);
1125 
1126  if (isOfClass(Integer, argument)) { /* is this an INTEGER object? */
1127  /* yes, gets its value. */
1128  wholenumber_t v = ((RexxInteger *)argument)->getValue();
1129  if (v > maxvalue) /* is this number larger than max? */
1130  maxvalue = v; /* yes, it is our new max. */
1131  }
1132  else { /* not an integer, compare isn't */
1133  /* not all integers, convert into a */
1134  /* NumberString, and let NumberString*/
1135  /* figure this out. */
1136  return this->numberString()->Max(args, argCount, named_argCount);
1137  }
1138  }
1139 
1140  return new_integer(maxvalue); /* yes, then max is our max number */
1141 }
1142 
1144  RexxObject **args, /* array of comparison values */
1145  size_t argCount, /* count of arguments */
1146  size_t named_argCount)
1147 /******************************************************************************/
1148 /* Function: Perform MAX function on integer objects */
1149 /******************************************************************************/
1150 {
1151  wholenumber_t minvalue; /* current minimum */
1152  size_t arg; /* current arg position */
1153  RexxObject * argument; /* current argument object */
1154 
1155  /* are we using default digits? */
1157  /* nope, we can't do integer max. */
1158  return this->numberString()->Min(args, argCount, named_argCount);
1159 
1160  if (argCount < 1) /* no comparisons to do? */
1161  return (RexxObject *)this; /* just return this as the result */
1162 
1163  minvalue = this->value; /* assume first number is our min. */
1164 
1165  /* check each numbers to see if */
1166  /* larger than the max. */
1167  for (arg = 0; arg < argCount; arg++) {
1168  argument = args[arg]; /* get next argument element */
1169 
1170  if (argument == OREF_NULL) /* was argument missging ? */
1171  /* Yes, report the error. */
1172  reportException(Error_Incorrect_method_noarg, OREF_positional, arg);
1173 
1174  if (isOfClass(Integer, argument)) { /* is this an INTEGER object? */
1175  /* yes, gets its value. */
1176  wholenumber_t v = ((RexxInteger *)argument)->getValue();
1177  if (v < minvalue) /* is this number larger than min? */
1178  minvalue = v; /* yes, it is our new max. */
1179  }
1180  else { /* not an integer, compare isn't */
1181  /* not all integers, convert into a */
1182  /* NumberString, and let NumberString*/
1183  /* figure this out. */
1184  return this->numberString()->Min(args, argCount, named_argCount);
1185  }
1186  }
1187 
1188  return new_integer(minvalue); /* yes, then max is our max number */
1189 }
1190 
1192  RexxObject *decimals) /* number of decimal digits requested*/
1193 /******************************************************************************/
1194 /* Function: Act as a front end for the actual TRUNC REXX method */
1195 /******************************************************************************/
1196 {
1197  /* just forward to numberstring */
1198  return this->numberString()->trunc(decimals);
1199 }
1200 
1201 /**
1202  * Calculate the floor value for a numeric value
1203  *
1204  * @return The floor value.
1205  */
1207 {
1208  // the floor of an integer is always the same value
1209  return this;
1210 }
1211 
1212 /**
1213  * Calculate the ceiling value for a numeric value
1214  *
1215  * @return The ceiling value.
1216  */
1218 {
1219  // the ceiling of an integer is always the same value
1220  return this;
1221 }
1222 
1223 /**
1224  * Calculate the round value for a numeric value
1225  *
1226  * @return The round value.
1227  */
1229 {
1230  // the rounding of an integer is always the same value
1231  return this;
1232 }
1233 
1235  RexxObject *Integers, /* space for integer part */
1236  RexxObject *Decimals, /* number of decimals required */
1237  RexxObject *MathExp, /* the exponent size */
1238  RexxObject *ExpTrigger ) /* the exponent trigger */
1239 /******************************************************************************/
1240 /* Function: Act as a front end for the actual FORMAT REXX method */
1241 /******************************************************************************/
1242 {
1243  return this->numberString()->formatRexx(Integers, Decimals, MathExp, ExpTrigger);
1244 }
1245 
1247  RexxObject *length) /* length of result */
1248 /******************************************************************************/
1249 /* Function: Convert a decimal number string into a character string */
1250 /******************************************************************************/
1251 {
1252  /* format as a string value */
1253  return this->numberString()->d2xD2c(length, true);
1254 }
1255 
1257  RexxObject *length) /* length of result */
1258 /******************************************************************************/
1259 /* Function: Convert a decimal number string into a hexadecimal string */
1260 /******************************************************************************/
1261 {
1262  /* format as a string value */
1263  return this->numberString()->d2xD2c(length, false);
1264 }
1265 
1267  RexxActivation *context, /* current activation context */
1268  RexxExpressionStack *stack ) /* evaluation stack */
1269 /******************************************************************************/
1270 /* Function: Polymorphic method that makes integer a polymorphic expression */
1271 /* term for literals */
1272 /******************************************************************************/
1273 {
1274  stack->push(this); /* place on the evaluation stack */
1275  /* trace if necessary */
1276  context->traceIntermediate(this, TRACE_PREFIX_LITERAL);
1277  return this; /* also return the result */
1278 }
1279 
1280 
1282  RexxActivation *context) /* current activation context */
1283 /******************************************************************************/
1284 /* Function: Polymorphic get_value function used with expression terms */
1285 /******************************************************************************/
1286 {
1287  return (RexxObject *)this; /* just return this value */
1288 }
1289 
1290 
1292  RexxVariableDictionary *context) /* current activation context */
1293 /******************************************************************************/
1294 /* Function: Polymorphic get_value function used with expression terms */
1295 /******************************************************************************/
1296 {
1297  return (RexxObject *)this; /* just return this value */
1298 }
1299 
1300 
1302  RexxActivation *context) /* current activation context */
1303 /******************************************************************************/
1304 /* Function: Polymorphic get_value function used with expression terms */
1305 /******************************************************************************/
1306 {
1307  return (RexxObject *)this; /* just return this value */
1308 }
1309 
1310 
1312  RexxVariableDictionary *context) /* current activation context */
1313 /******************************************************************************/
1314 /* Function: Polymorphic get_value function used with expression terms */
1315 /******************************************************************************/
1316 {
1317  return (RexxObject *)this; /* just return this value */
1318 }
1319 
1320 /* **************************************** */
1321 /* Integer class methods begin here ..... */
1322 /* **************************************** */
1323 
1325 /******************************************************************************/
1326 /* This method will pre-allocate 100 integer objects, 0-99. These will then */
1327 /* be used when ever a request for an integer between 0 and 99 is requested */
1328 /* this should help reduce some of our memory requirements and trips through */
1329 /* memory_new. */
1330 /******************************************************************************/
1331 {
1332  int i; /* loop counter */
1333 
1334  for (i=INTEGERCACHELOW; i<INTEGERCACHESIZE; i++ ) { /* now create all our cached integers*/
1335  OrefSet(this, this->integercache[i - INTEGERCACHELOW], new RexxInteger (i));
1336  /* force the item to create its string value too. This can save */
1337  /* us a lot of time when string indices are used for compound */
1338  /* variables and also eliminate a bunch of old-new table */
1339  /* references. */
1341  }
1342 }
1343 
1344 void RexxIntegerClass::live(size_t liveMark)
1345 /******************************************************************************/
1346 /* Function: Normal garbage collection live marking */
1347 /******************************************************************************/
1348 {
1349  int i; /* loop counter */
1350 
1351  this->RexxClass::live(liveMark); /* do RexxClass level marking */
1352 
1353  /* now mark the cached integers */
1354  for (i = INTEGERCACHELOW; i < INTEGERCACHESIZE ;i++ )
1355  {
1357  }
1358 }
1359 
1361 /******************************************************************************/
1362 /* Function: Generalized object marking */
1363 /******************************************************************************/
1364 {
1365  int i; /* loop counter */
1366 
1367  this->RexxClass::liveGeneral(reason); /* do RexxClass level marking */
1368 
1369  /* now mark the cached integers */
1370  for (i = INTEGERCACHELOW; i < INTEGERCACHESIZE ;i++ )
1371  {
1373  }
1374 }
1375 
1377 /******************************************************************************/
1378 /* Function: Return the String class object for integer instances */
1379 /******************************************************************************/
1380 {
1381  /* just return class from behaviour */
1382  return TheStringClass;
1383 }
1384 
1385 void *RexxInteger::operator new(size_t size)
1386 /******************************************************************************/
1387 /* Function: Create a new integer object */
1388 /******************************************************************************/
1389 {
1390  RexxObject *newObject = new_object(size, T_Integer); /* get a new object */
1391  newObject->setHasNoReferences(); /* Tell GC, not to bother with Live */
1392  return newObject; /* return the new object. */
1393 }
1394 
1396 /******************************************************************************/
1397 /* Function: Create the integer class and set up the integer cache */
1398 /******************************************************************************/
1399 {
1400  /* Create the Integer class object */
1401  /* its asubclass of the CLASS class,*/
1402  /* and needs to override the NEW */
1403  /* method to provide caching */
1404  /* support for integers. */
1405  CLASS_CREATE(Integer, "String", RexxIntegerClass);
1406  /* initialize our static array of */
1407  /* cached integers */
1409 }
1410 
1411 
1413 {
1414  NULL,
1415  (PCPPM)&RexxInteger::plus, // "+"
1416  (PCPPM)&RexxInteger::minus, // "-"
1417  (PCPPM)&RexxInteger::multiply, // "*"
1418  (PCPPM)&RexxInteger::divide, // "/"
1420  (PCPPM)&RexxInteger::remainder, // "//"
1421  (PCPPM)&RexxInteger::power, // "**"
1422  (PCPPM)&RexxInteger::concat, // "" should be ::abuttal
1423  (PCPPM)&RexxInteger::concat, // "||"
1425  (PCPPM)&RexxInteger::equal, // "="
1426  (PCPPM)&RexxInteger::notEqual, // "\="
1428  (PCPPM)&RexxInteger::isLessOrEqual, // ">" should be ::isBackslashGreaterThan
1429  (PCPPM)&RexxInteger::isLessThan, // "<"
1430  (PCPPM)&RexxInteger::isGreaterOrEqual, // "<" should be ::isBackslashLessThan
1433  (PCPPM)&RexxInteger::strictEqual, // "=="
1436  (PCPPM)&RexxInteger::strictLessOrEqual, // ">>" should be ::strictBackslashGreaterThan
1438  (PCPPM)&RexxInteger::strictGreaterOrEqual, // "<<" should be ::strictBackslashLessThan
1441  (PCPPM)&RexxInteger::notEqual, // "<>" should be ::lessThanGreaterThan
1442  (PCPPM)&RexxInteger::notEqual, // "><" should be ::greaterThanLessThan
1443  (PCPPM)&RexxInteger::andOp, // "&"
1444  (PCPPM)&RexxInteger::orOp, // "|"
1445  (PCPPM)&RexxInteger::xorOp, // "&&"
1447 };
1448 
void reportException(wholenumber_t error)
@ T_Integer
#define integer_forward(s, m, o)
#define INTEGERCACHELOW
#define INTEGERCACHESIZE
RexxInteger * new_integer(wholenumber_t v)
RexxNumberString * new_numberstringFromWholenumber(wholenumber_t n)
size_t number_digits()
Definition: Numerics.hpp:147
RexxObject *(RexxObject::* PCPPM)()
size_t HashCode
Definition: ObjectClass.hpp:79
@ TRACE_PREFIX_LITERAL
#define OREF_NULL
Definition: RexxCore.h:61
RexxString * REQUEST_STRING(RexxObject *object)
Definition: RexxCore.h:295
bool isPolymorphicString(RexxObject *o)
Definition: RexxCore.h:284
#define IntegerOne
Definition: RexxCore.h:200
#define TheStringClass
Definition: RexxCore.h:169
#define OrefSet(o, r, v)
Definition: RexxCore.h:101
#define TheTrueObject
Definition: RexxCore.h:196
#define TheIntegerClass
Definition: RexxCore.h:158
#define isOfClass(t, r)
Definition: RexxCore.h:224
#define TheNilObject
Definition: RexxCore.h:191
#define TheFalseObject
Definition: RexxCore.h:195
const int ARG_ONE
Definition: RexxCore.h:83
#define IntegerZero
Definition: RexxCore.h:199
void requiredArgument(RexxObject *object, RexxString *kind, size_t position)
Definition: RexxCore.h:303
#define Error_Logical_value_method
#define Error_No_result_object_message
#define Error_Incorrect_method_noarg
#define Error_Overflow_zero
#define memory_mark(oref)
Definition: RexxMemory.hpp:450
RexxObject * new_object(size_t s)
Definition: RexxMemory.hpp:436
#define flatten_reference(oref, envel)
Definition: RexxMemory.hpp:498
#define CLASS_CREATE(name, id, className)
Definition: RexxMemory.hpp:503
#define memory_mark_general(oref)
Definition: RexxMemory.hpp:451
#define cleanUpFlatten
Definition: RexxMemory.hpp:484
#define setUpFlatten(type)
Definition: RexxMemory.hpp:478
RexxString * new_string(const char *s, stringsize_t l)
static const wholenumber_t MIN_WHOLENUMBER
Definition: Numerics.hpp:63
static const wholenumber_t MAX_WHOLENUMBER
Definition: Numerics.hpp:62
static wholenumber_t abs(wholenumber_t n)
Definition: Numerics.hpp:115
static const wholenumber_t validMaxWhole[]
Definition: Numerics.hpp:83
static size_t formatWholeNumber(wholenumber_t integer, char *dest)
Definition: Numerics.cpp:572
static const size_t DEFAULT_DIGITS
Definition: Numerics.hpp:66
void traceIntermediate(RexxObject *v, int p)
void liveGeneral(int reason)
Definition: ClassClass.cpp:87
void live(size_t)
Definition: ClassClass.cpp:67
void append(const char *newData, size_t stringLen)
void push(RexxObject *value)
void liveGeneral(int reason)
void live(size_t)
RexxInteger * integercache[INTEGERCACHESIZE - INTEGERCACHELOW]
bool numberValue(wholenumber_t &result, size_t precision)
RexxInteger * isLessOrEqual(RexxObject *)
void setString(RexxString *string)
static RexxInteger * integerFour
RexxObject * xorOp(RexxObject *)
static void createInstance()
static RexxInteger * integerSix
RexxInteger * equal(RexxObject *)
wholenumber_t strictComp(RexxObject *, RexxString *alternativeOperator=OREF_NULL, RexxInteger **alternativeOperatorResultPtr=NULL)
RexxInteger * isLessThan(RexxObject *)
RexxInteger * strictGreaterOrEqual(RexxObject *)
RexxString * concat(RexxString *)
static RexxInteger * falseObject
static RexxInteger * integerThree
RexxInteger * isGreaterThan(RexxObject *)
static RexxInteger * integerSeven
RexxInteger * notEqual(RexxObject *)
void flatten(RexxEnvelope *)
RexxObject * power(RexxObject *)
RexxObject * getRealValue(RexxActivation *)
RexxObject * plus(RexxInteger *)
RexxString * stringrep
RexxObject * remainder(RexxInteger *)
RexxObject * minus(RexxInteger *)
RexxObject * notOp()
static RexxInteger * integerZero
RexxObject * ceiling()
RexxObject * Max(RexxObject **, size_t, size_t)
bool isEqual(RexxObject *)
static RexxInteger * integerTwo
RexxObject * round()
RexxObject * d2x(RexxObject *)
RexxInteger * strictGreaterThan(RexxObject *)
RexxObject * operatorNot(RexxObject *)
RexxNumberString * numberString()
RexxInteger * strictLessOrEqual(RexxObject *)
RexxInteger * strictLessThan(RexxObject *)
static RexxInteger * integerNine
RexxObject * trunc(RexxObject *)
RexxObject * Min(RexxObject **, size_t, size_t)
RexxInteger * isGreaterOrEqual(RexxObject *)
static RexxInteger * nullPointer
RexxString * concatBlank(RexxString *)
wholenumber_t value
RexxObject * d2c(RexxObject *)
void liveGeneral(int reason)
virtual HashCode getHashValue()
RexxClass * classObject()
bool isInstanceOf(RexxClass *)
static RexxInteger * trueObject
void live(size_t)
RexxInteger * integerValue(size_t)
RexxObject * getValue(RexxActivation *)
RexxString * stringValue()
void copyIntoTail(RexxCompoundTail *)
RexxObject * andOp(RexxObject *)
wholenumber_t wholeNumber()
static RexxInteger * integerEight
RexxObject * multiply(RexxInteger *)
virtual wholenumber_t compareTo(RexxObject *)
RexxInteger * hasMethod(RexxString *)
RexxInteger * strictNotEqual(RexxObject *)
RexxObject * orOp(RexxObject *)
static RexxIntegerClass * classInstance
RexxObject * unknown(RexxString *, RexxArray *, RexxDirectory *)
RexxMethod * instanceMethod(RexxString *)
RexxString * makeString()
RexxObject * hashCode()
wholenumber_t comp(RexxObject *other, RexxString *alternativeOperator=OREF_NULL, RexxInteger **alternativeOperatorResultPtr=NULL)
RexxObject * sign()
RexxObject * abs()
static RexxInteger * integerMinusOne
RexxObject * format(RexxObject *, RexxObject *, RexxObject *, RexxObject *)
static RexxInteger * integerOne
RexxObject * evaluate(RexxActivation *, RexxExpressionStack *)
RexxInteger * strictEqual(RexxObject *)
RexxObject * integerDivide(RexxInteger *)
bool truthValue(int)
static RexxInteger * integerFive
bool doubleValue(double &result)
RexxArray * makeArray()
RexxObject * floor()
RexxSupplier * instanceMethods(RexxClass *)
bool unsignedNumberValue(stringsize_t &result, size_t precision)
RexxObject * divide(RexxInteger *)
virtual bool logicalValue(logical_t &)
RexxString * primitiveMakeString()
static PCPPM operatorMethods[]
bool isSameType(RexxInternalObject *o)
wholenumber_t comp(RexxObject *, RexxString *alternativeOperator=OREF_NULL, RexxInteger **alternativeOperatorResultPtr=NULL)
RexxNumberString * Max(RexxObject **, size_t, size_t)
RexxString * formatRexx(RexxObject *, RexxObject *, RexxObject *, RexxObject *)
RexxNumberString * Min(RexxObject **, size_t, size_t)
RexxString * d2xD2c(RexxObject *, bool)
RexxNumberString * abs()
RexxObject * trunc(RexxObject *)
virtual RexxInteger * hasMethod(RexxString *msg)
RexxSupplier * instanceMethods(RexxClass *)
void sendMessage(RexxString *, RexxArray *, RexxDirectory *, ProtectedObject &)
HashCode hash()
RexxMethod * instanceMethod(RexxString *)
bool messageSend(RexxString *, RexxObject **, size_t, size_t, ProtectedObject &, bool processUnknown=true, bool dynamicTarget=true)
bool truthValue(int)
bool isInstanceOf(RexxClass *)
RexxString * concatRexx(RexxObject *)
size_t getLength()
const char * getStringData()
RexxString * concatBlank(RexxObject *)
RexxNumberString * numberString()
bool isEqual(RexxObject *)
virtual HashCode getHashValue()
RexxString * concat(RexxString *)
RexxString * concatWith(RexxString *, char)
wholenumber_t compareTo(RexxObject *)
RexxArray * makeArray()
wholenumber_t strictComp(RexxObject *, RexxString *alternativeOperator=NULL, RexxInteger **alternativeOperatorResultPtr=NULL)
size_t logical_t
Definition: rexx.h:231
ssize_t wholenumber_t
Definition: rexx.h:230
size_t stringsize_t
Definition: rexx.h:228