[svn:parrot] r40557 - in trunk: . docs/pdds docs/user/pir editor examples/opengl examples/pir/befunge examples/sdl/tetris src/pmc t/op t/pmc
dukeleto at svn.parrot.org
dukeleto at svn.parrot.org
Sat Aug 15 10:41:10 UTC 2009
Author: dukeleto
Date: Sat Aug 15 10:41:06 2009
New Revision: 40557
URL: https://trac.parrot.org/parrot/changeset/40557
Log:
[TT #871] Kill the Random PMC
Deleted:
trunk/src/pmc/random.pmc
trunk/t/pmc/random.t
Modified:
trunk/DEPRECATED.pod
trunk/MANIFEST
trunk/PBC_COMPAT
trunk/docs/pdds/pdd17_pmc.pod
trunk/docs/user/pir/pmcs.pod
trunk/editor/pir-mode.el
trunk/examples/opengl/shapes.pir
trunk/examples/pir/befunge/flow.pir
trunk/examples/sdl/tetris/board.pir
trunk/t/op/gc.t
trunk/t/pmc/pmc.t
Modified: trunk/DEPRECATED.pod
==============================================================================
--- trunk/DEPRECATED.pod Sat Aug 15 07:53:01 2009 (r40556)
+++ trunk/DEPRECATED.pod Sat Aug 15 10:41:06 2009 (r40557)
@@ -37,10 +37,6 @@
=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,
Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST Sat Aug 15 07:53:01 2009 (r40556)
+++ trunk/MANIFEST Sat Aug 15 10:41:06 2009 (r40557)
@@ -1445,7 +1445,6 @@
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/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]
Modified: trunk/PBC_COMPAT
==============================================================================
--- trunk/PBC_COMPAT Sat Aug 15 07:53:01 2009 (r40556)
+++ trunk/PBC_COMPAT Sat Aug 15 10:41:06 2009 (r40557)
@@ -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
Modified: trunk/docs/pdds/pdd17_pmc.pod
==============================================================================
--- trunk/docs/pdds/pdd17_pmc.pod Sat Aug 15 07:53:01 2009 (r40556)
+++ trunk/docs/pdds/pdd17_pmc.pod Sat Aug 15 10:41:06 2009 (r40557)
@@ -1703,11 +1703,6 @@
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
Modified: trunk/docs/user/pir/pmcs.pod
==============================================================================
--- trunk/docs/user/pir/pmcs.pod Sat Aug 15 07:53:01 2009 (r40556)
+++ trunk/docs/user/pir/pmcs.pod Sat Aug 15 10:41:06 2009 (r40557)
@@ -60,7 +60,6 @@
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 @@
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 @@
=end PIR
-=head3 Example 9: Setting a timer
+=head3 Example 8: Setting a timer
=begin PIR
Modified: trunk/editor/pir-mode.el
==============================================================================
--- trunk/editor/pir-mode.el Sat Aug 15 07:53:01 2009 (r40556)
+++ trunk/editor/pir-mode.el Sat Aug 15 10:41:06 2009 (r40557)
@@ -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 @@
"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"
Modified: trunk/examples/opengl/shapes.pir
==============================================================================
--- trunk/examples/opengl/shapes.pir Sat Aug 15 07:53:01 2009 (r40556)
+++ trunk/examples/opengl/shapes.pir Sat Aug 15 10:41:06 2009 (r40557)
@@ -24,6 +24,7 @@
=cut
+.loadlib 'math_ops'
.include 'datatypes.pasm'
.include 'opengl_defines.pasm'
@@ -396,31 +397,26 @@
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 @@
.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
Modified: trunk/examples/pir/befunge/flow.pir
==============================================================================
--- trunk/examples/pir/befunge/flow.pir Sat Aug 15 07:53:01 2009 (r40556)
+++ trunk/examples/pir/befunge/flow.pir Sat Aug 15 10:41:06 2009 (r40557)
@@ -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
Modified: trunk/examples/sdl/tetris/board.pir
==============================================================================
--- trunk/examples/sdl/tetris/board.pir Sat Aug 15 07:53:01 2009 (r40556)
+++ trunk/examples/sdl/tetris/board.pir Sat Aug 15 10:41:06 2009 (r40557)
@@ -18,6 +18,7 @@
=cut
.namespace ["Tetris::Board"]
+.loadlib 'math_ops'
.sub __onload :load
$P0 = get_class "Tetris::Board"
@@ -885,8 +886,7 @@
$I0 = blocks
# get a random block id
- $P0 = new 'Random'
- $N0 = $P0
+ rand $N0
$N0 = $N0 * $I0
id = $N0
Deleted: trunk/src/pmc/random.pmc
==============================================================================
--- trunk/src/pmc/random.pmc Sat Aug 15 10:41:06 2009 (r40556)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -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:
- */
Modified: trunk/t/op/gc.t
==============================================================================
--- trunk/t/op/gc.t Sat Aug 15 07:53:01 2009 (r40556)
+++ trunk/t/op/gc.t Sat Aug 15 10:41:06 2009 (r40557)
@@ -123,6 +123,9 @@
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 @@
CODE
ok
OUTPUT
+}
pir_output_is( <<'CODE', <<OUTPUT, "vanishing return continuation in method calls" );
.sub main :main
Modified: trunk/t/pmc/pmc.t
==============================================================================
--- trunk/t/pmc/pmc.t Sat Aug 15 07:53:01 2009 (r40556)
+++ trunk/t/pmc/pmc.t Sat Aug 15 10:41:06 2009 (r40557)
@@ -142,9 +142,9 @@
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"
Deleted: trunk/t/pmc/random.t
==============================================================================
--- trunk/t/pmc/random.t Sat Aug 15 10:41:06 2009 (r40556)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -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:
More information about the parrot-commits
mailing list