From 2806f02333f71a68fa7ddbfa2c70e7867f6908e9 Mon Sep 17 00:00:00 2001 From: miks1965 Date: Sat, 7 Oct 2017 14:01:51 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D0=B0=D0=BD=D0=B0=20=D0=BD=D0=B0=20=D1=81=D1=82=D0=B0=D0=BD?= =?UTF-8?q?=D0=B4=D0=B0=D1=80=D1=82=D0=BD=D1=83=D1=8E=20HashTable=20=D0=B2?= =?UTF-8?q?=20=D1=82=D0=B0=D0=B1=D0=BB=D0=B8=D1=86=D0=B5=20=D1=81=D0=B8?= =?UTF-8?q?=D0=BC=D0=B2=D0=BE=D0=BB=D0=BE=D0=B2.=20=D0=A1=D0=BA=D0=BE?= =?UTF-8?q?=D1=80=D0=BE=D1=81=D1=82=D1=8C=20=D0=BD=D0=B5=20=D1=83=D0=BF?= =?UTF-8?q?=D0=B0=D0=BB=D0=B0!=20=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BD?= =?UTF-8?q?=D1=8B=20ToString=20=D0=B4=D0=BB=D1=8F=20=D0=BD=D0=B5=D0=BA?= =?UTF-8?q?=D0=BE=D1=82=D0=BE=D1=80=D1=8B=D1=85=20=D0=BA=D0=BB=D0=B0=D1=81?= =?UTF-8?q?=D1=81=D0=BE=D0=B2=20=D0=B4=D0=BB=D1=8F=20=D0=BE=D1=82=D0=BE?= =?UTF-8?q?=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=81=D0=B8?= =?UTF-8?q?=D0=BC=D0=B2=D0=BE=D0=BB=D0=BE=D0=B2=20=D0=B2=20=D1=82=D0=B0?= =?UTF-8?q?=D0=B1=D0=BB=D0=B8=D1=86=D0=B5=20=D1=81=D0=B8=D0=BC=D0=B2=D0=BE?= =?UTF-8?q?=D0=BB=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Configuration/GlobalAssemblyInfo.cs | 2 +- Configuration/Version.defs | 4 +- Localization/DefaultLang.resources | Bin 81421 -> 81554 bytes ReleaseGenerators/PascalABCNET_version.nsh | 2 +- .../SymbolTable/DSST/AreaListArray.cs | 20 +++++- TreeConverter/SymbolTable/DSST/DSHashTable.cs | 67 +++++++++++++----- TreeConverter/SymbolTable/DSST/SymbolTable.cs | 45 ++++++++---- .../SymbolTable/symbol_information.cs | 4 +- TreeConverter/TreeRealization/base_nodes.cs | 4 +- TreeConverter/TreeRealization/types.cs | 4 +- TreeConverter/TreeRealization/variables.cs | 4 +- .../DockContent/DisassemblyWindow.cs | 2 +- 12 files changed, 114 insertions(+), 44 deletions(-) diff --git a/Configuration/GlobalAssemblyInfo.cs b/Configuration/GlobalAssemblyInfo.cs index f5d76637c..fee2b8fec 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 = "1542"; + public const string Revision = "1545"; 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 2a126d099..3e5552526 100644 --- a/Configuration/Version.defs +++ b/Configuration/Version.defs @@ -1,4 +1,4 @@ -%MINOR%=3 -%REVISION%=1542 %COREVERSION%=0 +%REVISION%=1545 +%MINOR%=3 %MAJOR%=3 diff --git a/Localization/DefaultLang.resources b/Localization/DefaultLang.resources index 9d5a83811cea82ac90a08de0da91fbf6ef972411..16ed30e924d9ca059601eebd642fc7ddb3a6b112 100644 GIT binary patch delta 160 zcmeDE!!qeF%Y+Av>oz_VZ%y)Z^mPpmaCCN!4{~*Jb@p)#at!hG_p?3!;oZkiA0E8@ z`03FDg%@w0zEybpRN=|H*U#SmR`~et(fbEa9(?+v@DVKa;LQt#H}9T&e*N^N!V87> o2%QRgey$;t``P6-i?m5kmJbN>iig{WY{NUSG23+|86T(s0FU)xPXGV_ delta 29 lcmbRAm!(this IEnumerable seq, string delim = " ") + { + var sb = new System.Text.StringBuilder(); + foreach (var x in seq) + sb.Append(x.ToString() + delim); + return sb.ToString(); + } + } +} namespace SymbolTable { public class AreaNodesList { - public AreaListNode[] data; + public override string ToString() => data.Take(count).JoinIntoString(); + + public AreaListNode[] data; int count; public int Count diff --git a/TreeConverter/SymbolTable/DSST/DSHashTable.cs b/TreeConverter/SymbolTable/DSST/DSHashTable.cs index 961273d0c..5994a1ddb 100644 --- a/TreeConverter/SymbolTable/DSST/DSHashTable.cs +++ b/TreeConverter/SymbolTable/DSST/DSHashTable.cs @@ -1,6 +1,8 @@ // Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; +using System.Linq; +using System.Collections.Generic; namespace SymbolTable { @@ -10,7 +12,9 @@ namespace SymbolTable /// public class DSHashTable { - private int count; + public override string ToString() => dict.SkipWhile(x=>x.Key != "").Skip(1).JoinIntoString(Environment.NewLine); + + /*private int count; private int hash_size { get @@ -19,7 +23,7 @@ namespace SymbolTable } } - public HashTableNode[] hash_arr; + private HashTableNode[] hash_arr; private int HashFunc(string s) { @@ -29,9 +33,11 @@ namespace SymbolTable return Math.Abs(n % hash_size); } - private System.Collections.Generic.Dictionary ht = new System.Collections.Generic.Dictionary(); + private System.Collections.Generic.Dictionary ht = new System.Collections.Generic.Dictionary();*/ - private int GetHash(string s) + private Dictionary dict = new Dictionary(); + + /*private int GetHash(string s) { int hash = HashFunc(s); int i = 1; @@ -59,25 +65,43 @@ namespace SymbolTable if (hat.Length > new_size) return; for (int i = 0; i < hat.Length; i++) if (hat[i] != null) Add(hat[i]); - } + }*/ public DSHashTable(int start_size) { - hash_arr = new HashTableNode[start_size]; - ClearTable(); + //hash_arr = new HashTableNode[start_size]; + //ClearTable(); } public void ClearTable() { - count = 0; - for (int i = 0; i < hash_size; i++) - hash_arr[i] = null; + dict.Clear(); + //count = 0; + //for (int i = 0; i < hash_size; i++) + // hash_arr[i] = null; } - public int Add(HashTableNode node) + public HashTableNode Add(string name) { - if (count / hash_size * 100 > SymbolTableConstants.HashTable_StartResise) + HashTableNode node = null; + var b = dict.TryGetValue(name, out node); + if (!b) + { + node = new HashTableNode(name); + dict[name] = node; + } + return node; + + /*if (!dict.ContainsKey(name)) + { + var node = new HashTableNode(name); + dict[name] = node; + return node; + } + return dict[name];*/ + + /*if (count / hash_size * 100 > SymbolTableConstants.HashTable_StartResise) Resize(hash_size + hash_size / 100 * SymbolTableConstants.HashTable_ProcResize); int tn = GetHash(node.Name); if (hash_arr[tn] == null) @@ -85,15 +109,22 @@ namespace SymbolTable hash_arr[tn] = node; count++; } - return tn; + return hash_arr[tn];*/ } - public int Find(string name) + public HashTableNode Find(string name) { - int h = GetHash(name); - if (hash_arr[h] != null) - return h; - return -1; + HashTableNode node = null; + dict.TryGetValue(name, out node); + return node; + /*if (dict.ContainsKey(name)) + return dict[name]; + else return null;*/ + + /*int h = GetHash(name); + //if (hash_arr[h] != null) + // return hash_arr[h]; + return hash_arr[h];*/ } diff --git a/TreeConverter/SymbolTable/DSST/SymbolTable.cs b/TreeConverter/SymbolTable/DSST/SymbolTable.cs index 243ba5681..af923ecbc 100644 --- a/TreeConverter/SymbolTable/DSST/SymbolTable.cs +++ b/TreeConverter/SymbolTable/DSST/SymbolTable.cs @@ -1,7 +1,7 @@ // Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using System.Collections; +using System.Linq; using PascalABCCompiler.TreeConverter; using System.Collections.Generic; using SymbolTable; @@ -144,7 +144,16 @@ namespace SymbolTable //при создании добавляет себя в vSymbolTable public class Scope:BaseScope { - public DSSymbolTable SymbolTable; + private string ScopeName() + { + var s = this.GetType().Name; + if (s == "UnitInterfaceScope") + return "GLOBAL"; + return s; + } + public override string ToString() => ScopeNum + "->" + TopScopeNum + " ," + ScopeName(); + + public DSSymbolTable SymbolTable; public bool CaseSensitive; public int TopScopeNum; public bool AddStatementsToFront = false; // SSM - введено для необходимости добавлять statements не только в конец statement_list, но и в начало. Нужно для синтаксически сахарных конструкций: например, для создания объекта класса при замыканиях @@ -454,7 +463,8 @@ namespace SymbolTable #region AreaListNode элемент списка областей видимости public class AreaListNode { - public int Area; + public override string ToString() => InfoList.JoinIntoString(); + public int Area; public List InfoList;//для перегузки public AreaListNode() { @@ -466,7 +476,7 @@ namespace SymbolTable Area=ar; InfoList.Add(inf); } - } + } #endregion #region HashTableNode элемент хеш-таблицы @@ -479,7 +489,11 @@ namespace SymbolTable Name=name; NumAreaList=new AreaNodesList(SymbolTableConstants.AreaList_StartSize); } - } + public override string ToString() + { + return NumAreaList.ToString(); + } + } #endregion @@ -611,9 +625,10 @@ namespace SymbolTable //{ Inf.scope = InScope; if (!InScope.CaseSensitive) Name = Name.ToLower(); - int hn = HashTable.Add(new HashTableNode(Name));//ЗДЕСь ВОЗНИКАЕТ НЕДЕТЕРМЕНИРОВАНЯ ОШИБКА + var hn = HashTable.Add(Name);//ЗДЕСь ВОЗНИКАЕТ НЕДЕТЕРМЕНИРОВАНЯ ОШИБКА - SSM 07.10.17 - странный комментарий. Вроде всё нормально. + // SSM 07.10.17 - переделал внутреннее представление HashTable на основе Dictionary - HashTable.hash_arr[hn].NumAreaList.Add(new AreaListNode(InScope.ScopeNum, Inf)); + hn.NumAreaList.Add(new AreaListNode(InScope.ScopeNum, Inf)); //} // catch (Exception e) //{ @@ -636,8 +651,8 @@ namespace SymbolTable SymbolInfoList FirstInfo = new SymbolInfoList(); int Area = scope.ScopeNum; - int tn = HashTable.Find(Name); //найдем имя в хеше - if (tn < 0 || scope is DotNETScope)//если нет такого ищем в областях .NET + var tn = HashTable.Find(Name); //найдем имя в хеше + if (tn == null || scope is DotNETScope)//если нет такого ищем в областях .NET { Scope an; an = ScopeTable[Area]; @@ -648,7 +663,7 @@ namespace SymbolTable return FirstInfo.InfoUnitList.Count > 0 ? FirstInfo : null; } - AreaNodesList AreaList = HashTable.hash_arr[tn].NumAreaList; + AreaNodesList AreaList = tn.NumAreaList; int CurrentArea = Area, ai, bs; do { @@ -950,14 +965,14 @@ namespace SymbolTable int Area = scope.ScopeNum; Scope[] used_units = null; - int tn = HashTable.Find(Name); //найдем имя в хеше + var tn = HashTable.Find(Name); //найдем имя в хеше // SSM 21.01.16 if (Name.StartsWith("?")) // это значит, надо искать в областях .NET Name = Name.Substring(1); // съели ? и ищем т.к. tn<0 // end SSM - if (tn < 0 || scope is DotNETScope)//если нет такого ищем в областях .NET + if (tn == null || scope is DotNETScope)//если нет такого ищем в областях .NET { //ssyy int NextUnitArea = -2; @@ -968,13 +983,13 @@ namespace SymbolTable an = ScopeTable[Area]; if (an is DotNETScope) { - if (tn < 0) + if (tn == null) { AddToSymbolInfo(FirstInfo, (DotNETScope)an, Name); } else { - FindAllInClass(Name, Area, HashTable.hash_arr[tn].NumAreaList, false, FirstInfo); + FindAllInClass(Name, Area, tn.NumAreaList, false, FirstInfo); } } if (FirstInfo.InfoUnitList.Count > 1) @@ -1075,7 +1090,7 @@ namespace SymbolTable return null; //если такого нет то поиск окончен } - AreaNodesList AreaList = HashTable.hash_arr[tn].NumAreaList; + AreaNodesList AreaList = tn.NumAreaList; int CurrentArea = Area, ai; while (CurrentArea >= 0) { diff --git a/TreeConverter/SymbolTable/symbol_information.cs b/TreeConverter/SymbolTable/symbol_information.cs index 93d13cfc5..655d30266 100644 --- a/TreeConverter/SymbolTable/symbol_information.cs +++ b/TreeConverter/SymbolTable/symbol_information.cs @@ -567,10 +567,11 @@ namespace PascalABCCompiler.TreeConverter public class SymbolInfoUnit { + public override string ToString() => "("+scope.ToString() + "," + sym_info.ToString()+")"; + //private readonly name_information_type _name_information_type; private definition_node _sym_info; - private access_level _access_level; private symbol_kind _symbol_kind; @@ -579,7 +580,6 @@ namespace PascalABCCompiler.TreeConverter //public SymbolInfo reference; - public access_level access_level { get diff --git a/TreeConverter/TreeRealization/base_nodes.cs b/TreeConverter/TreeRealization/base_nodes.cs index 718f884af..362d72fba 100644 --- a/TreeConverter/TreeRealization/base_nodes.cs +++ b/TreeConverter/TreeRealization/base_nodes.cs @@ -91,7 +91,9 @@ namespace PascalABCCompiler.TreeRealization [Serializable] public abstract class definition_node : semantic_node, SemanticTree.IDefinitionNode { - protected string doc; + public override string ToString() => this.GetType().Name; + + protected string doc; protected attributes_list _attributes; diff --git a/TreeConverter/TreeRealization/types.cs b/TreeConverter/TreeRealization/types.cs index 3d64b32bf..2b07f2515 100644 --- a/TreeConverter/TreeRealization/types.cs +++ b/TreeConverter/TreeRealization/types.cs @@ -2489,7 +2489,9 @@ namespace PascalABCCompiler.TreeRealization [Serializable] public class compiled_type_node : wrapped_type, SemanticTree.ICompiledTypeNode , SemanticTree.ILocated { - internal System.Type _compiled_type; + public override string ToString() => compiled_type.Name.ToString(); + + internal System.Type _compiled_type; protected compiled_type_node _base_type; //Если это не чистить, будет ошибка. Т.к. при следуйщей компиляции области видимости могут изменится. diff --git a/TreeConverter/TreeRealization/variables.cs b/TreeConverter/TreeRealization/variables.cs index 2879904b9..666646c92 100644 --- a/TreeConverter/TreeRealization/variables.cs +++ b/TreeConverter/TreeRealization/variables.cs @@ -10,7 +10,9 @@ namespace PascalABCCompiler.TreeRealization [Serializable] public abstract class var_definition_node : definition_node, SemanticTree.IVAriableDefinitionNode { - private string _name; + public override string ToString() => this.GetType().Name + ": "+ type.ToString(); + + private string _name; private type_node _type; private expression_node _inital_value; private bool _is_ret_value; diff --git a/VisualPascalABCNET/DockContent/DisassemblyWindow.cs b/VisualPascalABCNET/DockContent/DisassemblyWindow.cs index 4aaf190da..a9f2d6737 100644 --- a/VisualPascalABCNET/DockContent/DisassemblyWindow.cs +++ b/VisualPascalABCNET/DockContent/DisassemblyWindow.cs @@ -23,7 +23,7 @@ namespace VisualPascalABC public void SetDisassembledCode(string code) { DisassemblyEditor.Document.TextContent = code; - DisassemblyEditor.Refresh(); + //DisassemblyEditor.Refresh(); } public void ClearWindow()