Skip to content
This repository
Browse code

Reverting to 84e0c30

  • Loading branch information...
commit 7edf9b96724ed76bf2ded93a3264f04d4566373a 1 parent ea10b13
Andy Lester authored March 31, 2012

Showing 1 changed file with 45 additions and 71 deletions. Show diff stats Hide diff stats

  1. 116  src/dynpmc/rational.pmc
116  src/dynpmc/rational.pmc
@@ -54,7 +54,7 @@ Returns a string representation of a Rational-PMC to a certain base.
54 54
 */
55 55
 static STRING *rat_get_string_to_base(PARROT_INTERP, PMC *self, int base) {
56 56
   #ifdef PARROT_HAS_GMP
57  
-    char * const cstr   = mpq_get_str(NULL, base, RT(self));
  57
+    char * const cstr   = mpq_get_str(NULL, (int) base, RT(self));
58 58
     STRING * const pstr = Parrot_str_new(interp, cstr, 0);
59 59
     Parrot_str_free_cstring(cstr);
60 60
     return pstr;
@@ -72,11 +72,11 @@ Adds an integer "value" to a Rational-PMC inplace.
72 72
 =cut
73 73
 
74 74
 */
75  
-static void rat_add_integer(PMC *self, int value) {
  75
+static void rat_add_integer(PARROT_INTERP, PMC *self, int value) {
76 76
   #ifdef PARROT_HAS_GMP
77 77
     mpq_t t;
78 78
     mpq_init(t);
79  
-    mpq_set_si(t, value, 1);
  79
+    mpq_set_si(t, (int) value, 1);
80 80
     mpq_add(RT(self), RT(self), t);
81 81
     mpq_clear(t);
82 82
   #else
@@ -94,12 +94,12 @@ rational using GMPs mpq_set_d-function. This is meant to be exact.
94 94
 =cut
95 95
 
96 96
 */
97  
-static void rat_add_float(PMC *self, double value) {
  97
+static void rat_add_float(PARROT_INTERP, PMC *self, double value) {
98 98
   #ifdef PARROT_HAS_GMP
99 99
     mpq_t t;
100 100
 
101 101
     mpq_init(t);
102  
-    mpq_set_d(t, value);
  102
+    mpq_set_d(t, (double) value);
103 103
     mpq_add(RT(self), RT(self), t);
104 104
     mpq_clear(t);
105 105
   #else
@@ -116,7 +116,7 @@ Multiplies a Rational-PMC with an integer "value" in-place.
116 116
 =cut
117 117
 
118 118
 */
119  
-static void rat_multiply_integer(PMC *self, int value) {
  119
+static void rat_multiply_integer(PARROT_INTERP, PMC *self, int value) {
120 120
   #ifdef PARROT_HAS_GMP
121 121
     mpz_mul_ui(mpq_numref(RT(self)), mpq_numref(RT(self)), (unsigned int) value);
122 122
   #else
@@ -133,12 +133,12 @@ Multiplies a Rational-PMC with a float "value" in-place.
133 133
 =cut
134 134
 
135 135
 */
136  
-static void rat_multiply_float(PMC *self, double value) {
  136
+static void rat_multiply_float(PARROT_INTERP, PMC *self, double value) {
137 137
   #ifdef PARROT_HAS_GMP
138 138
     mpq_t t;
139 139
 
140 140
     mpq_init(t);
141  
-    mpq_set_d(t, value);
  141
+    mpq_set_d(t, (double) value);
142 142
     mpq_mul(RT(self), RT(self), t);
143 143
     mpq_clear(t);
144 144
   #else
@@ -155,12 +155,12 @@ Divides a Rational-PMC through an integer "value" in-place.
155 155
 =cut
156 156
 
157 157
 */
158  
-static void rat_divide_integer(PMC *self, int value) {
  158
+static void rat_divide_integer(PARROT_INTERP, PMC *self, int value) {
159 159
   #ifdef PARROT_HAS_GMP
160 160
     mpq_t t;
161 161
 
162 162
     mpq_init(t);
163  
-    mpq_set_si(t, value, 1);
  163
+    mpq_set_si(t, (int) value, 1);
164 164
     mpq_div(RT(self), RT(self), t);
165 165
     mpq_clear(t);
166 166
   #else
@@ -177,12 +177,12 @@ Divides a Rational-PMC through a float "value" in-place.
177 177
 =cut
178 178
 
179 179
 */
180  
-static void rat_divide_float(PMC *self, double value) {
  180
+static void rat_divide_float(PARROT_INTERP, PMC *self, double value) {
181 181
   #ifdef PARROT_HAS_GMP
182 182
     mpq_t t;
183 183
 
184 184
     mpq_init(t);
185  
-    mpq_set_d(t, value);
  185
+    mpq_set_d(t, (double) value);
186 186
     mpq_div(RT(self), RT(self), t);
187 187
     mpq_clear(t);
188 188
   #else
@@ -285,7 +285,6 @@ Returns the version of GNU Multiple Precision library. Returns 0.0.0, if GMP is
285 285
 */
286 286
     VTABLE void set_integer_native(INTVAL value) {
287 287
       #ifdef PARROT_HAS_GMP
288  
-        UNUSED(INTERP)
289 288
         mpq_set_si(RT(SELF), (signed int) value, 1);
290 289
         mpq_canonicalize(RT(SELF));
291 290
       #else
@@ -302,7 +301,6 @@ Returns the version of GNU Multiple Precision library. Returns 0.0.0, if GMP is
302 301
 */
303 302
     VTABLE void set_number_native(FLOATVAL value) {
304 303
       #ifdef PARROT_HAS_GMP
305  
-        UNUSED(INTERP)
306 304
         mpq_set_d(RT(SELF), (double) value);
307 305
         mpq_canonicalize(RT(SELF));
308 306
       #else
@@ -384,7 +382,6 @@ Returns the version of GNU Multiple Precision library. Returns 0.0.0, if GMP is
384 382
     VTABLE FLOATVAL get_number() {
385 383
       #ifdef PARROT_HAS_GMP
386 384
         const double d = mpq_get_d(RT(SELF));
387  
-        UNUSED(INTERP)
388 385
         return (FLOATVAL) d;
389 386
       #else
390 387
         RAISE_EXCEPTION
@@ -447,7 +444,6 @@ Returns the version of GNU Multiple Precision library. Returns 0.0.0, if GMP is
447 444
 */
448 445
     VTABLE void increment() {
449 446
       #ifdef PARROT_HAS_GMP
450  
-        UNUSED(INTERP)
451 447
         mpz_add(mpq_numref(RT(SELF)), mpq_numref(RT(SELF)), mpq_denref(RT(SELF)));
452 448
         mpq_canonicalize(RT(SELF));
453 449
       #else
@@ -464,7 +460,6 @@ Returns the version of GNU Multiple Precision library. Returns 0.0.0, if GMP is
464 460
 */
465 461
     VTABLE void decrement() {
466 462
       #ifdef PARROT_HAS_GMP
467  
-        UNUSED(INTERP)
468 463
         mpz_sub(mpq_numref(RT(SELF)), mpq_numref(RT(SELF)), mpq_denref(RT(SELF)));
469 464
         mpq_canonicalize(RT(SELF));
470 465
       #else
@@ -483,13 +478,13 @@ Adds Integer-, Float- or Rational-PMCs to SELF and stores them in dest.
483 478
 */
484 479
     MULTI PMC *add(Integer value, PMC* dest) {
485 480
         dest = STATICSELF.clone();
486  
-        rat_add_integer(dest, VTABLE_get_integer(INTERP, value));
  481
+        rat_add_integer(INTERP, dest, VTABLE_get_integer(INTERP, value));
487 482
         return dest;
488 483
     }
489 484
 
490 485
     MULTI PMC *add(Float value, PMC* dest) {
491 486
         dest = STATICSELF.clone();
492  
-        rat_add_float(dest, VTABLE_get_number(INTERP, value));
  487
+        rat_add_float(INTERP, dest, VTABLE_get_number(INTERP, value));
493 488
         return dest;
494 489
     }
495 490
 
@@ -517,11 +512,11 @@ Adds Integer-, Float- or Rational-PMCs to SELF and stores them in dest.
517 512
 
518 513
 */
519 514
     MULTI void i_add(Integer value) {
520  
-        rat_add_integer(SELF, (int) VTABLE_get_integer(INTERP, value));
  515
+        rat_add_integer(INTERP, SELF, (int) VTABLE_get_integer(INTERP, value));
521 516
     }
522 517
 
523 518
     MULTI void i_add(Float value) {
524  
-        rat_add_float(SELF, (double) VTABLE_get_number(INTERP, value));
  519
+        rat_add_float(INTERP, SELF, (double) VTABLE_get_number(INTERP, value));
525 520
     }
526 521
 
527 522
     MULTI void i_add(Rational value) {
@@ -546,7 +541,7 @@ Adds Integer-, Float- or Rational-PMCs to SELF and stores them in dest.
546 541
 */
547 542
     VTABLE PMC *add_int(INTVAL value, PMC* dest) {
548 543
         dest = STATICSELF.clone();
549  
-        rat_add_integer(dest, (int) value);
  544
+        rat_add_integer(INTERP, dest, (int) value);
550 545
         return dest;
551 546
     }
552 547
 
@@ -558,7 +553,7 @@ Adds Integer-, Float- or Rational-PMCs to SELF and stores them in dest.
558 553
 
559 554
 */
560 555
     VTABLE void i_add_int(INTVAL value) {
561  
-        rat_add_integer(SELF, (int) value);
  556
+        rat_add_integer(INTERP, SELF, (int) value);
562 557
     }
563 558
 
564 559
 /*
@@ -570,7 +565,7 @@ Adds Integer-, Float- or Rational-PMCs to SELF and stores them in dest.
570 565
 */
571 566
     VTABLE PMC *add_float(FLOATVAL value, PMC* dest) {
572 567
         dest = STATICSELF.clone();
573  
-        rat_add_float(dest, (double) value);
  568
+        rat_add_float(INTERP, dest, (double) value);
574 569
         return dest;
575 570
     }
576 571
 
@@ -582,8 +577,7 @@ Adds Integer-, Float- or Rational-PMCs to SELF and stores them in dest.
582 577
 
583 578
 */
584 579
     VTABLE void i_add_float(FLOATVAL value) {
585  
-        UNUSED(INTERP)
586  
-        rat_add_float(SELF, (double) value);
  580
+        rat_add_float(INTERP, SELF, (double) value);
587 581
     }
588 582
 
589 583
 /*
@@ -595,13 +589,13 @@ Adds Integer-, Float- or Rational-PMCs to SELF and stores them in dest.
595 589
 */
596 590
     MULTI PMC *subtract(Integer value, PMC* dest) {
597 591
         dest = STATICSELF.clone();
598  
-        rat_add_integer(dest, -((int) VTABLE_get_integer(INTERP, value)));
  592
+        rat_add_integer(INTERP, dest, -((int) VTABLE_get_integer(INTERP, value)));
599 593
         return dest;
600 594
     }
601 595
 
602 596
     MULTI PMC *subtract(Float value, PMC* dest) {
603 597
         dest = STATICSELF.clone();
604  
-        rat_add_float(dest, - ((double) VTABLE_get_number(INTERP, value)));
  598
+        rat_add_float(INTERP, dest, - ((double) VTABLE_get_number(INTERP, value)));
605 599
         return dest;
606 600
     }
607 601
 
@@ -628,18 +622,15 @@ Adds Integer-, Float- or Rational-PMCs to SELF and stores them in dest.
628 622
 
629 623
 */
630 624
     MULTI void i_subtract(Integer value) {
631  
-        UNUSED(INTERP)
632  
-        rat_add_integer(SELF, -((int) VTABLE_get_integer(INTERP, value)));
  625
+        rat_add_integer(INTERP, SELF, -((int) VTABLE_get_integer(INTERP, value)));
633 626
     }
634 627
 
635 628
     MULTI void i_subtract(Float value) {
636  
-        UNUSED(INTERP)
637  
-        rat_add_float(SELF, - ((double) VTABLE_get_number(INTERP, value)));
  629
+        rat_add_float(INTERP, SELF, - ((double) VTABLE_get_number(INTERP, value)));
638 630
     }
639 631
 
640 632
     MULTI void i_subtract(Rational value) {
641 633
       #ifdef PARROT_HAS_GMP
642  
-        UNUSED(INTERP)
643 634
         mpq_sub(RT(SELF), RT(SELF), RT(value));
644 635
       #else
645 636
         RAISE_EXCEPTION
@@ -659,9 +650,8 @@ Adds Integer-, Float- or Rational-PMCs to SELF and stores them in dest.
659 650
 
660 651
 */
661 652
     VTABLE PMC *subtract_int(INTVAL value, PMC* dest) {
662  
-        UNUSED(INTERP)
663 653
         dest = STATICSELF.clone();
664  
-        rat_add_integer(dest, -((int) value));
  654
+        rat_add_integer(INTERP, dest, -((int) value));
665 655
         return dest;
666 656
     }
667 657
 
@@ -673,8 +663,7 @@ Adds Integer-, Float- or Rational-PMCs to SELF and stores them in dest.
673 663
 
674 664
 */
675 665
     VTABLE void i_subtract_int(INTVAL value) {
676  
-        UNUSED(INTERP)
677  
-        rat_add_integer(SELF, -((int) value));
  666
+        rat_add_integer(INTERP, SELF, -((int) value));
678 667
     }
679 668
 
680 669
 /*
@@ -685,9 +674,8 @@ Adds Integer-, Float- or Rational-PMCs to SELF and stores them in dest.
685 674
 
686 675
 */
687 676
     VTABLE PMC *subtract_float(FLOATVAL value, PMC* dest) {
688  
-        UNUSED(INTERP)
689 677
         dest = STATICSELF.clone();
690  
-        rat_add_float(dest, -((double) value));
  678
+        rat_add_float(INTERP, dest, -((double) value));
691 679
         return dest;
692 680
     }
693 681
 
@@ -699,8 +687,7 @@ Adds Integer-, Float- or Rational-PMCs to SELF and stores them in dest.
699 687
 
700 688
 */
701 689
     VTABLE void i_subtract_float(FLOATVAL value) {
702  
-        UNUSED(INTERP)
703  
-        rat_add_float(SELF, -((double) value));
  690
+        rat_add_float(INTERP, SELF, -((double) value));
704 691
     }
705 692
 
706 693
 /*
@@ -712,13 +699,13 @@ Adds Integer-, Float- or Rational-PMCs to SELF and stores them in dest.
712 699
 */
713 700
     MULTI PMC *multiply(Integer value, PMC* dest) {
714 701
         dest = STATICSELF.clone();
715  
-        rat_multiply_integer(dest, (int) VTABLE_get_integer(INTERP, value));
  702
+        rat_multiply_integer(INTERP, dest, (int) VTABLE_get_integer(INTERP, value));
716 703
         return dest;
717 704
     }
718 705
 
719 706
     MULTI PMC *multiply(Float value, PMC* dest) {
720 707
         dest = STATICSELF.clone();
721  
-        rat_multiply_float(dest, (double) VTABLE_get_number(INTERP, value));
  708
+        rat_multiply_float(INTERP, dest, (double) VTABLE_get_number(INTERP, value));
722 709
         return dest;
723 710
     }
724 711
 
@@ -745,11 +732,11 @@ Adds Integer-, Float- or Rational-PMCs to SELF and stores them in dest.
745 732
 
746 733
 */
747 734
     MULTI void i_multiply(Integer value) {
748  
-        rat_multiply_integer(SELF, (int) VTABLE_get_integer(INTERP, value));
  735
+        rat_multiply_integer(INTERP, SELF, (int) VTABLE_get_integer(INTERP, value));
749 736
     }
750 737
 
751 738
     MULTI void i_multiply(Float value) {
752  
-        rat_multiply_float(SELF, (double) VTABLE_get_number(INTERP, value));
  739
+        rat_multiply_float(INTERP, SELF, (double) VTABLE_get_number(INTERP, value));
753 740
     }
754 741
 
755 742
     MULTI void i_multiply(Rational value) {
@@ -773,9 +760,8 @@ Adds Integer-, Float- or Rational-PMCs to SELF and stores them in dest.
773 760
 
774 761
 */
775 762
     VTABLE PMC *multiply_int(INTVAL value, PMC* dest) {
776  
-        UNUSED(INTERP)
777 763
         dest = STATICSELF.clone();
778  
-        rat_multiply_integer(dest, (int) value);
  764
+        rat_multiply_integer(INTERP, dest, (int) value);
779 765
         return dest;
780 766
     }
781 767
 
@@ -787,8 +773,7 @@ Adds Integer-, Float- or Rational-PMCs to SELF and stores them in dest.
787 773
 
788 774
 */
789 775
     VTABLE void i_multiply_int(INTVAL value) {
790  
-        UNUSED(INTERP)
791  
-        rat_multiply_integer(SELF, (int) value);
  776
+        rat_multiply_integer(INTERP, SELF, (int) value);
792 777
     }
793 778
 
794 779
 /*
@@ -799,9 +784,8 @@ Adds Integer-, Float- or Rational-PMCs to SELF and stores them in dest.
799 784
 
800 785
 */
801 786
     VTABLE PMC *multiply_float(FLOATVAL value, PMC* dest) {
802  
-        UNUSED(INTERP)
803 787
         dest = STATICSELF.clone();
804  
-        rat_multiply_float(dest, (double) value);
  788
+        rat_multiply_float(INTERP, dest, (double) value);
805 789
         return dest;
806 790
     }
807 791
 
@@ -813,8 +797,7 @@ Adds Integer-, Float- or Rational-PMCs to SELF and stores them in dest.
813 797
 
814 798
 */
815 799
     VTABLE void i_multiply_float(FLOATVAL value) {
816  
-        UNUSED(INTERP)
817  
-        rat_multiply_float(SELF, (double) value);
  800
+        rat_multiply_float(INTERP, SELF, (double) value);
818 801
     }
819 802
 
820 803
 /*
@@ -826,13 +809,13 @@ Adds Integer-, Float- or Rational-PMCs to SELF and stores them in dest.
826 809
 */
827 810
     MULTI PMC *divide(Integer value, PMC* dest) {
828 811
         dest = STATICSELF.clone();
829  
-        rat_divide_integer(dest, (int) VTABLE_get_integer(INTERP, value));
  812
+        rat_divide_integer(INTERP, dest, (int) VTABLE_get_integer(INTERP, value));
830 813
         return dest;
831 814
     }
832 815
 
833 816
     MULTI PMC *divide(Float value, PMC* dest) {
834 817
         dest = STATICSELF.clone();
835  
-        rat_divide_float(dest, (double) VTABLE_get_number(INTERP, value));
  818
+        rat_divide_float(INTERP, dest, (double) VTABLE_get_number(INTERP, value));
836 819
         return dest;
837 820
     }
838 821
 
@@ -859,18 +842,15 @@ Adds Integer-, Float- or Rational-PMCs to SELF and stores them in dest.
859 842
 
860 843
 */
861 844
     MULTI void i_divide(Integer value) {
862  
-        UNUSED(INTERP)
863  
-        rat_divide_integer(SELF, (int) VTABLE_get_integer(INTERP, value));
  845
+        rat_divide_integer(INTERP, SELF, (int) VTABLE_get_integer(INTERP, value));
864 846
     }
865 847
 
866 848
     MULTI void i_divide(Float value) {
867  
-        UNUSED(INTERP)
868  
-        rat_divide_float(SELF, (double) VTABLE_get_number(INTERP, value));
  849
+        rat_divide_float(INTERP, SELF, (double) VTABLE_get_number(INTERP, value));
869 850
     }
870 851
 
871 852
     MULTI void i_divide(Rational value) {
872 853
       #ifdef PARROT_HAS_GMP
873  
-        UNUSED(INTERP)
874 854
         mpq_div(RT(SELF), RT(SELF), RT(value));
875 855
       #else
876 856
         RAISE_EXCEPTION
@@ -891,7 +871,7 @@ Adds Integer-, Float- or Rational-PMCs to SELF and stores them in dest.
891 871
 */
892 872
     VTABLE PMC *divide_int(INTVAL value, PMC* dest) {
893 873
         dest = STATICSELF.clone();
894  
-        rat_divide_integer(dest, (int) value);
  874
+        rat_divide_integer(INTERP, dest, (int) value);
895 875
         return dest;
896 876
     }
897 877
 
@@ -903,8 +883,7 @@ Adds Integer-, Float- or Rational-PMCs to SELF and stores them in dest.
903 883
 
904 884
 */
905 885
     VTABLE void i_divide_int(INTVAL value) {
906  
-        UNUSED(INTERP)
907  
-        rat_divide_integer(SELF, (int) value);
  886
+        rat_divide_integer(INTERP, SELF, (int) value);
908 887
     }
909 888
 
910 889
 /*
@@ -915,9 +894,8 @@ Adds Integer-, Float- or Rational-PMCs to SELF and stores them in dest.
915 894
 
916 895
 */
917 896
     VTABLE PMC *divide_float(FLOATVAL value, PMC* dest) {
918  
-        UNUSED(INTERP)
919 897
         dest = STATICSELF.clone();
920  
-        rat_divide_float(dest, (double) value);
  898
+        rat_divide_float(INTERP, dest, (double) value);
921 899
         return dest;
922 900
     }
923 901
 
@@ -929,8 +907,7 @@ Adds Integer-, Float- or Rational-PMCs to SELF and stores them in dest.
929 907
 
930 908
 */
931 909
     VTABLE void i_divide_float(FLOATVAL value) {
932  
-        UNUSED(INTERP)
933  
-        rat_divide_float(SELF, (double) value);
  910
+        rat_divide_float(INTERP, SELF, (double) value);
934 911
     }
935 912
 
936 913
 /*
@@ -960,7 +937,6 @@ Adds Integer-, Float- or Rational-PMCs to SELF and stores them in dest.
960 937
 */
961 938
     VTABLE void i_neg() {
962 939
       #ifdef PARROT_HAS_GMP
963  
-        UNUSED(INTERP)
964 940
         mpq_neg(RT(SELF), RT(SELF));
965 941
       #else
966 942
         RAISE_EXCEPTION
@@ -994,7 +970,6 @@ Adds Integer-, Float- or Rational-PMCs to SELF and stores them in dest.
994 970
 */
995 971
     VTABLE void i_absolute() {
996 972
       #ifdef PARROT_HAS_GMP
997  
-        UNUSED(INTERP)
998 973
         mpq_abs(RT(SELF), RT(SELF));
999 974
       #else
1000 975
         RAISE_EXCEPTION
@@ -1027,7 +1002,6 @@ Adds Integer-, Float- or Rational-PMCs to SELF and stores them in dest.
1027 1002
 
1028 1003
     MULTI INTVAL cmp(Rational value) {
1029 1004
       #ifdef PARROT_HAS_GMP
1030  
-        UNUSED(INTERP)
1031 1005
         return (INTVAL) mpq_cmp(RT(SELF), RT(value));
1032 1006
       #else
1033 1007
         RAISE_EXCEPTION
@@ -1048,7 +1022,7 @@ Adds Integer-, Float- or Rational-PMCs to SELF and stores them in dest.
1048 1022
 */
1049 1023
     MULTI INTVAL is_equal(Integer value) {
1050 1024
       #ifdef PARROT_HAS_GMP
1051  
-        INTVAL eq;
  1025
+        INTVAL eq = 0;
1052 1026
         mpq_t t;
1053 1027
         mpq_init(t);
1054 1028
         mpq_set_ui(t, VTABLE_get_integer(INTERP, value), 1);

0 notes on commit 7edf9b9

Please sign in to comment.
Something went wrong with that request. Please try again.