This commit is contained in:
Бондарев Иван 2015-08-12 19:21:10 +02:00
parent 8a80aada64
commit 697fb91312
3 changed files with 36 additions and 18 deletions

View file

@ -790,24 +790,26 @@ namespace PascalABCCompiler.PCU
param_types[i] = FindSpecTypeByHandle(pcu_file.dotnet_names[off].addit[i].offset);
}
MethodInfo mi = null;
if (pcu_file.dotnet_names[off].name != "op_Explicit")
if (pcu_file.dotnet_names[off].name != "op_Explicit")
{
//mi = t.GetMethod(pcu_file.dotnet_names[off].name, param_types);
List<MemberInfo> mis = NetHelper.NetHelper.GetMembers(t, pcu_file.dotnet_names[off].name);
mi = ChooseMethod(t, mis, param_types);
}
else
{
MethodInfo[] mis = t.GetMethods();
foreach (MethodInfo mi2 in mis)
if (mi2.Name == "op_Explicit" && mi2.GetParameters()[0].ParameterType == param_types[0].t && mi2.ReturnType == param_types[1].t) mi = mi2;
if (mi == null)
{
//mi = t.GetMethod(pcu_file.dotnet_names[off].name, param_types);
List<MemberInfo> mis = NetHelper.NetHelper.GetMembers(t, pcu_file.dotnet_names[off].name);
mi = ChooseMethod(t, mis, param_types);
}
else
{
MethodInfo[] mis = t.GetMethods();
foreach (MethodInfo mi2 in mis)
if (mi2.Name == "op_Explicit" && mi2.GetParameters()[0].ParameterType == param_types[0].t && mi2.ReturnType == param_types[1].t) mi = mi2;
if (mi == null)
{
List<MemberInfo> mis2 = NetHelper.NetHelper.GetMembers(t, pcu_file.dotnet_names[off].name);
mi = ChooseMethod(t, mis2, param_types);
//mi = t.GetMethod(pcu_file.dotnet_names[off].name, new Type[1] { param_types[0].t });
}
List<MemberInfo> mis2 = NetHelper.NetHelper.GetMembers(t, pcu_file.dotnet_names[off].name);
mi = ChooseMethod(t, mis2, param_types);
//mi = t.GetMethod(pcu_file.dotnet_names[off].name, new Type[1] { param_types[0].t });
}
}
if (mi == null)
throw new Exception(pcu_file.dotnet_names[off].name+" "+t.FullName);
dot_net_cache[off] = mi;
return mi;
}

View file

@ -13,6 +13,21 @@ begin
Result := a;
end;
function ff(delim: string := ' '): string;
begin
Result := 'abc';
end;
procedure tt(str: string);
begin
assert(str = 'abc');
end;
procedure tt(i: integer);
begin
raise new Exception;
end;
begin
assert(test(2)=3);
assert(test(2,4)=4);
@ -24,4 +39,5 @@ var s := 'abcd';
assert(s.test=6);
var k := s.test;
assert(k = 6);
tt(ff);
end.

View file

@ -2267,9 +2267,9 @@ end;
function FormatStr(obj: object): string;
begin
if (obj.GetType = typeof(char)) or (obj.GetType = typeof(string)) then
Result := '''' + string.Format(System.Globalization.NumberFormatInfo.InvariantInfo, '{0}', obj) + ''''
Result := '''' + string.Format(System.Globalization.NumberFormatInfo.InvariantInfo, '{0}', new object[](obj)) + ''''
else
Result := string.Format(System.Globalization.NumberFormatInfo.InvariantInfo, '{0}', obj)
Result := string.Format(System.Globalization.NumberFormatInfo.InvariantInfo, '{0}', new object[](obj))
end;
function TypedSet.ToString: string;