Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
@leto leto authored moritz committed
View
2  build/PARROT_REVISION
@@ -1 +1 @@
-40521
+40598
View
7 src/builtins/any-list.pir
@@ -105,18 +105,18 @@ Return a List with the keys of the invocant.
.end
.namespace ['Any']
+.loadlib 'math_ops'
.sub 'pick' :method :multi()
.param int p_num :optional
.param int has_num :opt_flag
.param pmc p_repl :optional :named('repl')
.param int has_repl :opt_flag
- .local pmc list, result, rand
+ .local pmc list, result
.local int elems
list = self.'list'()
elems = list.'elems'()
result = 'list'()
- rand = get_hll_global ['Any'], '$!random'
if has_num goto have_num
p_num = 1
@@ -134,8 +134,7 @@ Return a List with the keys of the invocant.
loop:
unless p_num > 0 goto done
unless elems > 0 goto done
- $N0 = rand
- $N0 *= elems
+ $N0 = rand elems
$I0 = $N0
$P0 = list[$I0]
push result, $P0
View
13 src/builtins/any-num.pir
@@ -19,14 +19,13 @@ the size of that file down and to emphasize their generic,
=cut
.namespace []
+.loadlib 'math_ops'
.sub 'onload' :anon :init :load
$P0 = get_hll_namespace ['Any']
'!EXPORT'('abs,int,log,polar,sqrt,truncate,unpolar', 'from'=>$P0)
## pre-seed a random number generator
- $P0 = root_new ['parrot';'Random']
- set_hll_global ['Any'], '$!random', $P0
- srand()
+ 'srand'()
.end
@@ -103,18 +102,14 @@ error.
if has_seed goto have_seed
seed = time
have_seed:
- $P0 = get_hll_global ['Any'], '$!random'
- $I0 = seed
- $P0 = $I0
+ srand seed
.return ()
.end
.namespace ['Any']
.sub 'srand' :method
$N0 = self
- $I0 = $N0
- $P0 = get_hll_global ['Any'], '$!random'
- $P0 = $I0
+ srand $N0
.return ()
.end
View
6 src/setting/Any-num.pm
@@ -30,10 +30,8 @@ class Any is also {
our Num method rand() {
Q:PIR {
$N0 = self
- $P0 = get_hll_global ['Any'], '$!random'
- $N1 = $P0
- $N0 *= $N1
- %r = box $N0
+ $N1 = rand $N0
+ %r = box $N1
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.