diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index d5ff416ba..4514ab978 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 = "5"; public const string Build = "0"; - public const string Revision = "2184"; + public const string Revision = "2188"; 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 f7cbbf3d8..af56c93c7 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ %COREVERSION%=0 -%REVISION%=2184 +%REVISION%=2188 %MINOR%=5 %MAJOR%=3 diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index 4a9c971d5..5384fe5ae 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.5.0.2184' +!define VERSION '3.5.0.2188' diff --git a/SyntaxVisitors/YieldVisitors/ProcessYieldsCapturedVars.cs b/SyntaxVisitors/YieldVisitors/ProcessYieldsCapturedVars.cs index 8234fc9ce..e859be3f7 100644 --- a/SyntaxVisitors/YieldVisitors/ProcessYieldsCapturedVars.cs +++ b/SyntaxVisitors/YieldVisitors/ProcessYieldsCapturedVars.cs @@ -150,15 +150,16 @@ namespace SyntaxVisitors var stels = seqt.elements_type; var iteratorClassName = GetClassName(pd); - /*var classDef = UpperNode(3) as class_definition; - var staticClass = false; - if ((classDef.attribute & class_attribute.Static) != 0) + /*var staticClass = false; + + var classDef = GetMethodClassDefinition(pd); + + if (classDef != null && (classDef.attribute & class_attribute.Static) != 0) staticClass = true;*/ - // frninja 08/18/15 - Для захвата self - if (iteratorClassName != null/* && !staticClass */) + if (iteratorClassName != null /*&& !staticClass*/) { // frninja 20/04/16 - поддержка шаблонных классов var iteratorClassRef = CreateClassReference(iteratorClassName); diff --git a/SyntaxVisitors/YieldVisitors/ReplaceCapturedVariablesVisitor.cs b/SyntaxVisitors/YieldVisitors/ReplaceCapturedVariablesVisitor.cs index 2214601a2..c0b49bf69 100644 --- a/SyntaxVisitors/YieldVisitors/ReplaceCapturedVariablesVisitor.cs +++ b/SyntaxVisitors/YieldVisitors/ReplaceCapturedVariablesVisitor.cs @@ -49,6 +49,7 @@ namespace SyntaxVisitors CapturedFormalParamsMap = new Dictionary(formalParamsMap); IsInClassMethod = isInClassMethod; + IsStaticMethod = isStaticMethod; ClassName = className; // Methods hack @@ -112,6 +113,7 @@ namespace SyntaxVisitors //var capturedId = new dot_node(new dot_node(new ident("self"), new ident(YieldConsts.Self)), id); + //var capturedId = new dot_node(ClassName, id.TypedClone()); //Replace(id, capturedId); } //else diff --git a/TestSuite/Yield_static_1.pas b/TestSuite/Yield_static_1.pas new file mode 100644 index 000000000..607013d42 --- /dev/null +++ b/TestSuite/Yield_static_1.pas @@ -0,0 +1,14 @@ +type + T = static class + static r: integer := 3; + static property p: integer read 1; + static function r1(i: integer): integer := 2; + public static function f(a: integer): sequence of integer; + begin + yield r + a + p +r1(1); + end; + end; + +begin + Assert(T.f(5).First=11); +end. \ No newline at end of file diff --git a/TestSuite/Yield_static_2.pas b/TestSuite/Yield_static_2.pas new file mode 100644 index 000000000..1cca9e058 --- /dev/null +++ b/TestSuite/Yield_static_2.pas @@ -0,0 +1,14 @@ +type + T = {static} class + static r: integer := 3; + static property p: integer read 1; + static function r1(i: integer): integer := 2; + public static function f(a: integer): sequence of integer; + begin + yield r + a + p +r1(1); + end; + end; + +begin + Assert(T.f(5).First=11); +end. \ No newline at end of file diff --git a/TestSuite/Yield_static_3.pas b/TestSuite/Yield_static_3.pas new file mode 100644 index 000000000..1d8372f90 --- /dev/null +++ b/TestSuite/Yield_static_3.pas @@ -0,0 +1,16 @@ +type + T = {static} class + static r: integer := 3; + static property p: integer read 1; + static function r1(i: integer): integer := 2; + public static function f(a: integer): sequence of integer; + end; + +static function T.f(a: integer): sequence of integer; +begin + yield r + a + p +r1(1); +end; + +begin + Assert(T.f(5).First=11); +end. \ No newline at end of file diff --git a/TestSuite/Yield_static_4.pas b/TestSuite/Yield_static_4.pas new file mode 100644 index 000000000..6b70a2eb9 --- /dev/null +++ b/TestSuite/Yield_static_4.pas @@ -0,0 +1,16 @@ +type + T = static class + static r: integer := 3; + static property p: integer read 1; + static function r1(i: integer): integer := 2; + public static function f(a: integer): sequence of integer; + end; + +static function T.f(a: integer): sequence of integer; +begin + yield r + a + p +r1(1); +end; + +begin + Assert(T.f(5).First=11); +end. \ No newline at end of file diff --git a/TreeConverter/TreeConversion/syntax_tree_visitor.cs b/TreeConverter/TreeConversion/syntax_tree_visitor.cs index 0aba925e5..d72060cc3 100644 --- a/TreeConverter/TreeConversion/syntax_tree_visitor.cs +++ b/TreeConverter/TreeConversion/syntax_tree_visitor.cs @@ -16148,7 +16148,7 @@ namespace PascalABCCompiler.TreeConverter { tn = convert_strong(_var_def_statement.vars_type); //LambdaHelper.InferTypesFromVarStmt(tn, _var_def_statement.inital_value as SyntaxTree.function_lambda_definition, this); //lroman// - if (tn.IsStatic) + if (tn.IsStatic && _var_def_statement.vars.idents[0].name != YieldHelpers.YieldConsts.Self) // SSM 10/07/19 fix #1639 в статическом классе можно только фиктивное поле с именем YieldHelpers.YieldConsts.Self описать - для того чтобы посмотреть на семантике его тип!!! AddError(get_location(_var_def_statement), "VARIABLES_OF_STATIC_CLASS_NOT_ALLOWED"); var fld1 = _var_def_statement.inital_value as SyntaxTree.function_lambda_definition; if (fld1 != null) @@ -20098,7 +20098,7 @@ namespace PascalABCCompiler.TreeConverter { // Search for unknown ident in class var found = iteratorContainingClass.find(_unk.UnknownID.name); - if ((object)found != null) + if (found != null) { // class_field - поле класса // common_method_node - метод класса