From e3617050956f923af30f92dc62a64787ac4cec42 Mon Sep 17 00:00:00 2001 From: miks1965 Date: Fri, 12 Oct 2018 07:15:21 +0300 Subject: [PATCH] bug fix #1080 --- Configuration/GlobalAssemblyInfo.cs | 2 +- Configuration/Version.defs | 4 +- .../PascalABCParserNewSaushkin/ABCPascal.cs | 2 +- .../PascalABCParserNewSaushkin/ABCPascal.y | 2 +- .../ABCPascalYacc.cs | 2351 +++++++++-------- Parsers/PascalABCParserNewSaushkin/PABC.ymc | 2 + ReleaseGenerators/PascalABCNET_version.nsh | 2 +- TestSuite/CompilationSamples/PABCSystem.pas | 13 +- TestSuite/lambda_closure_class_fields_6.pas | 19 + .../Closure/CapturedVariablesTreeBuilder.cs | 3 +- 10 files changed, 1217 insertions(+), 1183 deletions(-) create mode 100644 TestSuite/lambda_closure_class_fields_6.pas diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index 133ebd195..dd4be34ad 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 = "4"; public const string Build = "2"; - public const string Revision = "1830"; + public const string Revision = "1837"; 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 4e4855ebd..aac9d33fc 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ -%MINOR%=4 -%REVISION%=1830 %COREVERSION%=2 +%REVISION%=1837 +%MINOR%=4 %MAJOR%=3 diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs b/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs index 2687182bc..1b7f0b5f6 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascal.cs @@ -2,7 +2,7 @@ // This CSharp output file generated by Gardens Point LEX // Version: 1.1.3.301 // Machine: DESKTOP-A6LT9RI -// DateTime: 11.10.2018 17:14:45 +// DateTime: 11.10.2018 17:41:30 // UserName: ????????? // GPLEX input file // GPLEX frame file diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascal.y b/Parsers/PascalABCParserNewSaushkin/ABCPascal.y index a20122212..3c2553aba 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascal.y +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascal.y @@ -3642,7 +3642,7 @@ default_expr ; tuple - : tkRoundOpen expr_l1 tkComma expr_l1_list lambda_type_ref tkRoundClose // lambda_type_ref optional_full_lambda_fp_list + : tkRoundOpen expr_l1 tkComma expr_l1_list lambda_type_ref optional_full_lambda_fp_list tkRoundClose // lambda_type_ref optional_full_lambda_fp_list { /*if ($5 != null) parsertools.AddErrorFromResource("BAD_TUPLE",@5); diff --git a/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs b/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs index e4fcea026..658dec987 100644 --- a/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs +++ b/Parsers/PascalABCParserNewSaushkin/ABCPascalYacc.cs @@ -2,7 +2,7 @@ // GPPG version 1.3.6 // Machine: DESKTOP-A6LT9RI -// DateTime: 11.10.2018 17:14:45 +// DateTime: 11.10.2018 17:41:31 // UserName: ????????? // Input file @@ -75,7 +75,7 @@ public partial class GPPGParser: ShiftReduceParser aliasses; #pragma warning restore 649 private static Rule[] rules = new Rule[907]; - private static State[] states = new State[1492]; + private static State[] states = new State[1493]; private static string[] nonTerms = new string[] { "parse_goal", "unit_key_word", "class_or_static", "assignment", "optional_array_initializer", "attribute_declarations", "ot_visibility_specifier", "one_attribute", "attribute_variable", @@ -160,13 +160,13 @@ public partial class GPPGParser: ShiftReduceParser tkRoundOpen, expr_l1, tkComma, expr_l1_list, lambda_type_ref, - // tkRoundClose + // optional_full_lambda_fp_list, tkRoundClose { /*if ($5 != null) parsertools.AddErrorFromResource("BAD_TUPLE",@5); if ($6 != null) parsertools.AddErrorFromResource("BAD_TUPLE",@6);*/ - if ((ValueStack[ValueStack.Depth-3].stn as expression_list).Count>6) + if ((ValueStack[ValueStack.Depth-4].stn as expression_list).Count>6) parsertools.AddErrorFromResource("TUPLE_ELEMENTS_COUNT_MUST_BE_LESSEQUAL_7",CurrentLocationSpan); - (ValueStack[ValueStack.Depth-3].stn as expression_list).Insert(0,ValueStack[ValueStack.Depth-5].ex); - CurrentSemanticValue.ex = new tuple_node(ValueStack[ValueStack.Depth-3].stn as expression_list,CurrentLocationSpan); + (ValueStack[ValueStack.Depth-4].stn as expression_list).Insert(0,ValueStack[ValueStack.Depth-6].ex); + CurrentSemanticValue.ex = new tuple_node(ValueStack[ValueStack.Depth-4].stn as expression_list,CurrentLocationSpan); } break; case 671: // factor -> tkNil diff --git a/Parsers/PascalABCParserNewSaushkin/PABC.ymc b/Parsers/PascalABCParserNewSaushkin/PABC.ymc index ec17519ab..07f9d053b 100644 --- a/Parsers/PascalABCParserNewSaushkin/PABC.ymc +++ b/Parsers/PascalABCParserNewSaushkin/PABC.ymc @@ -227,6 +227,8 @@ script= + + diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index 4988a63c0..4be8f9e1d 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.4.2.1830' +!define VERSION '3.4.2.1837' diff --git a/TestSuite/CompilationSamples/PABCSystem.pas b/TestSuite/CompilationSamples/PABCSystem.pas index 88664edea..36f086d8b 100644 --- a/TestSuite/CompilationSamples/PABCSystem.pas +++ b/TestSuite/CompilationSamples/PABCSystem.pas @@ -8395,6 +8395,12 @@ begin Result := Self; end; +function Print(Self: int64): int64; extensionmethod; +begin + PABCSystem.Print(Self); + Result := Self; +end; + function Print(Self: real): real; extensionmethod; begin PABCSystem.Print(Self); @@ -8425,6 +8431,12 @@ begin Result := Self; end; +function Println(Self: int64): int64; extensionmethod; +begin + PABCSystem.Println(Self); + Result := Self; +end; + function Println(Self: real): real; extensionmethod; begin PABCSystem.Println(Self); @@ -8450,7 +8462,6 @@ begin end; - //------------------------------------------------------------------------------ //>> Методы расширения последовательностей # Extension methods for sequence of T //------------------------------------------------------------------------------ diff --git a/TestSuite/lambda_closure_class_fields_6.pas b/TestSuite/lambda_closure_class_fields_6.pas new file mode 100644 index 000000000..1eac5fc70 --- /dev/null +++ b/TestSuite/lambda_closure_class_fields_6.pas @@ -0,0 +1,19 @@ +procedure Invoke(p: procedure); +begin end; + +type +WH = class + Width,Height: real; +end; +C = class + gr: WH; +end; + +B = class(C) + property Width: real + write Invoke(procedure->begin gr.Width := value end); +end; + +begin + Assert(1=1) +end. \ No newline at end of file diff --git a/TreeConverter/LambdaExpressions/Closure/CapturedVariablesTreeBuilder.cs b/TreeConverter/LambdaExpressions/Closure/CapturedVariablesTreeBuilder.cs index a5a8cda1a..a76c0f373 100644 --- a/TreeConverter/LambdaExpressions/Closure/CapturedVariablesTreeBuilder.cs +++ b/TreeConverter/LambdaExpressions/Closure/CapturedVariablesTreeBuilder.cs @@ -177,7 +177,8 @@ namespace TreeConverter.LambdaExpressions.Closure si.sym_info.semantic_node_type == semantic_node_type.class_field ; //trjuk, chtoby ne perelopachivat ves kod. zamenjaem ident na self.ident - if ((si.sym_info.semantic_node_type == semantic_node_type.class_field || si.sym_info.semantic_node_type == semantic_node_type.common_event || si.sym_info.semantic_node_type == semantic_node_type.common_property_node) && InLambdaContext) + // Использую этот трюк для нестатических полей предков - они не захватываются из-за плохого алгоритма захвата + if ((si.sym_info.semantic_node_type == semantic_node_type.class_field && !(si.sym_info as class_field).IsStatic || si.sym_info.semantic_node_type == semantic_node_type.common_event || si.sym_info.semantic_node_type == semantic_node_type.common_property_node) && InLambdaContext) { dot_node dn = new dot_node(new ident("self", id.source_context), new ident(id.name, id.source_context), id.source_context); bool ok = true;