diff options
author | Arnaud Charlet <charlet@adacore.com> | 2020-01-31 05:47:01 -0500 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2020-06-05 08:17:38 -0400 |
commit | c3c80e3c3adde1f96d9f5070eccf1184a97ce2cd (patch) | |
tree | 04376eef14439354af8c1f121015b970afa8f6ac /gcc/ada/libgnat | |
parent | 61fa3fd79ff9bf41651ca99f2f13902e91ca736d (diff) | |
download | gcc-c3c80e3c3adde1f96d9f5070eccf1184a97ce2cd.zip gcc-c3c80e3c3adde1f96d9f5070eccf1184a97ce2cd.tar.gz gcc-c3c80e3c3adde1f96d9f5070eccf1184a97ce2cd.tar.bz2 |
[Ada] AI12-0144 Make Discrete_Random more flexible
2020-06-05 Arnaud Charlet <charlet@adacore.com>
gcc/ada/
* libgnat/a-nudira.ads, libgnat/a-nudira.adb (Random): New
function.
Diffstat (limited to 'gcc/ada/libgnat')
-rw-r--r-- | gcc/ada/libgnat/a-nudira.adb | 11 | ||||
-rw-r--r-- | gcc/ada/libgnat/a-nudira.ads | 6 |
2 files changed, 17 insertions, 0 deletions
diff --git a/gcc/ada/libgnat/a-nudira.adb b/gcc/ada/libgnat/a-nudira.adb index 77f81b4..e18403c 100644 --- a/gcc/ada/libgnat/a-nudira.adb +++ b/gcc/ada/libgnat/a-nudira.adb @@ -56,6 +56,17 @@ is return Random (SRN.Generator (Gen)); end Random; + function Random + (Gen : Generator; + First : Result_Subtype; + Last : Result_Subtype) return Result_Subtype + is + subtype Local_Subtype is Result_Subtype range First .. Last; + function Random is new SRN.Random_Discrete (Local_Subtype, First); + begin + return Random (SRN.Generator (Gen)); + end Random; + ----------- -- Reset -- ----------- diff --git a/gcc/ada/libgnat/a-nudira.ads b/gcc/ada/libgnat/a-nudira.ads index 64342dd..35b7dc6 100644 --- a/gcc/ada/libgnat/a-nudira.ads +++ b/gcc/ada/libgnat/a-nudira.ads @@ -51,6 +51,12 @@ is function Random (Gen : Generator) return Result_Subtype; + function Random + (Gen : Generator; + First : Result_Subtype; + Last : Result_Subtype) return Result_Subtype + with Post => Random'Result in First .. Last; + procedure Reset (Gen : Generator; Initiator : Integer); procedure Reset (Gen : Generator); |