Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Convert any-num to the rand/srand dynops

The Random PMC was deprecated in Parrot 1.1 and is being removed as part
of 1.5 . This fixes the Rakudo build to use the dynamically loadable
math ops instead.

Plus changes by moritz:

 + bump build/PARROT_REVISION to r40598 where dynops installing is fixed
 + remove left-over usages of !random hll_global

Signed-off-by: Moritz Lenz <moritz@faui2k3.org>
  • Loading branch information...
commit 56372080883f2204224912b4213b3a0383e0198e 1 parent 9959b21
Duke Leto authored August 16, 2009 moritz committed August 16, 2009
2  build/PARROT_REVISION
... ...
@@ -1 +1 @@
1  
-40521
  1
+40598
7  src/builtins/any-list.pir
@@ -105,18 +105,18 @@ Return a List with the keys of the invocant.
105 105
 .end
106 106
 
107 107
 .namespace ['Any']
  108
+.loadlib 'math_ops'
108 109
 .sub 'pick' :method :multi()
109 110
     .param int p_num           :optional
110 111
     .param int has_num         :opt_flag
111 112
     .param pmc p_repl          :optional :named('repl')
112 113
     .param int has_repl        :opt_flag
113 114
 
114  
-    .local pmc list, result, rand
  115
+    .local pmc list, result
115 116
     .local int elems
116 117
     list = self.'list'()
117 118
     elems = list.'elems'()
118 119
     result = 'list'()
119  
-    rand = get_hll_global ['Any'], '$!random'
120 120
 
121 121
     if has_num goto have_num
122 122
     p_num = 1
@@ -134,8 +134,7 @@ Return a List with the keys of the invocant.
134 134
   loop:
135 135
     unless p_num > 0 goto done
136 136
     unless elems > 0 goto done
137  
-    $N0 = rand
138  
-    $N0 *= elems
  137
+    $N0 = rand elems
139 138
     $I0 = $N0
140 139
     $P0 = list[$I0]
141 140
     push result, $P0
13  src/builtins/any-num.pir
@@ -19,14 +19,13 @@ the size of that file down and to emphasize their generic,
19 19
 =cut
20 20
 
21 21
 .namespace []
  22
+.loadlib 'math_ops'
22 23
 .sub 'onload' :anon :init :load
23 24
     $P0 = get_hll_namespace ['Any']
24 25
     '!EXPORT'('abs,int,log,polar,sqrt,truncate,unpolar', 'from'=>$P0)
25 26
 
26 27
     ##  pre-seed a random number generator
27  
-    $P0 = root_new ['parrot';'Random']
28  
-    set_hll_global ['Any'], '$!random', $P0
29  
-    srand()
  28
+    'srand'()
30 29
 .end
31 30
 
32 31
 
@@ -103,18 +102,14 @@ error.
103 102
     if has_seed goto have_seed
104 103
     seed = time
105 104
   have_seed:
106  
-    $P0 = get_hll_global ['Any'], '$!random'
107  
-    $I0 = seed
108  
-    $P0 = $I0
  105
+    srand seed
109 106
     .return ()
110 107
 .end
111 108
 
112 109
 .namespace ['Any']
113 110
 .sub 'srand' :method
114 111
     $N0 = self
115  
-    $I0 = $N0
116  
-    $P0 = get_hll_global ['Any'], '$!random'
117  
-    $P0 = $I0
  112
+    srand $N0
118 113
     .return ()
119 114
 .end
120 115
 
6  src/setting/Any-num.pm
@@ -30,10 +30,8 @@ class Any is also {
30 30
     our Num method rand() {
31 31
         Q:PIR {
32 32
             $N0 = self
33  
-            $P0 = get_hll_global ['Any'], '$!random'
34  
-            $N1 = $P0
35  
-            $N0 *= $N1
36  
-            %r = box $N0
  33
+            $N1 = rand $N0
  34
+            %r = box $N1
37 35
         }
38 36
     }
39 37
 

0 notes on commit 5637208

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