This commit is contained in:
Бондарев Иван 2017-08-08 22:00:19 +02:00
parent 948632cb43
commit 01efad3d4f
4 changed files with 32 additions and 19 deletions

View file

@ -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<num_nest_funcs; i++)
cnfn.functions_nodes_list.AddElement(GetNestedFunction());
//br.ReadInt32();//code;
if (cnfn.name == "*")
{
}
cnfn.loc = ReadDebugInfo();
cnfn.function_code = (restore_code /*|| cnfn.is_generic_function*/) ? GetCode(br.ReadInt32()) : new wrapped_function_body(this, br.ReadInt32());
cnfn.ConnectedToType = ConnectedToType;

View file

@ -22,7 +22,26 @@ type
end;
protected property VisualChildrenCount: integer read getVisualChildrenCount; override;
end;
TBaseClass = class
function getA: integer;
begin
Result := 1;
end;
public property A: integer read getA; virtual;
end;
TDerClass = class(TBaseClass)
function getA: integer;
begin
Result := 2;
end;
public property A: integer read getA; override;
end;
begin
var obj: MyVisualHostBase := new MyVisualHost;
assert(obj.getCnt=1);
var obj2: TBaseClass := new TDerClass;
assert(obj2.A = 2);
end.

View file

@ -1,4 +1,8 @@
//winonly
{$reference 'PresentationFramework.dll'}
{$reference 'WindowsBase.dll'}
{$reference 'PresentationCore.dll'}
{$reference 'WindowsFormsIntegration.dll'}
uses System, System.Windows, System.Collections, System.Collections.Generic;
begin

View file

@ -253,7 +253,7 @@ namespace PascalABCCompiler.NetHelper
}
public static class NetHelper {
private static Hashtable namespaces;
private static Hashtable namespaces;
private static Hashtable types;
private static Dictionary<string,FoundInfo> 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;
}