summaryrefslogtreecommitdiff
path: root/gcc/ada/s-rannum.ads
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2010-06-22 17:29:41 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2010-06-22 17:29:41 +0000
commit5d9b4687bb8d1a2d2747dcd2ba70631cfb289c8d (patch)
treef457566fb8fc18443973ce2b98d400affc59113c /gcc/ada/s-rannum.ads
parent1473b207ced691551e6d534710e14193a555323f (diff)
downloadgcc-5d9b4687bb8d1a2d2747dcd2ba70631cfb289c8d.tar.gz
2010-06-22 Robert Dewar <dewar@adacore.com>
* errout.adb (Finalize): Set Prev pointers. (Finalize): Delete continuations for deletion by warnings off(str). * erroutc.ads: Add Prev pointer to error message structure. 2010-06-22 Ed Schonberg <schonberg@adacore.com> * sem.adb (Do_Unit_And_Dependents): If the spec of the main unit is a child unit, examine context of parent units to locate instantiated generics whose bodies may be needed. * sem_ch12.adb: (Mark_Context): if the enclosing unit does not have a with_clause for the instantiated generic, examine the context of its parents, to set Withed_Body flag, so that it can be visited earlier. * exp_ch4.adb (Expand_N_Op_Not): If this is a VMS operator applied to an unsigned type, use a type of the proper size for the intermediate value, to prevent alignment problems on unchecked conversion. 2010-06-22 Geert Bosch <bosch@adacore.com> * s-rannum.ads Change Generator type to be self-referential to allow Random to update its argument. Use "in" mode for the generator in the Reset procedures to allow them to be called from the Ada.Numerics packages without tricks. * s-rannum.adb: Use the self-referencing argument to get write access to the internal state of the random generator. * a-nudira.ads: Make Generator a derived type of System.Random_Numbers.Generator. * a-nudira.adb: Remove use of 'Unrestricted_Access. Put subprograms in alpha order and add headers. * g-mbdira.ads: Change Generator type to be self-referential. * g-mbdira.adb: Remove use of 'Unrestricted_Access. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161215 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/s-rannum.ads')
-rw-r--r--gcc/ada/s-rannum.ads26
1 files changed, 15 insertions, 11 deletions
diff --git a/gcc/ada/s-rannum.ads b/gcc/ada/s-rannum.ads
index c61d86b94c6..b7031d47c6f 100644
--- a/gcc/ada/s-rannum.ads
+++ b/gcc/ada/s-rannum.ads
@@ -88,27 +88,27 @@ package System.Random_Numbers is
-- in Reset). In general, there is little point in providing more than
-- a certain number of values (currently 624).
- procedure Reset (Gen : out Generator);
+ procedure Reset (Gen : Generator);
-- Re-initialize the state of Gen from the time of day
- procedure Reset (Gen : out Generator; Initiator : Initialization_Vector);
- procedure Reset (Gen : out Generator; Initiator : Interfaces.Integer_32);
- procedure Reset (Gen : out Generator; Initiator : Interfaces.Unsigned_32);
- procedure Reset (Gen : out Generator; Initiator : Integer);
+ procedure Reset (Gen : Generator; Initiator : Initialization_Vector);
+ procedure Reset (Gen : Generator; Initiator : Interfaces.Integer_32);
+ procedure Reset (Gen : Generator; Initiator : Interfaces.Unsigned_32);
+ procedure Reset (Gen : Generator; Initiator : Integer);
-- Re-initialize Gen based on the Initiator in various ways. Identical
-- values of Initiator cause identical sequences of values.
- procedure Reset (Gen : out Generator; From_State : Generator);
+ procedure Reset (Gen : Generator; From_State : Generator);
-- Causes the state of Gen to be identical to that of From_State; Gen
-- and From_State will produce identical sequences of values subsequently.
- procedure Reset (Gen : out Generator; From_State : State);
+ procedure Reset (Gen : Generator; From_State : State);
procedure Save (Gen : Generator; To_State : out State);
-- The sequence
-- Save (Gen2, S); Reset (Gen1, S)
-- has the same effect as Reset (Gen2, Gen1).
- procedure Reset (Gen : out Generator; From_Image : String);
+ procedure Reset (Gen : Generator; From_Image : String);
function Image (Gen : Generator) return String;
-- The call
-- Reset (Gen2, Image (Gen1))
@@ -135,11 +135,15 @@ private
subtype State_Val is Interfaces.Unsigned_32;
type State is array (0 .. N - 1) of State_Val;
+ type Writable_Access (Self : access Generator) is limited null record;
+ -- Auxiliary type to make Generator a self-referential type
+
type Generator is limited record
- S : State := (others => 0);
+ Writable : Writable_Access (Generator'Access);
+ -- This self reference allows functions to modify Generator arguments
+ S : State := (others => 0);
-- The shift register, a circular buffer
-
- I : Integer := N;
+ I : Integer := N;
-- Current starting position in shift register S (N means uninitialized)
end record;