From 01efad3d4f2abcdcff419b81b52cf25d083a258a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D0=BE=D0=BD=D0=B4=D0=B0=D1=80=D0=B5=D0=B2=20=D0=98?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD?= Date: Tue, 8 Aug 2017 22:00:19 +0200 Subject: [PATCH] bug fix --- Compiler/PCU/PCUReader.cs | 17 ++++------------- TestSuite/property4.pas | 19 +++++++++++++++++++ TestSuite/symbol_table_test.pas | 4 ++++ TreeConverter/NetWrappers/NetHelper.cs | 11 +++++------ 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/Compiler/PCU/PCUReader.cs b/Compiler/PCU/PCUReader.cs index b18e7bcd1..e84247ebe 100644 --- a/Compiler/PCU/PCUReader.cs +++ b/Compiler/PCU/PCUReader.cs @@ -477,9 +477,10 @@ namespace PascalABCCompiler.PCU type_node tn = GetSpecialTypeReference(names[i].offset); if (tn is compiled_type_node) { - if ((tn as compiled_type_node).scope == null) - (tn as compiled_type_node).init_scope(); - (tn as compiled_type_node).scope.AddSymbol(names[i].name, si); + compiled_type_node ctn = tn as compiled_type_node; + if (ctn.scope == null) + ctn.init_scope(); + ctn.scope.AddSymbol(names[i].name, si); } else if (tn is generic_instance_type_node) tn.Scope.AddSymbol(names[i].name, si); @@ -2532,12 +2533,6 @@ namespace PascalABCCompiler.PCU private void RestoreAllFields(common_type_node ctn) { //восстанавливаем все методы - - //(ssyy) Внимание!!! Данный код удваивает все методы! - //Я изменил его. - //DarkStar - посмотри: NETGenerator после этого кода - //дважды переводит каждую функцию. - //DarkStar: Да, Ты прав!. Метод я переписал. string[] mnames = class_names[ctn]; WrappedClassScope wcs = ctn.scope as WrappedClassScope; foreach (string mname in mnames) @@ -2908,10 +2903,6 @@ namespace PascalABCCompiler.PCU for (int i=0; i type_search_cache; private static Hashtable compiled_pascal_types; @@ -433,12 +433,12 @@ namespace PascalABCCompiler.NetHelper //if (namespaces[s] == null) ns_ht.Add(s,s); ns_ht[s] = s; namespaces[s] = t; - if (pos != -1) { string[] sub_ns_arr = s.Split('.'); string sub_ns_str = sub_ns_arr[sub_ns_arr.Length - 1]; namespaces[sub_ns_str] = t; + ns_ht[sub_ns_str] = s; int ind = sub_ns_arr.Length - 2; while (ind != 0) { @@ -452,10 +452,8 @@ namespace PascalABCCompiler.NetHelper pos = s.LastIndexOf('.'); //if (pos == -1) if (namespaces[s] == null) - { - ns_ht.Add(s, s); namespaces[s] = t; - } + ns_ht[s] = s; } } TypeInfo ti = new TypeInfo(t, t.FullName); @@ -821,7 +819,8 @@ namespace PascalABCCompiler.NetHelper if (t != null && cur_used_assemblies.ContainsKey(t.Assembly)) return true; foreach (Assembly a in namespace_assemblies.Keys) - if (cur_used_assemblies.ContainsKey(a) && (namespace_assemblies[a] as Hashtable).ContainsKey(Namespace)) return true; + if (cur_used_assemblies.ContainsKey(a) && (namespace_assemblies[a] as Hashtable).ContainsKey(Namespace)) + return true; return false; }