From 03be5bd931b57072807e2664ab512eb2bac0add4 Mon Sep 17 00:00:00 2001 From: Mikhalkovich Stanislav Date: Wed, 13 Nov 2024 22:13:41 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D1=81=D1=82=D0=B0?= =?UTF-8?q?=D0=B2=D0=B8=D0=BB=20operator:=3D=20=D0=B2=20NewSet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Configuration/GlobalAssemblyInfo.cs | 2 +- Configuration/Version.defs | 2 +- Release/pabcversion.txt | 2 +- ReleaseGenerators/PascalABCNET_version.nsh | 2 +- .../CompilationSamples/PABCExtensions.pas | 104 +++++++++--------- TestSuite/CompilationSamples/PABCSystem.pas | 69 +++++++----- .../TreeConversion/syntax_tree_visitor.cs | 1 - _RebuildReleaseAndBuildUnits.bat | 4 +- bin/Lib/PABCExtensions.pas | 4 +- bin/Lib/PABCSystem.pas | 27 +++-- 10 files changed, 117 insertions(+), 100 deletions(-) diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index 87924b03a..1932c640d 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 = "10"; public const string Build = "0"; - public const string Revision = "3559"; + public const string Revision = "3565"; 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 94352b456..524cea035 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ %MINOR%=10 -%REVISION%=3559 +%REVISION%=3565 %COREVERSION%=0 %MAJOR%=3 diff --git a/Release/pabcversion.txt b/Release/pabcversion.txt index 9248cae42..ff3cb138c 100644 --- a/Release/pabcversion.txt +++ b/Release/pabcversion.txt @@ -1 +1 @@ -3.10.0.3559 +3.10.0.3565 diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index e0d2e5384..44353f83c 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.10.0.3559' +!define VERSION '3.10.0.3565' diff --git a/TestSuite/CompilationSamples/PABCExtensions.pas b/TestSuite/CompilationSamples/PABCExtensions.pas index eafb49eb0..78ab568ac 100644 --- a/TestSuite/CompilationSamples/PABCExtensions.pas +++ b/TestSuite/CompilationSamples/PABCExtensions.pas @@ -455,10 +455,10 @@ begin end; // Важнейший для новых множеств !!! -procedure operator:=(var Self: NewSet; st: NewSet); extensionmethod; +{procedure operator:=(var Self: NewSet; st: NewSet); extensionmethod; begin - Self._hs := new HashSet(st.hs); -end; + Self.hs := new HashSet(st.hs); +end;} {procedure operator:=(var Self: NewSet; st: NewSetEmpty); extensionmethod; begin @@ -468,89 +468,89 @@ end;} // Extension-методы для новых множеств function operator implicit(n: NewSet): NewSet; extensionmethod; begin - foreach var x in n._hs do + foreach var x in n.hs do if (x >= byte.MinValue) and (x <= byte.MaxValue) then - Result._hs.Add(x) + Result.hs.Add(x) else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT)); end; function operator implicit(n: NewSet): NewSet; extensionmethod; begin - foreach var x in n._hs do + foreach var x in n.hs do if (x >= shortint.MinValue) and (x <= shortint.MaxValue) then - Result._hs.Add(x) + Result.hs.Add(x) else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT)); end; function operator implicit(n: NewSet): NewSet; extensionmethod; begin - foreach var x in n._hs do + foreach var x in n.hs do if (x >= smallint.MinValue) and (x <= smallint.MaxValue) then - Result._hs.Add(x) + Result.hs.Add(x) else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT)); end; function operator implicit(n: NewSet): NewSet; extensionmethod; begin - foreach var x in n._hs do + foreach var x in n.hs do if (x >= word.MinValue) and (x <= word.MaxValue) then - Result._hs.Add(x) + Result.hs.Add(x) else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT)); end; function operator implicit(n: NewSet): NewSet; extensionmethod; begin - foreach var x in n._hs do + foreach var x in n.hs do if (x >= longword.MinValue) and (x <= longword.MaxValue) then - Result._hs.Add(x) + Result.hs.Add(x) else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT)); end; function operator implicit(n: NewSet): NewSet; extensionmethod; begin - foreach var x in n._hs do - Result._hs.Add(x) + foreach var x in n.hs do + Result.hs.Add(x) end; function operator implicit(n: NewSet): NewSet; extensionmethod; begin - foreach var x in n._hs do + foreach var x in n.hs do if x >= 0 then - Result._hs.Add(x) + Result.hs.Add(x) else raise new System.ArgumentException(GetTranslation(OUT_OF_TYPE_RANGE_IN_SET_ASSIGNMENT)); end; -function NSToInts(ns: NewSet) := ns._hs.Select(x -> integer(x)); -function NSToInts(ns: NewSet) := ns._hs.Select(x -> integer(x)); -function NSToInts(ns: NewSet) := ns._hs.Select(x -> integer(x)); -function NSToInts(ns: NewSet) := ns._hs.Select(x -> integer(x)); +function NSToInts(ns: NewSet) := ns.hs.Select(x -> integer(x)); +function NSToInts(ns: NewSet) := ns.hs.Select(x -> integer(x)); +function NSToInts(ns: NewSet) := ns.hs.Select(x -> integer(x)); +function NSToInts(ns: NewSet) := ns.hs.Select(x -> integer(x)); //function NSToInts(ns: NewSet) := ns._hs.Select(x -> integer(x)); //function NSToInts(ns: NewSet) := ns._hs.Select(x -> integer(x)); -function NSToInts64(ns: NewSet) := ns._hs.Select(x -> int64(x)); -function NSToInts64(ns: NewSet) := ns._hs.Select(x -> int64(x)); -function NSToBytes(ns: NewSet) := ns._hs.Select(x -> byte(x)); -function NSToBytes(ns: NewSet) := ns._hs.Select(x -> byte(x)); +function NSToInts64(ns: NewSet) := ns.hs.Select(x -> int64(x)); +function NSToInts64(ns: NewSet) := ns.hs.Select(x -> int64(x)); +function NSToBytes(ns: NewSet) := ns.hs.Select(x -> byte(x)); +function NSToBytes(ns: NewSet) := ns.hs.Select(x -> byte(x)); // Надо set of integer со всеми -function operator=(a: NewSet; b: NewSet); extensionmethod := a._hs.SetEquals(NSToInts(b)); +function operator=(a: NewSet; b: NewSet); extensionmethod := a.hs.SetEquals(NSToInts(b)); function operator=(a: NewSet; b: NewSet): boolean; extensionmethod := b = a; -function operator=(a: NewSet; b: NewSet); extensionmethod := a._hs.SetEquals(NSToInts(b)); +function operator=(a: NewSet; b: NewSet); extensionmethod := a.hs.SetEquals(NSToInts(b)); function operator=(a: NewSet; b: NewSet): boolean; extensionmethod := b = a; -function operator=(a: NewSet; b: NewSet); extensionmethod := a._hs.SetEquals(NSToInts(b)); +function operator=(a: NewSet; b: NewSet); extensionmethod := a.hs.SetEquals(NSToInts(b)); function operator=(a: NewSet; b: NewSet): boolean; extensionmethod := b = a; -function operator=(a: NewSet; b: NewSet); extensionmethod := a._hs.SetEquals(NSToInts(b)); +function operator=(a: NewSet; b: NewSet); extensionmethod := a.hs.SetEquals(NSToInts(b)); function operator=(a: NewSet; b: NewSet): boolean; extensionmethod := b = a; // В этом случае integer и longword не вкладываются друг в друга function operator=(a: NewSet; b: NewSet): boolean; extensionmethod; begin var hsInt64: HashSet; - hsInt64 := new HashSet(b._hs.Select(x -> int64(x))); - Result := hsInt64.SetEquals(a._hs.Select(x -> int64(x))); + hsInt64 := new HashSet(b.hs.Select(x -> int64(x))); + Result := hsInt64.SetEquals(a.hs.Select(x -> int64(x))); end; function operator=(a: NewSet; b: NewSet): boolean; extensionmethod := b = a; -function operator=(a: NewSet; b: NewSet); extensionmethod := a._hs.SetEquals(NSToInts64(b)); +function operator=(a: NewSet; b: NewSet); extensionmethod := a.hs.SetEquals(NSToInts64(b)); function operator=(a: NewSet; b: NewSet): boolean; extensionmethod := b = a; // Здесь оба типа нельзя расширить до общего типа, и есть проблема @@ -582,43 +582,43 @@ function operator<>(a: NewSet; b: NewSet); extensionmethod := no function operator<>(a: NewSet; b: NewSet); extensionmethod := not(a = b); function operator<>(a: NewSet; b: NewSet); extensionmethod := not(a = b); -function operator<(a: NewSet; b: NewSet); extensionmethod := a._hs.IsProperSubsetOf(NSToInts(b)); +function operator<(a: NewSet; b: NewSet); extensionmethod := a.hs.IsProperSubsetOf(NSToInts(b)); function operator<(a: NewSet; b: NewSet); extensionmethod := b > a; -function operator<(a: NewSet; b: NewSet); extensionmethod := a._hs.IsProperSubsetOf(NSToInts64(b)); +function operator<(a: NewSet; b: NewSet); extensionmethod := a.hs.IsProperSubsetOf(NSToInts64(b)); function operator<(a: NewSet; b: NewSet); extensionmethod := b > a; -function operator>(a: NewSet; b: NewSet); extensionmethod := a._hs.IsProperSupersetOf(NSToInts(b)); +function operator>(a: NewSet; b: NewSet); extensionmethod := a.hs.IsProperSupersetOf(NSToInts(b)); function operator>(a: NewSet; b: NewSet); extensionmethod := b < a; -function operator>(a: NewSet; b: NewSet); extensionmethod := a._hs.IsProperSupersetOf(NSToInts64(b)); +function operator>(a: NewSet; b: NewSet); extensionmethod := a.hs.IsProperSupersetOf(NSToInts64(b)); function operator>(a: NewSet; b: NewSet); extensionmethod := b < a; -function operator<=(a: NewSet; b: NewSet); extensionmethod := a._hs.IsSubsetOf(NSToInts(b)); +function operator<=(a: NewSet; b: NewSet); extensionmethod := a.hs.IsSubsetOf(NSToInts(b)); function operator<=(a: NewSet; b: NewSet); extensionmethod := b >= a; -function operator<=(a: NewSet; b: NewSet); extensionmethod := a._hs.IsSubsetOf(NSToInts64(b)); +function operator<=(a: NewSet; b: NewSet); extensionmethod := a.hs.IsSubsetOf(NSToInts64(b)); function operator<=(a: NewSet; b: NewSet); extensionmethod := b >= a; -function operator>=(a: NewSet; b: NewSet); extensionmethod := a._hs.IsSupersetOf(NSToInts(b)); +function operator>=(a: NewSet; b: NewSet); extensionmethod := a.hs.IsSupersetOf(NSToInts(b)); function operator>=(a: NewSet; b: NewSet); extensionmethod := b <= a; -function operator>=(a: NewSet; b: NewSet); extensionmethod := a._hs.IsSupersetOf(NSToInts64(b)); +function operator>=(a: NewSet; b: NewSet); extensionmethod := a.hs.IsSupersetOf(NSToInts64(b)); function operator>=(a: NewSet; b: NewSet); extensionmethod := b <= a; -procedure operator*=(var a: NewSet; b: NewSet); extensionmethod := a._hs.IntersectWith(NSToBytes(b)); -procedure operator*=(var a: NewSet; b: NewSet); extensionmethod := a._hs.IntersectWith(NSToInts(b)); -procedure operator*=(var a: NewSet; b: NewSet); extensionmethod := a._hs.IntersectWith(NSToInts64(b)); +procedure operator*=(var a: NewSet; b: NewSet); extensionmethod := a.hs.IntersectWith(NSToBytes(b)); +procedure operator*=(var a: NewSet; b: NewSet); extensionmethod := a.hs.IntersectWith(NSToInts(b)); +procedure operator*=(var a: NewSet; b: NewSet); extensionmethod := a.hs.IntersectWith(NSToInts64(b)); //procedure operator*=(var a: NewSet; b: NewSet); extensionmethod := a._hs.IntersectWith(NSToInts(b)); //procedure operator*=(var a: NewSet; b: NewSet); extensionmethod := a._hs.IntersectWith(NSToBytes(b)); //procedure operator*=(var a: NewSet; b: NewSet); extensionmethod := a._hs.IntersectWith(NSToInts64(b)); -procedure operator+=(var a: NewSet; b: NewSet); extensionmethod := a._hs.UnionWith(NSToBytes(b)); -procedure operator+=(var a: NewSet; b: NewSet); extensionmethod := a._hs.UnionWith(NSToInts(b)); -procedure operator+=(var a: NewSet; b: NewSet); extensionmethod := a._hs.UnionWith(NSToInts64(b)); +procedure operator+=(var a: NewSet; b: NewSet); extensionmethod := a.hs.UnionWith(NSToBytes(b)); +procedure operator+=(var a: NewSet; b: NewSet); extensionmethod := a.hs.UnionWith(NSToInts(b)); +procedure operator+=(var a: NewSet; b: NewSet); extensionmethod := a.hs.UnionWith(NSToInts64(b)); //procedure operator+=(var a: NewSet; b: NewSet); extensionmethod := a._hs.UnionWith(NSToInts(b)); -procedure operator+=(var a: NewSet; b: NewSet); extensionmethod := a._hs.UnionWith(NSToBytes(b)); -procedure operator+=(var a: NewSet; b: NewSet); extensionmethod := a._hs.UnionWith(NSToInts64(b)); +procedure operator+=(var a: NewSet; b: NewSet); extensionmethod := a.hs.UnionWith(NSToBytes(b)); +procedure operator+=(var a: NewSet; b: NewSet); extensionmethod := a.hs.UnionWith(NSToInts64(b)); -procedure operator-=(var a: NewSet; b: NewSet); extensionmethod := a._hs.ExceptWith(NSToBytes(b)); -procedure operator-=(var a: NewSet; b: NewSet); extensionmethod := a._hs.ExceptWith(NSToInts(b)); -procedure operator-=(var a: NewSet; b: NewSet); extensionmethod := a._hs.ExceptWith(NSToInts64(b)); +procedure operator-=(var a: NewSet; b: NewSet); extensionmethod := a.hs.ExceptWith(NSToBytes(b)); +procedure operator-=(var a: NewSet; b: NewSet); extensionmethod := a.hs.ExceptWith(NSToInts(b)); +procedure operator-=(var a: NewSet; b: NewSet); extensionmethod := a.hs.ExceptWith(NSToInts64(b)); //procedure operator-=(var a: NewSet; b: NewSet); extensionmethod := a._hs.ExceptWith(NSToInts(b)); @@ -686,7 +686,7 @@ begin end; // и для массивов столько же -function operator=(a: NewSet; b: array of byte); extensionmethod := a._hs.SetEquals(b.Select(x -> integer(x))); +function operator=(a: NewSet; b: array of byte); extensionmethod := a.hs.SetEquals(b.Select(x -> integer(x))); function operator=(a: array of byte; b: NewSet): boolean; extensionmethod := b = a; function operator=(a: array of int64; b: NewSet); extensionmethod := a.ToHashSet.SetEquals(NSToInts64(b)); function operator=(a: NewSet; b: array of int64): boolean; extensionmethod := b = a; diff --git a/TestSuite/CompilationSamples/PABCSystem.pas b/TestSuite/CompilationSamples/PABCSystem.pas index a1fd541b4..3be1c8f8c 100644 --- a/TestSuite/CompilationSamples/PABCSystem.pas +++ b/TestSuite/CompilationSamples/PABCSystem.pas @@ -483,19 +483,21 @@ type end;} type + NewSetEmpty = class; + /// Тип нового встроенного множества NewSet = record(IEnumerable) private public ///-- - _hs := new HashSet; + hs := new HashSet; ///-- - function hs: HashSet; + {function hs: HashSet; begin if _hs = nil then _hs := new HashSet; Result := _hs; - end; + end;} constructor (params a: array of T); begin hs.UnionWith(a); @@ -504,7 +506,7 @@ type function System.Collections.IEnumerable.GetEnumerator: System.Collections.IEnumerator := GetEnumerator; static function operator implicit(a: array of T): NewSet; begin - Result._hs := new HashSet(a); + Result.hs := new HashSet(a); end; function ToString: string; override; function Count: integer := hs.Count; @@ -545,12 +547,17 @@ type static function operator implicit(ns: HashSet): NewSet; begin Result.hs.UnionWith(ns); - end; + end; + + static function operator implicit(ns: NewSetEmpty): NewSet; begin end; + static function operator:=(var Self: NewSet; st: NewSet): NewSet; + begin + Self.hs := new HashSet(st.hs); + end; end; - NewSetEmpty = record - static function operator implicit(ns: NewSetEmpty): NewSet; begin end; - + NewSetEmpty = class + public static function operator=(s1: NewSet; s2: NewSetEmpty): boolean := s1.Count = 0; static function operator=(s2: NewSetEmpty; s1: NewSet): boolean := s1.Count = 0; static function operator<>(s1: NewSet; s2: NewSetEmpty): boolean := not (s1 = s2); @@ -565,16 +572,16 @@ type static function operator<=(s2: NewSetEmpty; s1: NewSet): boolean := s1.Count >= 0; // ToDo: определить то же для массивов на будущее - static function operator+(first, second: NewSetEmpty): NewSetEmpty; begin end; - static function operator-(first, second: NewSetEmpty): NewSetEmpty; begin end; - static function operator*(first, second: NewSetEmpty): NewSetEmpty; begin end; + static function operator+(first, second: NewSetEmpty): NewSetEmpty := new NewSetEmpty; + static function operator-(first, second: NewSetEmpty): NewSetEmpty := new NewSetEmpty; + static function operator*(first, second: NewSetEmpty): NewSetEmpty := new NewSetEmpty; static function operator+(first: NewSetEmpty; second: array of T): NewSet; begin - Result._hs.UnionWith(second); + Result.hs.UnionWith(second); end; static function operator+(first: array of T; second: NewSetEmpty): NewSet; begin - Result._hs.UnionWith(first); + Result.hs.UnionWith(first); end; static function operator+(first: NewSet; second: NewSetEmpty): NewSet := first; static function operator+(first: NewSetEmpty; second: NewSet): NewSet := second; @@ -588,7 +595,7 @@ type static function operator-(first: NewSetEmpty; second: array of T): NewSet; begin end; static function operator-(first: array of T; second: NewSetEmpty): NewSet; begin - Result._hs.UnionWith(first); + Result.hs.UnionWith(first); end; function ToString: string; override := '{}'; function ToSet(): NewSet; begin end; @@ -602,7 +609,7 @@ type Result := new HashSet; end; end; - + type // Вспомогательный тип для множества ///-- @@ -15395,7 +15402,7 @@ end;} // Присваивание реализовано в PABCExtensions. Здесь не работает -var _emptyset: NewSetEmpty; +var _emptyset: NewSetEmpty := new NewSetEmpty; type SetCreatorFunctionAttribute = class(Attribute) @@ -15406,14 +15413,14 @@ function EmptySet := _emptyset; [SetCreatorFunction] function __NewSetCreatorInternal(params a: array of T): NewSet; begin - Result._hs := new HashSet; - Result._hs.UnionWith(a); + Result.hs := new HashSet; + Result.hs.UnionWith(a); end; [SetCreatorFunction] function __NSetInteger(a: array of integer; dd: array of integer): NewSet; begin - Result._hs.UnionWith(a); + Result.hs.UnionWith(a); var n := dd.Length; for var i:=0 to n-1 step 2 do begin @@ -15425,7 +15432,7 @@ end; [SetCreatorFunction] function __NSetChar(a: array of char; dd: array of char): NewSet; begin - Result._hs.UnionWith(a); + Result.hs.UnionWith(a); var n := dd.Length; for var i:=0 to n-1 step 2 do begin @@ -15437,7 +15444,7 @@ end; [SetCreatorFunction] function __NSetBoolean(a: array of boolean; dd: array of boolean): NewSet; begin - Result._hs.UnionWith(a); + Result.hs.UnionWith(a); var n := dd.Length; for var i:=0 to n-1 step 2 do begin @@ -15449,7 +15456,7 @@ end; [SetCreatorFunction] function __NSetEnum(a: array of T; dd: array of T): NewSet; begin - Result._hs.UnionWith(a); + Result.hs.UnionWith(a); var vals := System.Enum.GetValues(typeof(T)).Cast&.ToArray; var n := dd.Length; for var i:=0 to n-1 step 2 do @@ -15471,51 +15478,53 @@ end; function operator implicit(n: array of integer): set of byte; extensionmethod; begin foreach var x in n do - Result._hs.Add(x); + Result.hs.Add(x); end; function operator implicit(n: array of integer): set of shortint; extensionmethod; begin foreach var x in n do - Result._hs.Add(x); + Result.hs.Add(x); end; function operator implicit(n: array of integer): set of smallint; extensionmethod; begin foreach var x in n do - Result._hs.Add(x); + Result.hs.Add(x); end; function operator implicit(n: array of integer): set of word; extensionmethod; begin foreach var x in n do - Result._hs.Add(x); + Result.hs.Add(x); end; function operator implicit(n: array of integer): set of longword; extensionmethod; begin foreach var x in n do - Result._hs.Add(x); + Result.hs.Add(x); end; function operator implicit(a: array of integer): set of int64; extensionmethod; begin foreach var x in a do - Result._hs.Add(x); + Result.hs.Add(x); end; function operator implicit(a: array of integer): set of uint64; extensionmethod; begin foreach var x in a do - Result._hs.Add(x); + Result.hs.Add(x); end; function operator implicit(a: array of integer): set of BigInteger; extensionmethod; begin foreach var x in a do - Result._hs.Add(x); + Result.hs.Add(x); end; +//function operator implicit(ns: NewSetEmpty): NewSet; extensionmethod; begin end; + // ----------------------------------------------------------------------------- // Внутренние вспомогательные функции // ----------------------------------------------------------------------------- diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index 62808a171..1951ad714 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -5321,7 +5321,6 @@ namespace PascalABCCompiler.TreeConverter } else { - _pascal_set_constant = _pascal_set_constant; // Ну теперь самый общий NSet(Arr(consts), Arr(consts_diap)) var nset_type = new semantic_type_node(el_type, psc); var dnNSetInt = new dot_node(new ident("PABCSystem", psc), new ident("__NSetInteger", psc)); diff --git a/_RebuildReleaseAndBuildUnits.bat b/_RebuildReleaseAndBuildUnits.bat index 5a54bf60e..a5613c8df 100644 --- a/_RebuildReleaseAndBuildUnits.bat +++ b/_RebuildReleaseAndBuildUnits.bat @@ -18,8 +18,8 @@ cd .. ExecHide.exe gacutil.exe /u PABCRtl ExecHide.exe gacutil.exe /i ..\bin\Lib\PABCRtl.dll -..\bin\pabcnetc RebuildStandartModules.pas /rebuild -@IF %ERRORLEVEL% NEQ 0 GOTO ERROR +rem ..\bin\pabcnetc RebuildStandartModules.pas /rebuild +rem @IF %ERRORLEVEL% NEQ 0 GOTO ERROR cd ..\bin diff --git a/bin/Lib/PABCExtensions.pas b/bin/Lib/PABCExtensions.pas index 6a4f4bb26..2a0539a0b 100644 --- a/bin/Lib/PABCExtensions.pas +++ b/bin/Lib/PABCExtensions.pas @@ -455,10 +455,10 @@ begin end; // Важнейший для новых множеств !!! -procedure operator:=(var Self: NewSet; st: NewSet); extensionmethod; +{procedure operator:=(var Self: NewSet; st: NewSet); extensionmethod; begin Self._hs := new HashSet(st.hs); -end; +end;} {procedure operator:=(var Self: NewSet; st: NewSetEmpty); extensionmethod; begin diff --git a/bin/Lib/PABCSystem.pas b/bin/Lib/PABCSystem.pas index a1fd541b4..94a925d95 100644 --- a/bin/Lib/PABCSystem.pas +++ b/bin/Lib/PABCSystem.pas @@ -483,6 +483,8 @@ type end;} type + NewSetEmpty = class; + /// Тип нового встроенного множества NewSet = record(IEnumerable) private @@ -545,12 +547,17 @@ type static function operator implicit(ns: HashSet): NewSet; begin Result.hs.UnionWith(ns); - end; + end; + + static function operator implicit(ns: NewSetEmpty): NewSet; begin end; + static function operator:=(var s: NewSet; st: NewSet): NewSet; + begin + s._hs := new HashSet(st.hs); + end; end; - NewSetEmpty = record - static function operator implicit(ns: NewSetEmpty): NewSet; begin end; - + NewSetEmpty = class + public static function operator=(s1: NewSet; s2: NewSetEmpty): boolean := s1.Count = 0; static function operator=(s2: NewSetEmpty; s1: NewSet): boolean := s1.Count = 0; static function operator<>(s1: NewSet; s2: NewSetEmpty): boolean := not (s1 = s2); @@ -565,9 +572,9 @@ type static function operator<=(s2: NewSetEmpty; s1: NewSet): boolean := s1.Count >= 0; // ToDo: определить то же для массивов на будущее - static function operator+(first, second: NewSetEmpty): NewSetEmpty; begin end; - static function operator-(first, second: NewSetEmpty): NewSetEmpty; begin end; - static function operator*(first, second: NewSetEmpty): NewSetEmpty; begin end; + static function operator+(first, second: NewSetEmpty): NewSetEmpty := new NewSetEmpty; + static function operator-(first, second: NewSetEmpty): NewSetEmpty := new NewSetEmpty; + static function operator*(first, second: NewSetEmpty): NewSetEmpty := new NewSetEmpty; static function operator+(first: NewSetEmpty; second: array of T): NewSet; begin Result._hs.UnionWith(second); @@ -602,7 +609,7 @@ type Result := new HashSet; end; end; - + type // Вспомогательный тип для множества ///-- @@ -15395,7 +15402,7 @@ end;} // Присваивание реализовано в PABCExtensions. Здесь не работает -var _emptyset: NewSetEmpty; +var _emptyset: NewSetEmpty := new NewSetEmpty; type SetCreatorFunctionAttribute = class(Attribute) @@ -15516,6 +15523,8 @@ begin Result._hs.Add(x); end; +//function operator implicit(ns: NewSetEmpty): NewSet; extensionmethod; begin end; + // ----------------------------------------------------------------------------- // Внутренние вспомогательные функции // -----------------------------------------------------------------------------