* constant string conversion fixed, it's now equal to both

shortstring, ansistring and the typeconvnode will return
    te_equal but still return convtype to change the constnode
This commit is contained in:
peter 2003-01-09 21:43:39 +00:00
parent 91b50bdf37
commit 90473fa87f
2 changed files with 37 additions and 20 deletions

View File

@ -34,17 +34,6 @@ interface
symconst,symbase,symtype,symdef;
type
{ The order is from low priority to high priority,
Note: the operators > and < are used on this list }
tequaltype = (
te_incompatible,
te_convert_operator,
te_convert_l2, { compatible conversion with possible loss of data }
te_convert_l1, { compatible conversion }
te_equal, { the definitions are equal }
te_exact
);
{ if acp is cp_all the var const or nothing are considered equal }
compare_type = ( cp_none, cp_value_equal_const, cp_all,cp_procvar);
@ -286,10 +275,15 @@ implementation
doconv:=tc_string_2_string;
{ Don't prefer conversions from widestring to a
normal string as we can loose information }
if is_widestring(def_from) then
eq:=te_convert_l1
if tstringdef(def_from).string_typ=st_widestring then
eq:=te_convert_l1
else
eq:=te_convert_l2;
begin
if tstringdef(def_to).string_typ=st_widestring then
eq:=te_convert_l1
else
eq:=te_equal; { we can change the stringconst node }
end;
end;
end
else
@ -958,6 +952,7 @@ implementation
formaldef :
begin
doconv:=tc_equal;
if (def_from.deftype=formaldef) then
eq:=te_equal
else
@ -978,6 +973,12 @@ implementation
if assigned(operatorpd) then
eq:=te_convert_operator;
end;
{ update convtype for te_equal when it is not yet set }
if (eq=te_equal) and
(doconv=tc_not_possible) then
doconv:=tc_equal;
compare_defs_ext:=eq;
end;
@ -1187,7 +1188,12 @@ implementation
end.
{
$Log$
Revision 1.16 2003-01-05 22:42:13 peter
Revision 1.17 2003-01-09 21:43:39 peter
* constant string conversion fixed, it's now equal to both
shortstring, ansistring and the typeconvnode will return
te_equal but still return convtype to change the constnode
Revision 1.16 2003/01/05 22:42:13 peter
* use int_to_int conversion for pointer/procvar/classref to int
Revision 1.15 2003/01/05 15:54:15 florian

View File

@ -1054,10 +1054,16 @@ implementation
end
else
begin
left.resulttype:=resulttype;
result:=left;
left:=nil;
exit;
{ Only leave when there is no conversion to do.
We can still need to call a conversion routine,
like the routine to convert a stringconstnode }
if convtype in [tc_equal,tc_not_possible] then
begin
left.resulttype:=resulttype;
result:=left;
left:=nil;
exit;
end;
end;
end;
@ -2018,7 +2024,12 @@ begin
end.
{
$Log$
Revision 1.98 2003-01-05 22:41:40 peter
Revision 1.99 2003-01-09 21:43:39 peter
* constant string conversion fixed, it's now equal to both
shortstring, ansistring and the typeconvnode will return
te_equal but still return convtype to change the constnode
Revision 1.98 2003/01/05 22:41:40 peter
* move code that checks for longint-pointer conversion hint
Revision 1.97 2003/01/03 12:15:56 daniel