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

View File

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

View File

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

View File

@ -44,15 +44,28 @@ type
function getcopy: tstoreddef; override; function getcopy: tstoreddef; override;
function GetTypeName: string; override; function GetTypeName: string; override;
class function default_x86_data_pointer_type: tx86pointertyp; virtual; class function default_x86_data_pointer_type: tx86pointertyp; virtual;
function compatible_with_pointerdef_size(ptr: tpointerdef): boolean; override;
end; end;
tx86pointerdefclass = class of tx86pointerdef; 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 implementation
uses uses
globals, verbose, globals, verbose,
symbase, fmodule; symbase, fmodule;
{**************************************************************************** {****************************************************************************
tx86pointerdef tx86pointerdef
****************************************************************************} ****************************************************************************}
@ -178,5 +191,40 @@ implementation
result:=x86pt_near; result:=x86pt_near;
end; 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. end.

View File

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