mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-25 12:29:25 +02:00
Align htypechk.pas:is_better_candidate to the left edge of the screen.
This commit is contained in:
parent
bea36238e7
commit
7a963ac56a
@ -52,15 +52,7 @@ interface
|
|||||||
data : tprocdef;
|
data : tprocdef;
|
||||||
wrongparaidx,
|
wrongparaidx,
|
||||||
firstparaidx : integer;
|
firstparaidx : integer;
|
||||||
exact_count,
|
te_count : array[te_convert_operator .. te_exact] of integer; { should be signed }
|
||||||
equal_count,
|
|
||||||
cl1_count,
|
|
||||||
cl2_count,
|
|
||||||
cl3_count,
|
|
||||||
cl4_count,
|
|
||||||
cl5_count,
|
|
||||||
cl6_count,
|
|
||||||
coper_count : integer; { should be signed }
|
|
||||||
ordinal_distance : double;
|
ordinal_distance : double;
|
||||||
invalid : boolean;
|
invalid : boolean;
|
||||||
{$ifndef DISABLE_FAST_OVERLOAD_PATCH}
|
{$ifndef DISABLE_FAST_OVERLOAD_PATCH}
|
||||||
@ -2877,15 +2869,15 @@ implementation
|
|||||||
Comment(lvl,' invalid')
|
Comment(lvl,' invalid')
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
Comment(lvl,' ex: '+tostr(hp^.exact_count)+
|
Comment(lvl,' ex: '+tostr(hp^.te_count[te_exact])+
|
||||||
' eq: '+tostr(hp^.equal_count)+
|
' eq: '+tostr(hp^.te_count[te_equal])+
|
||||||
' l1: '+tostr(hp^.cl1_count)+
|
' l1: '+tostr(hp^.te_count[te_convert_l1])+
|
||||||
' l2: '+tostr(hp^.cl2_count)+
|
' l2: '+tostr(hp^.te_count[te_convert_l2])+
|
||||||
' l3: '+tostr(hp^.cl3_count)+
|
' l3: '+tostr(hp^.te_count[te_convert_l3])+
|
||||||
' l4: '+tostr(hp^.cl4_count)+
|
' l4: '+tostr(hp^.te_count[te_convert_l4])+
|
||||||
' l5: '+tostr(hp^.cl5_count)+
|
' l5: '+tostr(hp^.te_count[te_convert_l5])+
|
||||||
' l6: '+tostr(hp^.cl6_count)+
|
' l6: '+tostr(hp^.te_count[te_convert_l6])+
|
||||||
' oper: '+tostr(hp^.coper_count)+
|
' oper: '+tostr(hp^.te_count[te_convert_operator])+
|
||||||
' ord: '+realtostr(hp^.ordinal_distance));
|
' ord: '+realtostr(hp^.ordinal_distance));
|
||||||
{ Print parameters in left-right order }
|
{ Print parameters in left-right order }
|
||||||
for i:=0 to hp^.data.paras.count-1 do
|
for i:=0 to hp^.data.paras.count-1 do
|
||||||
@ -3210,28 +3202,10 @@ implementation
|
|||||||
eq:=te_incompatible;
|
eq:=te_incompatible;
|
||||||
|
|
||||||
{ increase correct counter }
|
{ increase correct counter }
|
||||||
case eq of
|
if eq<>te_incompatible then
|
||||||
te_exact :
|
inc(hp^.te_count[eq])
|
||||||
inc(hp^.exact_count);
|
else
|
||||||
te_equal :
|
hp^.invalid:=true;
|
||||||
inc(hp^.equal_count);
|
|
||||||
te_convert_l1 :
|
|
||||||
inc(hp^.cl1_count);
|
|
||||||
te_convert_l2 :
|
|
||||||
inc(hp^.cl2_count);
|
|
||||||
te_convert_l3 :
|
|
||||||
inc(hp^.cl3_count);
|
|
||||||
te_convert_l4 :
|
|
||||||
inc(hp^.cl4_count);
|
|
||||||
te_convert_l5 :
|
|
||||||
inc(hp^.cl5_count);
|
|
||||||
te_convert_l6 :
|
|
||||||
inc(hp^.cl6_count);
|
|
||||||
te_convert_operator :
|
|
||||||
inc(hp^.coper_count);
|
|
||||||
te_incompatible :
|
|
||||||
hp^.invalid:=true;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ stop checking when an incompatible parameter is found }
|
{ stop checking when an incompatible parameter is found }
|
||||||
if hp^.invalid then
|
if hp^.invalid then
|
||||||
@ -3319,8 +3293,6 @@ implementation
|
|||||||
|
|
||||||
|
|
||||||
function is_better_candidate(currpd,bestpd:pcandidate):integer;
|
function is_better_candidate(currpd,bestpd:pcandidate):integer;
|
||||||
var
|
|
||||||
res : integer;
|
|
||||||
begin
|
begin
|
||||||
{
|
{
|
||||||
Return values:
|
Return values:
|
||||||
@ -3338,82 +3310,55 @@ implementation
|
|||||||
- (Smaller) Total of ordinal distance. For example, the distance of a word
|
- (Smaller) Total of ordinal distance. For example, the distance of a word
|
||||||
to a byte is 65535-255=65280.
|
to a byte is 65535-255=65280.
|
||||||
}
|
}
|
||||||
if bestpd^.invalid then
|
if bestpd^.invalid or currpd^.invalid then
|
||||||
begin
|
exit(ord(bestpd^.invalid)-ord(currpd^.invalid)); { 1 if bestpd^.invalid, -1 if currpd^.invalid, 0 if both. }
|
||||||
if currpd^.invalid then
|
{ less operator parameters? }
|
||||||
res:=0
|
is_better_candidate:=(bestpd^.te_count[te_convert_operator]-currpd^.te_count[te_convert_operator]);
|
||||||
else
|
if is_better_candidate<>0 then
|
||||||
res:=1;
|
exit;
|
||||||
end
|
{ less cl6 parameters? }
|
||||||
else
|
is_better_candidate:=(bestpd^.te_count[te_convert_l6]-currpd^.te_count[te_convert_l6]);
|
||||||
if currpd^.invalid then
|
if is_better_candidate<>0 then
|
||||||
res:=-1
|
exit;
|
||||||
else
|
{ less cl5 parameters? }
|
||||||
begin
|
is_better_candidate:=(bestpd^.te_count[te_convert_l5]-currpd^.te_count[te_convert_l5]);
|
||||||
{ less operator parameters? }
|
if is_better_candidate<>0 then
|
||||||
res:=(bestpd^.coper_count-currpd^.coper_count);
|
exit;
|
||||||
if (res=0) then
|
{ less cl4 parameters? }
|
||||||
begin
|
is_better_candidate:=(bestpd^.te_count[te_convert_l4]-currpd^.te_count[te_convert_l4]);
|
||||||
{ less cl6 parameters? }
|
if is_better_candidate<>0 then
|
||||||
res:=(bestpd^.cl6_count-currpd^.cl6_count);
|
exit;
|
||||||
if (res=0) then
|
{ less cl3 parameters? }
|
||||||
begin
|
is_better_candidate:=(bestpd^.te_count[te_convert_l3]-currpd^.te_count[te_convert_l3]);
|
||||||
{ less cl5 parameters? }
|
if is_better_candidate<>0 then
|
||||||
res:=(bestpd^.cl5_count-currpd^.cl5_count);
|
exit;
|
||||||
if (res=0) then
|
{ less cl2 parameters? }
|
||||||
begin
|
is_better_candidate:=(bestpd^.te_count[te_convert_l2]-currpd^.te_count[te_convert_l2]);
|
||||||
{ less cl4 parameters? }
|
if is_better_candidate<>0 then
|
||||||
res:=(bestpd^.cl4_count-currpd^.cl4_count);
|
exit;
|
||||||
if (res=0) then
|
{ less cl1 parameters? }
|
||||||
begin
|
is_better_candidate:=(bestpd^.te_count[te_convert_l1]-currpd^.te_count[te_convert_l1]);
|
||||||
{ less cl3 parameters? }
|
if is_better_candidate<>0 then
|
||||||
res:=(bestpd^.cl3_count-currpd^.cl3_count);
|
exit;
|
||||||
if (res=0) then
|
{ more exact parameters? }
|
||||||
begin
|
is_better_candidate:=(currpd^.te_count[te_exact]-bestpd^.te_count[te_exact]);
|
||||||
{ less cl2 parameters? }
|
if is_better_candidate<>0 then
|
||||||
res:=(bestpd^.cl2_count-currpd^.cl2_count);
|
exit;
|
||||||
if (res=0) then
|
{ less equal parameters? }
|
||||||
begin
|
is_better_candidate:=(bestpd^.te_count[te_equal]-currpd^.te_count[te_equal]);
|
||||||
{ less cl1 parameters? }
|
if is_better_candidate<>0 then
|
||||||
res:=(bestpd^.cl1_count-currpd^.cl1_count);
|
exit;
|
||||||
if (res=0) then
|
{ if a specialization is better than a non-specialization then
|
||||||
begin
|
the non-generic always wins }
|
||||||
{ more exact parameters? }
|
if m_implicit_function_specialization in current_settings.modeswitches then
|
||||||
res:=(currpd^.exact_count-bestpd^.exact_count);
|
begin
|
||||||
if (res=0) then
|
is_better_candidate:=ord(bestpd^.data.is_specialization)-ord(currpd^.data.is_specialization); { 1 if bestpd^.data.is_specialization and not currpd^.data.is_specialization, -1 if the reverse, 0 if same is_specialization. }
|
||||||
begin
|
if is_better_candidate<>0 then
|
||||||
{ less equal parameters? }
|
exit;
|
||||||
res:=(bestpd^.equal_count-currpd^.equal_count);
|
end;
|
||||||
if (res=0) then
|
{ smaller ordinal distance? }
|
||||||
begin
|
if (currpd^.ordinal_distance<>bestpd^.ordinal_distance) then
|
||||||
{ smaller ordinal distance? }
|
is_better_candidate:=2*ord(currpd^.ordinal_distance<bestpd^.ordinal_distance)-1; { 1 if currpd^.ordinal_distance < bestpd^.ordinal_distance, -1 if the reverse. }
|
||||||
if (currpd^.ordinal_distance<bestpd^.ordinal_distance) then
|
|
||||||
res:=1
|
|
||||||
else
|
|
||||||
if (currpd^.ordinal_distance>bestpd^.ordinal_distance) then
|
|
||||||
res:=-1
|
|
||||||
else
|
|
||||||
res:=0;
|
|
||||||
{ if a specialization is better than a non-specialization then
|
|
||||||
the non-generic always wins }
|
|
||||||
if m_implicit_function_specialization in current_settings.modeswitches then
|
|
||||||
begin
|
|
||||||
if (currpd^.data.is_specialization and not bestpd^.data.is_specialization) then
|
|
||||||
res:=-1
|
|
||||||
else if (not currpd^.data.is_specialization and bestpd^.data.is_specialization) then
|
|
||||||
res:=1;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
is_better_candidate:=res;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user