diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index 105c82ae3..c53df5830 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 = "7"; public const string Build = "1"; - public const string Revision = "2764"; + public const string Revision = "2768"; 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 fbc578e14..094db1fd7 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ %COREVERSION%=1 -%REVISION%=2764 +%REVISION%=2768 %MINOR%=7 %MAJOR%=3 diff --git a/InstallerSamples/StandardUnits/PABCSystem/SerializationGraph.pas b/InstallerSamples/StandardUnits/PABCSystem/SerializationGraph.pas new file mode 100644 index 000000000..8ac010c36 --- /dev/null +++ b/InstallerSamples/StandardUnits/PABCSystem/SerializationGraph.pas @@ -0,0 +1,19 @@ +// Сериализация объектов +// Можно сериализовать только объекты, помеченные атрибутом [Serializable] +// Внешние Serialize, Deserialize позволяют сохранить в файле - восстановить +// один объект (один граф объектов с данным корнем) +type + [Serializable] + Node = auto class + x: integer; + next: Node; + end; + +const fname = 'a.dat'; + +begin + var m := new Node(5,new Node(3,new Node(4,nil))); + Serialize(fname,m); // Сериализуем объект в файл + var m1 := Deserialize(fname) as Node; // Десериализуем из файла + Print(m1); +end. \ No newline at end of file diff --git a/InstallerSamples/StandardUnits/PABCSystem/SerializationMany.pas b/InstallerSamples/StandardUnits/PABCSystem/SerializationMany.pas new file mode 100644 index 000000000..c5a2671b0 --- /dev/null +++ b/InstallerSamples/StandardUnits/PABCSystem/SerializationMany.pas @@ -0,0 +1,28 @@ +// Сериализация объектов +// Можно сериализовать только объекты, помеченные атрибутом [Serializable] +// Внешние Serialize, Deserialize позволяют сохранить в файле - восстановить +// один объект (один граф объектов с данным корнем) +type + [Serializable] + My = auto class + x,y: integer; + end; + IntArray = array of integer; + +const fname = 'a.dat'; + +begin + var f := CreateBinary(fname); + f.Serialize(new My(444,555)); + f.Serialize(|1,2,3|); + f.Serialize(Lst(1..9)); + f.Close; + + f := OpenBinary(fname); + var m: My := f.Deserialize as My; + var a: array of integer := f.Deserialize as IntArray; + var l: List := f.Deserialize as List; + f.Close; + + Print(m,a,l); +end. \ No newline at end of file diff --git a/InstallerSamples/StandardUnits/PABCSystem/SerializationOne.pas b/InstallerSamples/StandardUnits/PABCSystem/SerializationOne.pas new file mode 100644 index 000000000..9b395972c --- /dev/null +++ b/InstallerSamples/StandardUnits/PABCSystem/SerializationOne.pas @@ -0,0 +1,18 @@ +// Сериализация объектов +// Можно сериализовать только объекты, помеченные атрибутом [Serializable] +// Внешние Serialize, Deserialize позволяют сохранить в файле - восстановить +// один объект (один граф объектов с данным корнем) +type + [Serializable] + My = auto class + x,y: integer; + end; + +const fname = 'a.dat'; + +begin + var m := new My(2,3); + Serialize(fname,m); // Сериализуем объект в файл + var m1 := Deserialize(fname) as My; // Десериализуем из файла + Print(m1); +end. \ No newline at end of file diff --git a/Release/pabcversion.txt b/Release/pabcversion.txt index 78e99bcd5..a41468fb6 100644 --- a/Release/pabcversion.txt +++ b/Release/pabcversion.txt @@ -1 +1 @@ -3.7.1.2764 +3.7.1.2768 diff --git a/ReleaseGenerators/1049/IlDasmrc.dll b/ReleaseGenerators/1049/IlDasmrc.dll new file mode 100644 index 000000000..3106f1277 Binary files /dev/null and b/ReleaseGenerators/1049/IlDasmrc.dll differ diff --git a/ReleaseGenerators/1049/TrackerUI.dll b/ReleaseGenerators/1049/TrackerUI.dll new file mode 100644 index 000000000..7dab50b31 Binary files /dev/null and b/ReleaseGenerators/1049/TrackerUI.dll differ diff --git a/ReleaseGenerators/1049/flogvwrc.dll b/ReleaseGenerators/1049/flogvwrc.dll new file mode 100644 index 000000000..d8571be6d Binary files /dev/null and b/ReleaseGenerators/1049/flogvwrc.dll differ diff --git a/ReleaseGenerators/1049/gacutlrc.dll b/ReleaseGenerators/1049/gacutlrc.dll new file mode 100644 index 000000000..0cad0c82e Binary files /dev/null and b/ReleaseGenerators/1049/gacutlrc.dll differ diff --git a/ReleaseGenerators/1049/pevrfyrc.dll b/ReleaseGenerators/1049/pevrfyrc.dll new file mode 100644 index 000000000..e0ac385bd Binary files /dev/null and b/ReleaseGenerators/1049/pevrfyrc.dll differ diff --git a/ReleaseGenerators/1049/snrc.dll b/ReleaseGenerators/1049/snrc.dll new file mode 100644 index 000000000..0c6139745 Binary files /dev/null and b/ReleaseGenerators/1049/snrc.dll differ diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index b51f7f199..6d7860ec2 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.7.1.2764' +!define VERSION '3.7.1.2768' diff --git a/SyntaxVisitors/SugarVisitors/TupleVisitor.cs b/SyntaxVisitors/SugarVisitors/TupleVisitor.cs index 31b5d5c66..ec68ff2c6 100644 --- a/SyntaxVisitors/SugarVisitors/TupleVisitor.cs +++ b/SyntaxVisitors/SugarVisitors/TupleVisitor.cs @@ -39,6 +39,15 @@ namespace SyntaxVisitors.SugarVisitors DefaultVisit(ne); } + public override void visit(labeled_statement ls) + { + var sl = new List(); + sl.Add(new labeled_statement(ls.label_name, new empty_statement(), ls.source_context)); + sl.Add(ls.to_statement); + ReplaceStatementUsingParent(ls, sl); + ProcessNode(ls.to_statement); + } + public override void visit(assign_var_tuple assvartup) { if (assvartup.expr is tuple_node tn && tn.el.expressions.All(ex => ex is const_node) && !tn.el.expressions.Any(ex => ex is nil_const)) diff --git a/TestSuite/2363.pas b/TestSuite/2363.pas new file mode 100644 index 000000000..d1dbd02ad --- /dev/null +++ b/TestSuite/2363.pas @@ -0,0 +1,14 @@ +procedure p0(o: T); +begin + //Print(1); +end; + +procedure p1; where T: record; +begin + //Ошибка: Возможны два преобразования типов + p0&(nil); +end; + +begin + Assert(1=1) +end. \ No newline at end of file diff --git a/TestSuite/CompilationSamples/PABCSystem.pas b/TestSuite/CompilationSamples/PABCSystem.pas index ec6b68545..bc2865507 100644 --- a/TestSuite/CompilationSamples/PABCSystem.pas +++ b/TestSuite/CompilationSamples/PABCSystem.pas @@ -253,6 +253,9 @@ type /// Предоставляет методы для точного измерения затраченного времени Stopwatch = System.Diagnostics.Stopwatch; + /// Указывает на возможность сериализации класса + Serializable = System.SerializableAttribute; + /// Представляет тип короткой строки фиксированной длины 255 символов ShortString = string[255]; @@ -586,6 +589,10 @@ type function ReadReal: real; /// Считывает строку из бестипового файла function ReadString: string; + /// Сериализует объект в файл (объект должен иметь атрибут [Serializable]) + procedure Serialize(obj: object); + /// Десериализует объект из файла + function Deserialize: object; end; type @@ -1183,6 +1190,12 @@ procedure Println(params args: array of object); /// Выводит значения a,b,... в текстовый файл f, после каждого значения выводит пробел и переходит на новую строку procedure Println(f: Text; params args: array of object); +/// Сериализует объект в файл (объект должен иметь атрибут [Serializable]) +procedure Serialize(filename: string; obj: object); +/// Десериализует объект из файла +function Deserialize(filename: string): object; + + // ----------------------------------------------------- //>> Общие подпрограммы для работы с файлами # Common subroutines for files // ----------------------------------------------------- @@ -2818,6 +2831,9 @@ function WINAPI_AllocConsole: longword; external 'kernel32.dll' name 'AllocConso var console_alloc: boolean := false; + +type + BinaryFormatter = System.Runtime.Serialization.Formatters.Binary.BinaryFormatter; // ----------------------------------------------------- // Internal functions @@ -6677,6 +6693,18 @@ begin Result := Self.br.ReadString; end; +procedure BinaryFile.Serialize(obj: object); +begin + var formatter := new BinaryFormatter; + formatter.Serialize(fs,obj); +end; + +function BinaryFile.Deserialize: object; +begin + var formatter := new BinaryFormatter; + Result := formatter.Deserialize(fs); +end; + // ----------------------------------------------------- // Eoln - Eof // ----------------------------------------------------- @@ -6997,6 +7025,23 @@ begin Print(f, args); Writeln(f); end; + +procedure Serialize(filename: string; obj: object); +begin + var fs := new System.IO.FileStream(filename,System.IO.FileMode.Create); + var formatter := new BinaryFormatter; + formatter.Serialize(fs,obj); + fs.Close; +end; + +function Deserialize(filename: string): object; +begin + var fs := new System.IO.FileStream(filename,System.IO.FileMode.Open); + var formatter := new BinaryFormatter; + Result := formatter.Deserialize(fs); + fs.Close; +end; + // ----------------------------------------------------- // Text files // ----------------------------------------------------- diff --git a/TestSuite/CompilationSamples/School.pas b/TestSuite/CompilationSamples/School.pas index 28ab17d8c..e563ab2f7 100644 --- a/TestSuite/CompilationSamples/School.pas +++ b/TestSuite/CompilationSamples/School.pas @@ -38,6 +38,12 @@ function MinMax(s: sequence of int64): (int64, int64); /// Возвращает кортеж из минимума и максимума последовательности s function MinMax(s: sequence of integer): (integer, integer); +/// Возвращает кортеж из минимума и максимума последовательности s +function MinMax(s: sequence of real): (real, real); + +/// Возвращает кортеж из минимума и максимума последовательности s +function MinMax(s: sequence of BigInteger): (BigInteger, BigInteger); + /// Возвращает НОД function НОД(a, b: int64): int64; @@ -276,10 +282,12 @@ function MinMax(s: sequence of int64): (int64, int64); begin var (min, max) := (int64.MaxValue, int64.MinValue); foreach var m in s do + begin if m < min then - min := m - else if m > max then - max := m; + min := m; + if m > max then + max := m + end; Result := (min, max) end; @@ -288,10 +296,44 @@ function MinMax(s: sequence of integer): (integer, integer); begin var (min, max) := (integer.MaxValue, integer.MinValue); foreach var m in s do + begin if m < min then - min := m - else if m > max then - max := m; + min := m; + if m > max then + max := m + end; + Result := (min, max) +end; + +/// Возвращает кортеж из минимума и максимума последовательности s +function MinMax(s: sequence of real): (real, real); +begin + var (min, max) := (real.MaxValue, -real.MaxValue); + foreach var m in s do + begin + if m < min then + min := m; + if m > max then + max := m + end; + Result := (min, max) +end; + +/// Возвращает кортеж из минимума и максимума последовательности s +function MinMax(s: sequence of BigInteger): (BigInteger, BigInteger); +begin + var min, max: BigInteger; + var FirstValue := True; + foreach var m in s do + if FirstValue then + (min, max, FirstValue) := (m, m, False) + else + begin + if m < min then + min := m; + if m > max then + max := m + end; Result := (min, max) end; @@ -302,7 +344,15 @@ MinMax(Self); /// Возвращает кортеж из минимума и максимума последовательности function MinMax(Self: sequence of integer): (integer, integer); extensionmethod := -MinMax(Self); +MinMax(Self); + +/// Возвращает кортеж из минимума и максимума последовательности +function MinMax(Self: sequence of real): (real, real); extensionmethod := +MinMax(Self); + +/// Возвращает кортеж из минимума и максимума последовательности +function MinMax(Self: sequence of BigInteger): (BigInteger, BigInteger); +extensionmethod := MinMax(Self); {$endregion} diff --git a/TestSuite/label_ass_var_tuple.pas b/TestSuite/label_ass_var_tuple.pas new file mode 100644 index 000000000..cfa9cbf79 --- /dev/null +++ b/TestSuite/label_ass_var_tuple.pas @@ -0,0 +1,8 @@ +label 1; +begin + var c := 1; + 1: + var (a,b) := (1,1); + b := 1; + Assert(b=1); +end. \ No newline at end of file diff --git a/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs b/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs index 02bbbf85f..d667f86b6 100644 --- a/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs +++ b/TreeConverter/TreeConversion/convertion_data_and_alghoritms.cs @@ -1667,6 +1667,8 @@ namespace PascalABCCompiler.TreeConverter { if (ptc.second!=null) { + if (ptc.first.from is null_type_node || ptc.second.from is null_type_node) + continue; // SSM 9/12/20 fix 2363 AddError(new PossibleTwoTypeConversionsInFunctionCall(loc,ptc.first,ptc.second)); } diff --git a/bin/Lib/PABCSystem.pas b/bin/Lib/PABCSystem.pas index ec6b68545..bc2865507 100644 --- a/bin/Lib/PABCSystem.pas +++ b/bin/Lib/PABCSystem.pas @@ -253,6 +253,9 @@ type /// Предоставляет методы для точного измерения затраченного времени Stopwatch = System.Diagnostics.Stopwatch; + /// Указывает на возможность сериализации класса + Serializable = System.SerializableAttribute; + /// Представляет тип короткой строки фиксированной длины 255 символов ShortString = string[255]; @@ -586,6 +589,10 @@ type function ReadReal: real; /// Считывает строку из бестипового файла function ReadString: string; + /// Сериализует объект в файл (объект должен иметь атрибут [Serializable]) + procedure Serialize(obj: object); + /// Десериализует объект из файла + function Deserialize: object; end; type @@ -1183,6 +1190,12 @@ procedure Println(params args: array of object); /// Выводит значения a,b,... в текстовый файл f, после каждого значения выводит пробел и переходит на новую строку procedure Println(f: Text; params args: array of object); +/// Сериализует объект в файл (объект должен иметь атрибут [Serializable]) +procedure Serialize(filename: string; obj: object); +/// Десериализует объект из файла +function Deserialize(filename: string): object; + + // ----------------------------------------------------- //>> Общие подпрограммы для работы с файлами # Common subroutines for files // ----------------------------------------------------- @@ -2818,6 +2831,9 @@ function WINAPI_AllocConsole: longword; external 'kernel32.dll' name 'AllocConso var console_alloc: boolean := false; + +type + BinaryFormatter = System.Runtime.Serialization.Formatters.Binary.BinaryFormatter; // ----------------------------------------------------- // Internal functions @@ -6677,6 +6693,18 @@ begin Result := Self.br.ReadString; end; +procedure BinaryFile.Serialize(obj: object); +begin + var formatter := new BinaryFormatter; + formatter.Serialize(fs,obj); +end; + +function BinaryFile.Deserialize: object; +begin + var formatter := new BinaryFormatter; + Result := formatter.Deserialize(fs); +end; + // ----------------------------------------------------- // Eoln - Eof // ----------------------------------------------------- @@ -6997,6 +7025,23 @@ begin Print(f, args); Writeln(f); end; + +procedure Serialize(filename: string; obj: object); +begin + var fs := new System.IO.FileStream(filename,System.IO.FileMode.Create); + var formatter := new BinaryFormatter; + formatter.Serialize(fs,obj); + fs.Close; +end; + +function Deserialize(filename: string): object; +begin + var fs := new System.IO.FileStream(filename,System.IO.FileMode.Open); + var formatter := new BinaryFormatter; + Result := formatter.Deserialize(fs); + fs.Close; +end; + // ----------------------------------------------------- // Text files // ----------------------------------------------------- diff --git a/bin/Lib/School.pas b/bin/Lib/School.pas index 28ab17d8c..e563ab2f7 100644 --- a/bin/Lib/School.pas +++ b/bin/Lib/School.pas @@ -38,6 +38,12 @@ function MinMax(s: sequence of int64): (int64, int64); /// Возвращает кортеж из минимума и максимума последовательности s function MinMax(s: sequence of integer): (integer, integer); +/// Возвращает кортеж из минимума и максимума последовательности s +function MinMax(s: sequence of real): (real, real); + +/// Возвращает кортеж из минимума и максимума последовательности s +function MinMax(s: sequence of BigInteger): (BigInteger, BigInteger); + /// Возвращает НОД function НОД(a, b: int64): int64; @@ -276,10 +282,12 @@ function MinMax(s: sequence of int64): (int64, int64); begin var (min, max) := (int64.MaxValue, int64.MinValue); foreach var m in s do + begin if m < min then - min := m - else if m > max then - max := m; + min := m; + if m > max then + max := m + end; Result := (min, max) end; @@ -288,10 +296,44 @@ function MinMax(s: sequence of integer): (integer, integer); begin var (min, max) := (integer.MaxValue, integer.MinValue); foreach var m in s do + begin if m < min then - min := m - else if m > max then - max := m; + min := m; + if m > max then + max := m + end; + Result := (min, max) +end; + +/// Возвращает кортеж из минимума и максимума последовательности s +function MinMax(s: sequence of real): (real, real); +begin + var (min, max) := (real.MaxValue, -real.MaxValue); + foreach var m in s do + begin + if m < min then + min := m; + if m > max then + max := m + end; + Result := (min, max) +end; + +/// Возвращает кортеж из минимума и максимума последовательности s +function MinMax(s: sequence of BigInteger): (BigInteger, BigInteger); +begin + var min, max: BigInteger; + var FirstValue := True; + foreach var m in s do + if FirstValue then + (min, max, FirstValue) := (m, m, False) + else + begin + if m < min then + min := m; + if m > max then + max := m + end; Result := (min, max) end; @@ -302,7 +344,15 @@ MinMax(Self); /// Возвращает кортеж из минимума и максимума последовательности function MinMax(Self: sequence of integer): (integer, integer); extensionmethod := -MinMax(Self); +MinMax(Self); + +/// Возвращает кортеж из минимума и максимума последовательности +function MinMax(Self: sequence of real): (real, real); extensionmethod := +MinMax(Self); + +/// Возвращает кортеж из минимума и максимума последовательности +function MinMax(Self: sequence of BigInteger): (BigInteger, BigInteger); +extensionmethod := MinMax(Self); {$endregion}