diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index ea883be91..2c211ff86 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 = "6"; public const string Build = "2"; - public const string Revision = "2379"; + public const string Revision = "2383"; 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 f4209befd..e2623f2e3 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ %MINOR%=6 -%REVISION%=2379 +%REVISION%=2383 %COREVERSION%=2 %MAJOR%=3 diff --git a/Release/pabcversion.txt b/Release/pabcversion.txt index ec7b1ff54..b8f5211fb 100644 --- a/Release/pabcversion.txt +++ b/Release/pabcversion.txt @@ -1 +1 @@ -3.6.2.2379 +3.6.2.2383 diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index 5b0afd644..3534f08a8 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.6.2.2379' +!define VERSION '3.6.2.2383' diff --git a/TestSuite/CompilationSamples/PABCSystem.pas b/TestSuite/CompilationSamples/PABCSystem.pas index 7b9ea10fd..9712a064b 100644 --- a/TestSuite/CompilationSamples/PABCSystem.pas +++ b/TestSuite/CompilationSamples/PABCSystem.pas @@ -10610,6 +10610,22 @@ begin Self[i, j] := f(i, j); end; +/// Заполняет элементы двумерного массива случайными значениями в диапазоне от a до b +procedure FillRandom(Self: array [,] of integer; a,b: integer); extensionmethod; +begin + for var i := 0 to Self.RowCount - 1 do + for var j := 0 to Self.ColCount - 1 do + Self[i, j] := Random(a,b); +end; + +/// Заполняет элементы двумерного массива случайными значениями в диапазоне от a до b +procedure FillRandom(Self: array [,] of real; a,b: real); extensionmethod; +begin + for var i := 0 to Self.RowCount - 1 do + for var j := 0 to Self.ColCount - 1 do + Self[i, j] := a + Random*(b-a); +end; + /// Применяет действие к каждому элементу двумерного массива procedure &ForEach(Self: array [,] of T; act: T -> ()); extensionmethod; begin @@ -10787,6 +10803,28 @@ end; // Статические методы - в методы расширения: BinarySearch, ConvertAll, Find, FindIndex, FindAll, // FindLast, FindLastIndex, IndexOf, Contains, LastIndexOf, Reverse, Sort +// Дополнения март 2020: RandomElement, FillRandom + +/// Заполняет массив случайными значениями в диапазоне от a до b +procedure FillRandom(Self: array of integer; a,b: integer); extensionmethod; +begin + for var i:=0 to Self.Length-1 do + Self[i] := Random(a,b); +end; + +/// Заполняет массив случайными значениями в диапазоне от a до b +procedure FillRandom(Self: array of real; a,b: real); extensionmethod; +begin + for var i:=0 to Self.Length-1 do + Self[i] := a + Random*(b-a); +end; + +/// Возвращает случайный элемент массива +function RandomElement(Self: array of T): T; extensionmethod; +begin + Result := Self[Random(Self.Length)]; +end; + /// Перемешивает элементы массива случайным образом function Shuffle(Self: array of T): array of T; extensionmethod; begin diff --git a/TestSuite/FunToObj_Overloading.pas b/TestSuite/FunToObj_Overloading.pas new file mode 100644 index 000000000..45e615fc8 --- /dev/null +++ b/TestSuite/FunToObj_Overloading.pas @@ -0,0 +1,9 @@ +function f0(x: byte) := x; + +procedure p1(o: object) := exit; +procedure p1(o: word) := exit; + +begin + p1(f0); + Assert(True) +end. \ No newline at end of file diff --git a/TreeConverter/OpenMP/OpenMP.cs b/TreeConverter/OpenMP/OpenMP.cs index 5d0d5dc96..58f22ddff 100644 --- a/TreeConverter/OpenMP/OpenMP.cs +++ b/TreeConverter/OpenMP/OpenMP.cs @@ -1262,6 +1262,8 @@ namespace PascalABCCompiler.TreeConverter } else if (sem_type.IsEnum) return new PascalABCCompiler.SyntaxTree.named_type_reference(get_idents_from_dot_string(sem_type.name, sem_type.location), sem_type.location); + else if (sem_type is compiled_type_node ctn1 && ctn1.compiled_type == typeof(System.IntPtr)) + return new PascalABCCompiler.SyntaxTree.named_type_reference(get_idents_from_dot_string("System.IntPtr", sem_type.location), sem_type.location); else return new PascalABCCompiler.SyntaxTree.named_type_reference(get_idents_from_dot_string(sem_type.PrintableName, sem_type.location), sem_type.location); } diff --git a/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs b/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs index 73d926625..4d608f4a4 100644 --- a/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs +++ b/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs @@ -1153,23 +1153,21 @@ namespace PascalABCCompiler.TreeConverter } else { - if (is_alone_method_defined) + //issue #2161 - SSM 12.03.2020 + //issue #348 + if (formal_param_type == SystemLibrary.SystemLibrary.object_type && factparams[i].type is delegated_methods) { - //issue #348 - if (formal_param_type == SystemLibrary.SystemLibrary.object_type && factparams[i].type is delegated_methods) - { - possible_type_convertions ptci = new possible_type_convertions(); - ptci.first = null; - ptci.second = null; - ptci.from = factparams[i].type; - ptci.to = formal_param_type; - tc.AddElement(ptci); - factparams[i] = syntax_tree_visitor.CreateDelegateCall((factparams[i].type as delegated_methods).proper_methods[0]); - return tc; - } - else - error = new CanNotConvertTypes(factparams[i], factparams[i].type, formal_param_type, locg); + possible_type_convertions ptci = new possible_type_convertions(); + ptci.first = null; + ptci.second = null; + ptci.from = factparams[i].type; + ptci.to = formal_param_type; + tc.AddElement(ptci); + factparams[i] = syntax_tree_visitor.CreateDelegateCall((factparams[i].type as delegated_methods).proper_methods[0]); + return tc; } + if (is_alone_method_defined) // если мы сюда попали, то ошибка более явная + error = new CanNotConvertTypes(factparams[i], factparams[i].type, formal_param_type, locg); return null; } diff --git a/TreeConverter/TreeRealization/types.cs b/TreeConverter/TreeRealization/types.cs index 7205d16d5..954ff4fa1 100644 --- a/TreeConverter/TreeRealization/types.cs +++ b/TreeConverter/TreeRealization/types.cs @@ -382,7 +382,7 @@ namespace PascalABCCompiler.TreeRealization { get { - return full_name; + return name; } } diff --git a/bin/Lib/PABCSystem.pas b/bin/Lib/PABCSystem.pas index 7b9ea10fd..9712a064b 100644 --- a/bin/Lib/PABCSystem.pas +++ b/bin/Lib/PABCSystem.pas @@ -10610,6 +10610,22 @@ begin Self[i, j] := f(i, j); end; +/// Заполняет элементы двумерного массива случайными значениями в диапазоне от a до b +procedure FillRandom(Self: array [,] of integer; a,b: integer); extensionmethod; +begin + for var i := 0 to Self.RowCount - 1 do + for var j := 0 to Self.ColCount - 1 do + Self[i, j] := Random(a,b); +end; + +/// Заполняет элементы двумерного массива случайными значениями в диапазоне от a до b +procedure FillRandom(Self: array [,] of real; a,b: real); extensionmethod; +begin + for var i := 0 to Self.RowCount - 1 do + for var j := 0 to Self.ColCount - 1 do + Self[i, j] := a + Random*(b-a); +end; + /// Применяет действие к каждому элементу двумерного массива procedure &ForEach(Self: array [,] of T; act: T -> ()); extensionmethod; begin @@ -10787,6 +10803,28 @@ end; // Статические методы - в методы расширения: BinarySearch, ConvertAll, Find, FindIndex, FindAll, // FindLast, FindLastIndex, IndexOf, Contains, LastIndexOf, Reverse, Sort +// Дополнения март 2020: RandomElement, FillRandom + +/// Заполняет массив случайными значениями в диапазоне от a до b +procedure FillRandom(Self: array of integer; a,b: integer); extensionmethod; +begin + for var i:=0 to Self.Length-1 do + Self[i] := Random(a,b); +end; + +/// Заполняет массив случайными значениями в диапазоне от a до b +procedure FillRandom(Self: array of real; a,b: real); extensionmethod; +begin + for var i:=0 to Self.Length-1 do + Self[i] := a + Random*(b-a); +end; + +/// Возвращает случайный элемент массива +function RandomElement(Self: array of T): T; extensionmethod; +begin + Result := Self[Random(Self.Length)]; +end; + /// Перемешивает элементы массива случайным образом function Shuffle(Self: array of T): array of T; extensionmethod; begin