* changed {$ifdef x86} code in defcmp into virtual methods

git-svn-id: trunk@32180 -
This commit is contained in:
Jonas Maebe 2015-10-28 18:06:27 +00:00
parent ef5e368327
commit 4f7b4a2735
5 changed files with 71 additions and 19 deletions

View File

@ -1339,18 +1339,16 @@ implementation
end;
pointerdef :
begin
{$ifdef x86}
{ check for far pointers }
if (tcpupointerdef(def_from).x86pointertyp<>tcpupointerdef(def_to).x86pointertyp) then
if not tpointerdef(def_from).compatible_with_pointerdef_size(tpointerdef(def_to)) then
begin
if fromtreetype=niln then
eq:=te_equal
else
eq:=te_incompatible;
end
{ the types can be forward type, handle before normal type check !! }
else
{$endif x86}
{ the types can be forward type, handle before normal type check !! }
if assigned(def_to.typesym) and
((tpointerdef(def_to).pointeddef.typ=forwarddef) or
(tpointerdef(def_from).pointeddef.typ=forwarddef)) then
@ -1422,11 +1420,7 @@ implementation
this is not allowed for complex procvars }
if (is_void(tpointerdef(def_to).pointeddef) or
(m_mac_procvar in current_settings.modeswitches)) and
tprocvardef(def_from).is_addressonly
{$ifdef x86}
and (tcpupointerdef(voidcodepointertype).x86pointertyp=tcpupointerdef(def_to).x86pointertyp)
{$endif x86}
then
tprocvardef(def_from).compatible_with_pointerdef_size(tpointerdef(def_to)) then
begin
doconv:=tc_equal;
eq:=te_convert_l1;
@ -1437,11 +1431,7 @@ implementation
{ procedure variable can be assigned to an void pointer,
this not allowed for methodpointers }
if (m_mac_procvar in current_settings.modeswitches) and
tprocdef(def_from).is_addressonly
{$ifdef x86}
and (tcpupointerdef(voidcodepointertype).x86pointertyp=tcpupointerdef(def_to).x86pointertyp)
{$endif x86}
then
tprocdef(def_from).compatible_with_pointerdef_size(tpointerdef(def_to)) then
begin
doconv:=tc_proc_2_procvar;
eq:=te_convert_l2;

View File

@ -242,6 +242,7 @@ interface
Normally, this is sinttype, except on i8086, where it takes into account the
special i8086 pointer types (near, far, huge). }
function pointer_subtraction_result_type:tdef;virtual;
function compatible_with_pointerdef_size(ptr: tpointerdef): boolean; virtual;
end;
tpointerdefclass = class of tpointerdef;
@ -598,6 +599,7 @@ interface
function no_self_node:boolean;
{ get either a copy as a procdef or procvardef }
function getcopyas(newtyp:tdeftyp;copytyp:tproccopytyp): tstoreddef; virtual;
function compatible_with_pointerdef_size(ptr: tpointerdef): boolean; virtual;
procedure check_mark_as_nested;
procedure init_paraloc_info(side: tcallercallee);
function stack_tainting_parameter(side: tcallercallee): boolean;
@ -3285,6 +3287,12 @@ implementation
end;
function tpointerdef.compatible_with_pointerdef_size(ptr: tpointerdef): boolean;
begin
result:=true;
end;
{****************************************************************************
TCLASSREFDEF
****************************************************************************}
@ -4906,6 +4914,12 @@ implementation
end;
function tabstractprocdef.compatible_with_pointerdef_size(ptr: tpointerdef): boolean;
begin
result:=is_addressonly;
end;
procedure tabstractprocdef.check_mark_as_nested;
begin
{ nested procvars require that nested functions use the Delphi-style

View File

@ -26,19 +26,19 @@ unit symi86;
interface
uses
symtype,symdef,symsym;
symtype,symdef,symsym,symx86;
type
{ ti86procvardef }
ti86procvardef = class(tprocvardef)
ti86procvardef = class(tx86procvardef)
function is_pushleftright: boolean; override;
end;
{ ti86procdef }
ti86procdef = class(tprocdef)
ti86procdef = class(tx86procdef)
function is_pushleftright: boolean; override;
end;

View File

@ -44,15 +44,28 @@ type
function getcopy: tstoreddef; override;
function GetTypeName: string; override;
class function default_x86_data_pointer_type: tx86pointertyp; virtual;
function compatible_with_pointerdef_size(ptr: tpointerdef): boolean; override;
end;
tx86pointerdefclass = class of tx86pointerdef;
tx86procvardef = class(tprocvardef)
function compatible_with_pointerdef_size(ptr: tpointerdef): boolean; override;
end;
tx86procvardefclass = class of tx86procvardef;
tx86procdef = class(tprocdef)
function compatible_with_pointerdef_size(ptr: tpointerdef): boolean; override;
end;
tx86procdefclass = class of tx86procdef;
implementation
uses
globals, verbose,
symbase, fmodule;
{****************************************************************************
tx86pointerdef
****************************************************************************}
@ -178,5 +191,40 @@ implementation
result:=x86pt_near;
end;
function tx86pointerdef.compatible_with_pointerdef_size(ptr: tpointerdef): boolean;
begin
result:=
inherited and
(x86pointertyp=tx86pointerdef(ptr).x86pointertyp);
end;
{****************************************************************************
tx86procvardef
****************************************************************************}
function tx86procvardef.compatible_with_pointerdef_size(ptr: tpointerdef): boolean;
begin
result:=
inherited and
(tx86pointerdef(voidcodepointertype).x86pointertyp=tx86pointerdef(ptr).x86pointertyp);
end;
{****************************************************************************
tx86procdef
****************************************************************************}
function tx86procdef.compatible_with_pointerdef_size(ptr: tpointerdef): boolean;
begin
result:=
inherited and
(tx86pointerdef(voidcodepointertype).x86pointertyp=tx86pointerdef(ptr).x86pointertyp);
end;
end.

View File

@ -86,11 +86,11 @@ type
end;
tcpufloatdefclass = class of tcpufloatdef;
tcpuprocvardef = class(tprocvardef)
tcpuprocvardef = class(tx86procvardef)
end;
tcpuprocvardefclass = class of tcpuprocvardef;
tcpuprocdef = class(tprocdef)
tcpuprocdef = class(tx86procdef)
procedure ppuload_platform(ppufile: tcompilerppufile); override;
procedure ppuwrite_platform(ppufile: tcompilerppufile); override;
public