* always allow typecasts between enums and pointers/classes on the JVM target

and treat them like tc_equal rather than tc_int_2_int, because enums /are/
    class instances there

git-svn-id: branches/jvmbackend@18811 -
This commit is contained in:
Jonas Maebe 2011-08-23 15:25:47 +00:00
parent 79e971ea12
commit 7fe0485a4e

View File

@ -663,22 +663,40 @@ implementation
pointerdef : pointerdef :
begin begin
{ ugly, but delphi allows it } { ugly, but delphi allows it }
if (cdo_explicit in cdoptions) and if cdo_explicit in cdoptions then
(m_delphi in current_settings.modeswitches) then
begin begin
doconv:=tc_int_2_int; if target_info.system in [system_jvm_java32] then
eq:=te_convert_l1; begin
doconv:=tc_equal;
eq:=te_convert_l1;
end
else if m_delphi in current_settings.modeswitches then
begin
doconv:=tc_int_2_int;
eq:=te_convert_l1;
end
end; end;
end; end;
objectdef: objectdef:
begin begin
{ ugly, but delphi allows it } { ugly, but delphi allows it }
if (m_delphi in current_settings.modeswitches) and if (cdo_explicit in cdoptions) and
is_class_or_interface_or_dispinterface(def_from) and is_class_or_interface_or_objc_or_java(def_from) then
(cdo_explicit in cdoptions) then
begin begin
doconv:=tc_int_2_int; { in Java enums /are/ class instances, and hence such
eq:=te_convert_l1; typecasts must not be treated as integer-like
conversions
}
if target_info.system in [system_jvm_java32] then
begin
doconv:=tc_equal;
eq:=te_convert_l1;
end
else if m_delphi in current_settings.modeswitches then
begin
doconv:=tc_int_2_int;
eq:=te_convert_l1;
end;
end; end;
end; end;
end; end;
@ -1026,14 +1044,31 @@ implementation
{ allow explicit typecasts from enums to pointer. { allow explicit typecasts from enums to pointer.
Support for delphi compatibility Support for delphi compatibility
} }
{ in Java enums /are/ class instances, and hence such
typecasts must not be treated as integer-like conversions
}
if (((cdo_explicit in cdoptions) and if (((cdo_explicit in cdoptions) and
(m_delphi in current_settings.modeswitches) ((m_delphi in current_settings.modeswitches) or
) or (target_info.system in [system_jvm_java32])
)
) or
(cdo_internal in cdoptions) (cdo_internal in cdoptions)
) then ) then
begin begin
doconv:=tc_int_2_int; { in Java enums /are/ class instances, and hence such
eq:=te_convert_l1; typecasts must not be treated as integer-like
conversions
}
if target_info.system in [system_jvm_java32] then
begin
doconv:=tc_equal;
eq:=te_convert_l1;
end
else if m_delphi in current_settings.modeswitches then
begin
doconv:=tc_int_2_int;
eq:=te_convert_l1;
end;
end; end;
end; end;
arraydef : arraydef :
@ -1397,9 +1432,14 @@ implementation
eq:=te_convert_l2; eq:=te_convert_l2;
end end
{ ugly, but delphi allows it } { ugly, but delphi allows it }
else if (def_from.typ in [orddef,enumdef]) and { in Java enums /are/ class instances, and hence such
(m_delphi in current_settings.modeswitches) and typecasts must not be treated as integer-like conversions
(cdo_explicit in cdoptions) then }
else if ((not(target_info.system in [system_jvm_java32]) and
(def_from.typ=enumdef)) or
(def_from.typ=orddef)) and
(m_delphi in current_settings.modeswitches) and
(cdo_explicit in cdoptions) then
begin begin
doconv:=tc_int_2_int; doconv:=tc_int_2_int;
eq:=te_convert_l1; eq:=te_convert_l1;