From 674df680115575f0cbdb9c3596c439fd7fb29478 Mon Sep 17 00:00:00 2001 From: miks1965 Date: Mon, 23 Oct 2017 13:25:37 +0300 Subject: [PATCH] AdjacentGroup - sequence of array MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit if (hn == null) throw new Exception("Попытка добавить уже добавленное имя "+ Name + " в HashTable. Обратитесь к разработчикам"); в SymbolTable Попытка учесть классовые переменные при захвате в лямбдах --- Configuration/GlobalAssemblyInfo.cs | 2 +- Configuration/Version.defs | 2 +- InstallerSamples/CheckedTasks/PT4/File48.pas | 2 +- ReleaseGenerators/PascalABCNET_version.nsh | 2 +- ReleaseGenerators/sect_Core.nsh | 2 +- TestSuite/CompilationSamples/PABCSystem.pas | 6 +++--- .../CapturedVariablesSubstitutionClassGenerator.cs | 8 ++++++++ .../Closure/CapturedVariablesSubstitutor.cs | 1 + TreeConverter/SymbolTable/DSST/SymbolTable.cs | 5 +++-- bin/Lib/PABCSystem.pas | 6 +++--- 10 files changed, 23 insertions(+), 13 deletions(-) diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index 20e8a1ba2..1d9c8ee61 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 = "3"; public const string Build = "0"; - public const string Revision = "1551"; + public const string Revision = "1555"; 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 2995444e8..34f0be296 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ %COREVERSION%=0 -%REVISION%=1551 +%REVISION%=1555 %MINOR%=3 %MAJOR%=3 diff --git a/InstallerSamples/CheckedTasks/PT4/File48.pas b/InstallerSamples/CheckedTasks/PT4/File48.pas index b6c906d29..d73fec286 100644 --- a/InstallerSamples/CheckedTasks/PT4/File48.pas +++ b/InstallerSamples/CheckedTasks/PT4/File48.pas @@ -1,4 +1,4 @@ -// Пример решения задачи File48 из электронного задачника Programming Taskbook +// Пример решения задачи File48 из электронного задачника Programming Taskbook uses PT4; var f: array [1..4] of file of integer; diff --git a/ReleaseGenerators/PascalABCNET_version.nsh b/ReleaseGenerators/PascalABCNET_version.nsh index ad29f1d5b..29a7f81e6 100644 --- a/ReleaseGenerators/PascalABCNET_version.nsh +++ b/ReleaseGenerators/PascalABCNET_version.nsh @@ -1 +1 @@ -!define VERSION '3.3.0.1551' +!define VERSION '3.3.0.1555' diff --git a/ReleaseGenerators/sect_Core.nsh b/ReleaseGenerators/sect_Core.nsh index 6dba115b9..d356fdc96 100644 --- a/ReleaseGenerators/sect_Core.nsh +++ b/ReleaseGenerators/sect_Core.nsh @@ -165,7 +165,7 @@ ${AddFile} "PABCRtl.pdb" SetOutPath "$INSTDIR\Doc" - File ..\Doc\NumLibABC.pdf + File ..\doc\NumLibABC.pdf ${AddFile} "NumLibABC.pdf" diff --git a/TestSuite/CompilationSamples/PABCSystem.pas b/TestSuite/CompilationSamples/PABCSystem.pas index 6713e4218..b47866f25 100644 --- a/TestSuite/CompilationSamples/PABCSystem.pas +++ b/TestSuite/CompilationSamples/PABCSystem.pas @@ -8644,12 +8644,12 @@ begin end end; -/// Группирует одинаковые подряд идущие элементы, получая последовательность последовательностей -function AdjacentGroup(Self: sequence of T): sequence of sequence of T; extensionmethod; +/// Группирует одинаковые подряд идущие элементы, получая последовательность массивов +function AdjacentGroup(Self: sequence of T): sequence of array of T; extensionmethod; begin var c := new AdjGroupClass(Self); while c.fin do - yield c.TakeGroup(); + yield c.TakeGroup().ToArray; end; // ToDo Сделать AdjacentGroup с функцией сравнения diff --git a/TreeConverter/LambdaExpressions/Closure/CapturedVariablesSubstitutionClassGenerator.cs b/TreeConverter/LambdaExpressions/Closure/CapturedVariablesSubstitutionClassGenerator.cs index 0b7b0887c..8c44b16e3 100644 --- a/TreeConverter/LambdaExpressions/Closure/CapturedVariablesSubstitutionClassGenerator.cs +++ b/TreeConverter/LambdaExpressions/Closure/CapturedVariablesSubstitutionClassGenerator.cs @@ -170,6 +170,7 @@ namespace TreeConverter.LambdaExpressions.Closure private void VisitCapturedVar(CapturedVariablesTreeNode scope, CapturedVariablesTreeNode.CapturedSymbolInfo symbolInfo) { var varName = ((IVAriableDefinitionNode)symbolInfo.SymbolInfo.sym_info).name.ToLower(); + var ff = symbolInfo.SymbolInfo.sym_info.GetType(); var isSelfWordInClass = scope is CapturedVariablesTreeNodeClassScope && varName == compiler_string_consts.self_word; foreach (var referencingLambda in symbolInfo.ReferencingLambdas.OrderByDescending(rl => rl.ScopeIndex)) @@ -200,6 +201,13 @@ namespace TreeConverter.LambdaExpressions.Closure scope.CorrespondingSyntaxTreeNode); if (!_substitutions.ContainsKey(substKey)) { + // SSM 22.10.17 Тут ошибка в случае захвата классовых полей - первый параметр должен быть не self, а имя класса + var cl = _capturedVarsClassDefs[upperScopeWhereVarsAreCaptured.ScopeIndex].ClassDeclaration; + var ClassName = cl.type_name; + var cf = symbolInfo.SymbolInfo.sym_info as class_field; + if (cf != null && cf.IsStatic) + _substitutions.Add(substKey, new dot_node(ClassName, new ident(varName)));// sc не заполнен, что плохо! + else _substitutions.Add(substKey, new dot_node( new ident( diff --git a/TreeConverter/LambdaExpressions/Closure/CapturedVariablesSubstitutor.cs b/TreeConverter/LambdaExpressions/Closure/CapturedVariablesSubstitutor.cs index fc29d4f5c..2224b5247 100644 --- a/TreeConverter/LambdaExpressions/Closure/CapturedVariablesSubstitutor.cs +++ b/TreeConverter/LambdaExpressions/Closure/CapturedVariablesSubstitutor.cs @@ -15,6 +15,7 @@ namespace TreeConverter.LambdaExpressions.Closure { internal class SubstitutionKey { + public override string ToString() => _variableName; private readonly string _variableName; private readonly syntax_tree_node _syntaxTreeNodeWhereVaribleIsDeclared; private readonly syntax_tree_node _syntaxTreeUnderSubstitution; diff --git a/TreeConverter/SymbolTable/DSST/SymbolTable.cs b/TreeConverter/SymbolTable/DSST/SymbolTable.cs index 4ac7c6949..f3d3e029e 100644 --- a/TreeConverter/SymbolTable/DSST/SymbolTable.cs +++ b/TreeConverter/SymbolTable/DSST/SymbolTable.cs @@ -670,9 +670,10 @@ namespace SymbolTable //{ Inf.scope = InScope; if (!InScope.CaseSensitive) Name = Name.ToLower(); - var hn = HashTable.Add(Name);//ЗДЕСь ВОЗНИКАЕТ НЕДЕТЕРМЕНИРОВАНЯ ОШИБКА - SSM 07.10.17 - странный комментарий. Вроде всё нормально. + var hn = HashTable.Add(Name);//ЗДЕСЬ ВОЗНИКАЕТ НЕДЕТЕРМЕНИРОВАННАЯ ОШИБКА - SSM 07.10.17 - странный комментарий. Вроде всё нормально. // SSM 07.10.17 - переделал внутреннее представление HashTable на основе Dictionary - + if (hn == null) + throw new Exception("Попытка добавить уже добавленное имя "+ Name + " в HashTable. Обратитесь к разработчикам"); hn.NumAreaList.Add(new AreaListNode(InScope.ScopeNum, Inf)); //} // catch (Exception e) diff --git a/bin/Lib/PABCSystem.pas b/bin/Lib/PABCSystem.pas index 6713e4218..b47866f25 100644 --- a/bin/Lib/PABCSystem.pas +++ b/bin/Lib/PABCSystem.pas @@ -8644,12 +8644,12 @@ begin end end; -/// Группирует одинаковые подряд идущие элементы, получая последовательность последовательностей -function AdjacentGroup(Self: sequence of T): sequence of sequence of T; extensionmethod; +/// Группирует одинаковые подряд идущие элементы, получая последовательность массивов +function AdjacentGroup(Self: sequence of T): sequence of array of T; extensionmethod; begin var c := new AdjGroupClass(Self); while c.fin do - yield c.TakeGroup(); + yield c.TakeGroup().ToArray; end; // ToDo Сделать AdjacentGroup с функцией сравнения