diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index d5ca301fb..9d59f2c33 100644 --- a/Configuration/GlobalAssemblyInfo.cs +++ b/Configuration/GlobalAssemblyInfo.cs @@ -15,7 +15,7 @@ internal static class RevisionClass public const string Major = "3"; public const string Minor = "9"; public const string Build = "0"; - public const string Revision = "3299"; + public const string Revision = "3305"; public const string MainVersion = Major + "." + Minor; public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision; diff --git a/Configuration/Version.defs b/Configuration/Version.defs index dc6d30e3c..716cf6fdd 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ %MINOR%=9 -%REVISION%=3299 +%REVISION%=3305 %COREVERSION%=0 %MAJOR%=3 diff --git a/InstallerSamples/Graphics/GraphWPF/anim4.pas b/InstallerSamples/Graphics/GraphWPF/anim4.pas index 4d2d5a692..4c4b30c82 100644 --- a/InstallerSamples/Graphics/GraphWPF/anim4.pas +++ b/InstallerSamples/Graphics/GraphWPF/anim4.pas @@ -1,7 +1,5 @@ uses GraphWPF; -function RandomReal(a,b: real): real := Random*(b-a)+a; - type BallInfo = auto class x,y,r,dx,dy: real; diff --git a/InstallerSamples/Graphics/GraphWPF/anim5.pas b/InstallerSamples/Graphics/GraphWPF/anim5.pas index 9dd84de15..801e9863a 100644 --- a/InstallerSamples/Graphics/GraphWPF/anim5.pas +++ b/InstallerSamples/Graphics/GraphWPF/anim5.pas @@ -2,8 +2,6 @@ const vmax = 50; -function RandomReal(a,b: real): real := Random*(b-a)+a; - type BallInfo = auto class x,y,r,vx,vy: real; diff --git a/Release/pabcversion.txt b/Release/pabcversion.txt index 469a78a6d..f2794d66f 100644 --- a/Release/pabcversion.txt +++ b/Release/pabcversion.txt @@ -1 +1 @@ -3.9.0.3299 +3.9.0.3305 diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index b1eb1b6ef..e09acd85d 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.9.0.3299' +!define VERSION '3.9.0.3305' diff --git a/TestSuite/CompilationSamples/PABCSystem.pas b/TestSuite/CompilationSamples/PABCSystem.pas index a05dd9ffe..056dc3c0e 100644 --- a/TestSuite/CompilationSamples/PABCSystem.pas +++ b/TestSuite/CompilationSamples/PABCSystem.pas @@ -1700,6 +1700,8 @@ function Random(maxValue: real): real; function Random(a, b: integer): integer; /// Возвращает случайное вещественное в диапазоне [a,b) function Random(a, b: real): real; +/// Возвращает случайное вещественное в диапазоне [a,b] c количеством значащих цифр после точки, равным digits +function RandomReal(a, b: real; digits: integer := -1): real; /// Возвращает случайный символ в диапазоне от a до b function Random(a, b: char): char; /// Возвращает случайное целое в диапазоне @@ -8509,6 +8511,29 @@ begin Result := a + Random()*(b-a); end; +function RandomReal(a, b: real; digits: integer): real; +begin + if digits<0 then + Result := Random(a,b) + else begin + // Бывают некорректные данные. Например, найти точку с 2 знаками на [2.736, 2.737]. Тогда возвращать a скажем + var step := 1/10**digits; + Result := Round(Random(a,b),digits); + if Result < a then + begin + Result += step; + if Result > b then + Result := b + end + else if Result > b then + begin + Result -= step; + if Result < a then + Result := a; + end; + end; +end; + function Random(diap: IntRange): integer := Random(diap.Low,diap.High); function Random(diap: RealRange): real := Random(diap.Low,diap.High); function Random(diap: CharRange): char := Random(diap.Low,diap.High); diff --git a/TestSuite/CompilationSamples/anim4.pas b/TestSuite/CompilationSamples/anim4.pas index dc2c25ec3..4c4b30c82 100644 --- a/TestSuite/CompilationSamples/anim4.pas +++ b/TestSuite/CompilationSamples/anim4.pas @@ -1,7 +1,5 @@ uses GraphWPF; -//function RandomReal(a,b: real): real := Random*(b-a)+a; - type BallInfo = auto class x,y,r,dx,dy: real; diff --git a/TreeConverter/TreeRealization/type_table.cs b/TreeConverter/TreeRealization/type_table.cs index 17e6b89f8..44782e256 100644 --- a/TreeConverter/TreeRealization/type_table.cs +++ b/TreeConverter/TreeRealization/type_table.cs @@ -571,8 +571,10 @@ namespace PascalABCCompiler.TreeRealization implements = false; // Цикл по всем реализуемым интерфейсам. А если tnode сам является интерфейсом? var ImplementingInterfaces = tnode.ImplementingInterfaces.ToList(); - if (tnode.IsInterface) - ImplementingInterfaces.Add(tnode); + // Из-за этой строки возникла ошибка https://github.com/pascalabcnet/pascalabcnet/issues/2872 + // Но без этой строчки не работает преобразование sequence of Student к sequence of Person и sequence of object + //if (tnode.IsInterface) + // ImplementingInterfaces.Add(tnode); foreach (var interf in ImplementingInterfaces) { var ctn = interf as compiled_type_node; diff --git a/bin/Lib/LightPT.pas b/bin/Lib/LightPT.pas index e103c834d..4c03688ea 100644 --- a/bin/Lib/LightPT.pas +++ b/bin/Lib/LightPT.pas @@ -48,6 +48,8 @@ function Random(n: integer): integer; function Random: real; /// Возвращает случайное вещественное в диапазоне [a,b) function Random(a, b: real): real; +/// Возвращает случайное вещественное в диапазоне [a,b] c количеством значащих цифр после точки, равным digits +function RandomReal(a, b: real; digits: integer := 1): real; /// Возвращает случайный символ в диапазоне от a до b function Random(a, b: char): char; /// Возвращает случайное целое в диапазоне @@ -1029,6 +1031,13 @@ begin InputList.Add(Result); end; +function RandomReal(a, b: real; digits: integer): real; +begin + Result := PABCSystem.RandomReal(a, b, digits); + if IsPT then exit; + InputList.Add(Result); +end; + /// Возвращает случайное целое в диапазоне function Random(diap: IntRange): integer; begin diff --git a/bin/Lib/PABCSystem.pas b/bin/Lib/PABCSystem.pas index d5c1f0ece..056dc3c0e 100644 --- a/bin/Lib/PABCSystem.pas +++ b/bin/Lib/PABCSystem.pas @@ -1701,7 +1701,7 @@ function Random(a, b: integer): integer; /// Возвращает случайное вещественное в диапазоне [a,b) function Random(a, b: real): real; /// Возвращает случайное вещественное в диапазоне [a,b] c количеством значащих цифр после точки, равным digits -function RandomReal(a, b: real; digits: integer := 1): real; +function RandomReal(a, b: real; digits: integer := -1): real; /// Возвращает случайный символ в диапазоне от a до b function Random(a, b: char): char; /// Возвращает случайное целое в диапазоне