summaryrefslogtreecommitdiff
path: root/gcc/ada/a-nuflra.adb
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/a-nuflra.adb
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/a-nuflra.adb')
-rw-r--r--gcc/ada/a-nuflra.adb66
1 files changed, 22 insertions, 44 deletions
diff --git a/gcc/ada/a-nuflra.adb b/gcc/ada/a-nuflra.adb
index 0c62f0fea4b..2c6fbc47f6d 100644
--- a/gcc/ada/a-nuflra.adb
+++ b/gcc/ada/a-nuflra.adb
@@ -29,29 +29,19 @@
-- --
------------------------------------------------------------------------------
-with Interfaces; use Interfaces;
-
-with System.Random_Numbers; use System.Random_Numbers;
-
package body Ada.Numerics.Float_Random is
- -------------------------
- -- Implementation Note --
- -------------------------
+ package SRN renames System.Random_Numbers;
+ use SRN;
- -- The design of this spec is a bit awkward, as a result of Ada 95 not
- -- permitting in-out parameters for function formals (most naturally
- -- Generator values would be passed this way). In pure Ada 95, the only
- -- solution would be to add a self-referential component to the generator
- -- allowing access to the generator object from inside the function. This
- -- would work because the generator is limited, which prevents any copy.
-
- -- This is a bit heavy, so what we do is to use Unrestricted_Access to
- -- get a pointer to the state in the passed Generator. This works because
- -- Generator is a limited type and will thus always be passed by reference.
+ -----------
+ -- Image --
+ -----------
- subtype Rep_Generator is System.Random_Numbers.Generator;
- subtype Rep_State is System.Random_Numbers.State;
+ function Image (Of_State : State) return String is
+ begin
+ return Image (SRN.State (Of_State));
+ end Image;
------------
-- Random --
@@ -59,35 +49,32 @@ package body Ada.Numerics.Float_Random is
function Random (Gen : Generator) return Uniformly_Distributed is
begin
- return Random (Gen.Rep);
+ return Random (SRN.Generator (Gen));
end Random;
-----------
-- Reset --
-----------
- -- Version that works from given initiator value
+ -- Version that works from calendar
- procedure Reset (Gen : Generator; Initiator : Integer) is
- G : Rep_Generator renames Gen.Rep'Unrestricted_Access.all;
+ procedure Reset (Gen : Generator) is
begin
- Reset (G, Integer_32 (Initiator));
+ Reset (SRN.Generator (Gen));
end Reset;
- -- Version that works from calendar
+ -- Version that works from given initiator value
- procedure Reset (Gen : Generator) is
- G : Rep_Generator renames Gen.Rep'Unrestricted_Access.all;
+ procedure Reset (Gen : Generator; Initiator : Integer) is
begin
- Reset (G);
+ Reset (SRN.Generator (Gen), Initiator);
end Reset;
-- Version that works from specific saved state
procedure Reset (Gen : Generator; From_State : State) is
- G : Rep_Generator renames Gen.Rep'Unrestricted_Access.all;
begin
- Reset (G, From_State);
+ Reset (SRN.Generator (Gen), From_State);
end Reset;
----------
@@ -96,28 +83,19 @@ package body Ada.Numerics.Float_Random is
procedure Save (Gen : Generator; To_State : out State) is
begin
- Save (Gen.Rep, State (To_State));
+ Save (SRN.Generator (Gen), To_State);
end Save;
-----------
- -- Image --
- -----------
-
- function Image (Of_State : State) return String is
- begin
- return Image (Rep_State (Of_State));
- end Image;
-
- -----------
-- Value --
-----------
function Value (Coded_State : String) return State is
- G : Generator;
- S : Rep_State;
+ G : SRN.Generator;
+ S : SRN.State;
begin
- Reset (G.Rep, Coded_State);
- System.Random_Numbers.Save (G.Rep, S);
+ Reset (G, Coded_State);
+ Save (G, S);
return State (S);
end Value;