Permalink
Browse files

[TT #871] Kill the Random PMC

git-svn-id: https://svn.parrot.org/parrot/trunk@40557 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
1 parent 29c1354 commit e1f325a20d7d922c0491ac1c6592e432d4615f56 @leto leto committed Aug 15, 2009
View
4 DEPRECATED.pod
@@ -37,10 +37,6 @@ specifically by including this C<PIR> code:
=over 4
-=item random [eligible in 1.1]
-
-L<https://trac.parrot.org/parrot/ticket/189>
-
=item moved to dynpmc [eligible in 1.1]
AddrRegistry, CodeString, Env, Eval, File, OS, PCCMETHOD_Test, StringHandle,
View
2 MANIFEST
@@ -1445,7 +1445,6 @@ src/pmc/pccmethod_test.pmc [devel]src
src/pmc/pmc.num []
src/pmc/pmcproxy.pmc [devel]src
src/pmc/pointer.pmc [devel]src
-src/pmc/random.pmc [devel]src
src/pmc/resizablebooleanarray.pmc [devel]src
src/pmc/resizablefloatarray.pmc [devel]src
src/pmc/resizableintegerarray.pmc [devel]src
@@ -1910,7 +1909,6 @@ t/pmc/pmc.t [test]
t/pmc/pmcproxy.t [test]
t/pmc/pointer.t [test]
t/pmc/prop.t [test]
-t/pmc/random.t [test]
t/pmc/resizablebooleanarray.t [test]
t/pmc/resizablefloatarray.t [test]
t/pmc/resizableintegerarray.t [test]
View
1 PBC_COMPAT
@@ -27,6 +27,7 @@
# please insert tab separated entries at the top of the list
+5.2 2009.08.06 dukeleto remove Random PMC
5.1 2009.08.06 cotto remove branch_cs opcode
5.0 2009.07.21 cotto released 1.4.0
4.0 2009.03.17 allison released 1.0.0
View
5 docs/pdds/pdd17_pmc.pod
@@ -1703,11 +1703,6 @@ when assigning a PMC using a WeakRegisterRef PMC, the register will be updated
to reference that PMC rather than calling the assign v-table call on the PMC
in that register. This is not the same behaviour as the Ref PMC.
-=item Random
-
-A singleton PMC that generates a random number. {{ NOTE: Why do we have
-this? }}
-
=item Exception
The base class for all exceptions. Currently based on
View
21 docs/user/pir/pmcs.pod
@@ -60,7 +60,6 @@ several interesting and useful PMC types:
Iterator iterate over aggregates such as arrays or hashes
Array A generic, resizable array
Hash A generic, resizable hash
- Random Obtain a random number
String Similar to a string register but in PMC form
Integer Similar to an int register but in PMC form
Float Similar to a num register but in PMC form
@@ -304,23 +303,7 @@ documentation to find out more about these (and other) PMCs.
A good place to start is the docs directory in the Parrot
distribution (parrot/docs)
-=head3 Example 7: Output random numbers
-
-=begin PIR
-
- .sub _ :main
- $P0 = new 'Random'
- $N0 = $P0
- print $N0
- print "\n"
- $N0 = $P0
- print $N0
- print "\n"
- .end
-
-=end PIR
-
-=head3 Example 8: Triggering an exception
+=head3 Example 7: Triggering an exception
=begin PIR
@@ -332,7 +315,7 @@ distribution (parrot/docs)
=end PIR
-=head3 Example 9: Setting a timer
+=head3 Example 8: Setting a timer
=begin PIR
View
4 editor/pir-mode.el
@@ -1,5 +1,5 @@
;;; pir-mode.el --- pir-mode.el --- editing IMCC source files under Emacs
-
+;;; $Id $
;;; Commentary:
;; This package provides Emacs support for PIR.
@@ -153,7 +153,7 @@ newline or semicolon after an end keyword."
"ManagedStruct" "MultiSub" "NCI" "NameSpace" "Null"
"OS" "Object" "OrderedHash" "PMCProxy" "ParrotClass"
"ParrotIO" "ParrotInterpreter" "ParrotLibrary" "ParrotObject"
- "ParrotRunningThread" "ParrotThread" "Pointer" "Random"
+ "ParrotRunningThread" "ParrotThread" "Pointer"
"ResizableBooleanArray" "ResizableFloatArray" "ResizableIntegerArray"
"ResizablePMCArray" "ResizableStringArray" "RetContinuation"
"Role" "Scalar" "String" "Sub" "Super"
View
55 examples/opengl/shapes.pir
@@ -24,6 +24,7 @@ ASCII key.
=cut
+.loadlib 'math_ops'
.include 'datatypes.pasm'
.include 'opengl_defines.pasm'
@@ -396,31 +397,26 @@ ASCII key.
vy = 0.135
vz = 0.0
- .local pmc random
- .local num rand
- random = new 'Random'
- rand = random
- rand *= .1
- x += rand
- rand = random
- rand *= .1
- y += rand
- rand = random
- rand *= .1
- z += rand
-
- rand = random
- rand -= .5
- rand *= .01
- vx += rand
- rand = random
- rand -= .5
- rand *= .01
- vy += rand
- rand = random
- rand -= .5
- rand *= .01
- vz += rand
+ .local num random
+ random = rand 0, 0.1
+ x += random
+ random = rand 0, 0.1
+ y += random
+ random = rand 0, 0.1
+ z += random
+
+ rand random
+ random -= .5
+ random *= .01
+ vx += random
+ random = random
+ random -= .5
+ random *= .01
+ vy += random
+ random = random
+ random -= .5
+ random *= .01
+ vz += random
.local pmc pos
pos = new 'FixedFloatArray'
@@ -457,12 +453,9 @@ ASCII key.
.local int count
count = pfx_pos
if count > 1000 goto update_particles
- .local pmc random
- .local num rand
- random = new 'Random'
- rand = random
- rand *= 4
- if rand > dt goto update_particles
+ .local num random
+ random = rand 0, 4
+ if random > dt goto update_particles
new_particle(count, pfx_pos, pfx_vel)
# Update all particles
View
7 examples/pir/befunge/flow.pir
@@ -3,6 +3,8 @@
# ** direction changing
+.loadlib 'math_ops'
+
#
# flow__go_east()
#
@@ -69,10 +71,7 @@
# no return value
#
.sub "flow__go_away"
- $P0 = new 'Random'
- $N0 = $P0
- $N0 = $N0 * 4
- $I0 = $N0
+ rand $I0, 0, 4
$P0 = get_global "status"
$P0["dir"] = $I0
set_global "status", $P0
View
4 examples/sdl/tetris/board.pir
@@ -18,6 +18,7 @@ board.pir - a tetris board class.
=cut
.namespace ["Tetris::Board"]
+.loadlib 'math_ops'
.sub __onload :load
$P0 = get_class "Tetris::Board"
@@ -885,8 +886,7 @@ TDB
$I0 = blocks
# get a random block id
- $P0 = new 'Random'
- $N0 = $P0
+ rand $N0
$N0 = $N0 * $I0
id = $N0
View
145 src/pmc/random.pmc
@@ -1,145 +0,0 @@
-/*
-Copyright (C) 2001-2007, Parrot Foundation.
-$Id$
-
-=head1 NAME
-
-src/pmc/random.pmc - Random Numbers
-
-=head1 DESCRIPTION
-
-These are the vtable functions for the Random base class.
-
-This is a singleton (monadic) class - only one instance exists.
-
-=head2 Methods
-
-=over 4
-
-=cut
-
-*/
-
-static PMC *Rand_PMC;
-
-pmclass Random singleton {
-
-/*
-
-=item C<void class_init()>
-
-Class initialization. Clears the singleton PMC.
-
-=cut
-
-*/
-
- void class_init() {
- Rand_PMC = NULL;
- }
-
-/*
-
-=item C<void *get_pointer()>
-
-=cut
-
-*/
-
- VTABLE void *get_pointer() {
- return Rand_PMC;
- }
-
-/*
-
-=item C<void set_pointer(void *ptr)>
-
-These two functions are part of the singleton creation interface. For more
-information see F<src/pmc.c>.
-
-=cut
-
-*/
-
- VTABLE void set_pointer(void *ptr) {
- PARROT_ASSERT(!Rand_PMC);
- Rand_PMC = (PMC *)ptr;
- }
-
-/*
-
-=item C<void set_integer_native(INTVAL seed)>
-
-Sets the random number seed to C<seed>.
-
-=cut
-
-*/
-
- VTABLE void set_integer_native(INTVAL seed) {
- Parrot_srand(seed);
- }
-
-/*
-
-=item C<INTVAL get_integer()>
-
-Returns a random integer in the range C<-2^31..2^31>.
-
-=cut
-
-*/
-
- VTABLE INTVAL get_integer() {
- return Parrot_int_rand(0);
- }
-
-/*
-
-=item C<INTVAL get_integer_keyed_int(INTVAL max)>
-
-Returns a random integer in the range C<0..max>.
-
-=cut
-
-*/
-
- VTABLE INTVAL get_integer_keyed_int(INTVAL max) {
- return Parrot_range_rand(0, max, 0);
- }
-
-/*
-
-=item C<FLOATVAL get_number()>
-
-Returns a random floating-point number in the range C<0.0..1.0>.
-
-=cut
-
-*/
-
- VTABLE FLOATVAL get_number() {
- return Parrot_float_rand(0);
- }
-
-}
-
-/*
-
-=back
-
-=head1 HISTORY
-
-2003.12.10 first rev by leo.
-
-=cut
-
-*/
-
-
-/*
- * Local variables:
- * c-file-style: "parrot"
- * End:
- * vim: expandtab shiftwidth=4:
- */
View
4 t/op/gc.t
@@ -123,6 +123,9 @@ CODE
1
OUTPUT
+{
+local $TODO = 'this tests singletons but was tied to the now-gone Random PMC';
+
pasm_output_is( <<'CODE', <<OUTPUT, "vanishing slingleton PMC" );
_main:
.const 'Sub' P0 = "_rand"
@@ -152,6 +155,7 @@ err:
CODE
ok
OUTPUT
+}
pir_output_is( <<'CODE', <<OUTPUT, "vanishing return continuation in method calls" );
.sub main :main
View
6 t/pmc/pmc.t
@@ -142,9 +142,9 @@ ok 1
ok 2
OUTPUT
-pasm_output_is( <<'CODE', <<'OUTPUT', "Random PMCs are singletons" );
- new P0, ['Random']
- new P1, ['Random']
+pasm_output_is( <<'CODE', <<'OUTPUT', "Env PMCs are singletons" );
+ new P0, ['Env']
+ new P1, ['Env']
eq_addr P0, P1, ok
print "not the same "
ok: print "ok\n"
View
34 t/pmc/random.t
@@ -1,34 +0,0 @@
-#! parrot
-# Copyright (C) 2001-2008, Parrot Foundation.
-# $Id$
-
-=head1 NAME
-
-t/pmc/random.t - Random numbers
-
-=head1 SYNOPSIS
-
- % prove t/pmc/random.t
-
-=head1 DESCRIPTION
-
-Tests random number generation
-
-=cut
-
-.sub main :main
- .include 'test_more.pir'
-
- plan(2)
-
- new $P0, ['Random']
- ok(1, 'Instantiated Random PMC')
- set $I0, $P0
- ok(1, 'Got (unknown) random int')
-.end
-
-# Local Variables:
-# mode: pir
-# fill-column: 100
-# End:
-# vim: expandtab shiftwidth=4 ft=pir:

0 comments on commit e1f325a

Please sign in to comment.