diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index 1932c640d..3f7252c63 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 = "3565"; + public const string Revision = "3569"; 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 524cea035..df4c97322 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ %MINOR%=10 -%REVISION%=3565 +%REVISION%=3569 %COREVERSION%=0 %MAJOR%=3 diff --git a/Release/pabcversion.txt b/Release/pabcversion.txt index ff3cb138c..05b93e56f 100644 --- a/Release/pabcversion.txt +++ b/Release/pabcversion.txt @@ -1 +1 @@ -3.10.0.3565 +3.10.0.3569 diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index 44353f83c..091d00edf 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.10.0.3565' +!define VERSION '3.10.0.3569' diff --git a/TestSuite/CompilationSamples/PABCExtensions.pas b/TestSuite/CompilationSamples/PABCExtensions.pas index 78ab568ac..fd1f72816 100644 --- a/TestSuite/CompilationSamples/PABCExtensions.pas +++ b/TestSuite/CompilationSamples/PABCExtensions.pas @@ -457,7 +457,7 @@ end; // Важнейший для новых множеств !!! {procedure operator:=(var Self: NewSet; st: NewSet); extensionmethod; begin - Self.hs := new HashSet(st.hs); + Self._hs := new HashSet(st.hs); end;} {procedure operator:=(var Self: NewSet; st: NewSetEmpty); extensionmethod; @@ -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 3be1c8f8c..94a925d95 100644 --- a/TestSuite/CompilationSamples/PABCSystem.pas +++ b/TestSuite/CompilationSamples/PABCSystem.pas @@ -490,14 +490,14 @@ type 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); @@ -506,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; @@ -549,10 +549,10 @@ type Result.hs.UnionWith(ns); end; - static function operator implicit(ns: NewSetEmpty): NewSet; begin end; - static function operator:=(var Self: NewSet; st: NewSet): NewSet; + static function operator implicit(ns: NewSetEmpty): NewSet; begin end; + static function operator:=(var s: NewSet; st: NewSet): NewSet; begin - Self.hs := new HashSet(st.hs); + s._hs := new HashSet(st.hs); end; end; @@ -577,11 +577,11 @@ type 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; @@ -595,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; @@ -15413,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 @@ -15432,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 @@ -15444,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 @@ -15456,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 @@ -15478,49 +15478,49 @@ 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/TestSuite/generics4.pas b/TestSuite/generics4.pas index f94be4d71..9490888e7 100644 --- a/TestSuite/generics4.pas +++ b/TestSuite/generics4.pas @@ -11,6 +11,8 @@ begin assert(set1.set1 = []); assert(set1.set2 = []); set2 := set1; + Include(set1.set1,'b'); + Include(set1.set2,'b'); Include(set2.set1,'b'); Include(set2.set2,'b'); assert(set1.set1 = ['b']); // увы - при присваивании не вызывается operator := для компонент diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index 1951ad714..497676e76 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -15617,14 +15617,27 @@ namespace PascalABCCompiler.TreeConverter else if (expr is common_static_method_call) { var csmc = expr as common_static_method_call; - var properties = new List(); - foreach (common_property_node cpn in csmc.function_node.cont_type.properties) - if (cpn.get_function == csmc.function_node && cpn.set_function == null) + if (csmc.function_node.cont_type != null) + { + foreach (common_property_node cpn in csmc.function_node.cont_type.properties) + if (cpn.get_function == csmc.function_node && cpn.set_function == null) + { + constant = new common_static_method_call_as_constant(csmc, null); + break; + } + } + else + { + var values = (csmc.parameters[0] as array_initializer).element_values; + // Надо компоненты проверять на константность + foreach (expression_node en in values) { - constant = new common_static_method_call_as_constant(csmc, null); - break; + if (!(en is constant_node)) + AddError(loc, "CONSTANT_EXPRESSION_EXPECTED"); } - + constant = new common_static_method_call_as_constant(csmc, loc); + return constant; + } } else {