mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-23 00:19:54 +01:00
* fixed inlining of method calls with a methodpointer in a temp
+ print inline trees to screen if compiler is compiled with -ddebuginline git-svn-id: trunk@704 -
This commit is contained in:
parent
255855b5d9
commit
20e1ac4640
@ -2110,6 +2110,7 @@ type
|
|||||||
para: tcallparanode;
|
para: tcallparanode;
|
||||||
tempnode: ttempcreatenode;
|
tempnode: ttempcreatenode;
|
||||||
tempnodes: ttempnodes;
|
tempnodes: ttempnodes;
|
||||||
|
n: tnode;
|
||||||
begin
|
begin
|
||||||
{ parameters }
|
{ parameters }
|
||||||
para := tcallparanode(left);
|
para := tcallparanode(left);
|
||||||
@ -2120,6 +2121,14 @@ type
|
|||||||
(not(vo_is_funcret in tparavarsym(para.parasym).varoptions) or
|
(not(vo_is_funcret in tparavarsym(para.parasym).varoptions) or
|
||||||
(not assigned(funcretnode))) then
|
(not assigned(funcretnode))) then
|
||||||
begin
|
begin
|
||||||
|
{ must take copy of para.left, because if it contains a }
|
||||||
|
{ temprefn pointing to a copied temp (e.g. methodpointer), }
|
||||||
|
{ then this parameter must be changed to point to the copy of }
|
||||||
|
{ that temp (JM) }
|
||||||
|
n := para.left.getcopy;
|
||||||
|
para.left.free;
|
||||||
|
para.left := n;
|
||||||
|
|
||||||
{ create temps for value parameters, function result and also for }
|
{ create temps for value parameters, function result and also for }
|
||||||
{ const parameters which are passed by value instead of by reference }
|
{ const parameters which are passed by value instead of by reference }
|
||||||
{ we need to take care that we use the type of the defined parameter and not of the
|
{ we need to take care that we use the type of the defined parameter and not of the
|
||||||
@ -2214,11 +2223,10 @@ type
|
|||||||
createblock:=internalstatements(createstatement);
|
createblock:=internalstatements(createstatement);
|
||||||
deleteblock:=internalstatements(deletestatement);
|
deleteblock:=internalstatements(deletestatement);
|
||||||
|
|
||||||
{ add methodpointer init/fini code to init/done statements }
|
{ add methodpointer init code to init statement }
|
||||||
|
{ (fini must be done later, as it will delete the hookoncopy info) }
|
||||||
if assigned(methodpointerinit) then
|
if assigned(methodpointerinit) then
|
||||||
addstatement(createstatement,methodpointerinit.getcopy);
|
addstatement(createstatement,methodpointerinit.getcopy);
|
||||||
if assigned(methodpointerdone) then
|
|
||||||
addstatement(deletestatement,methodpointerdone.getcopy);
|
|
||||||
|
|
||||||
inlinelocals:=tlist.create;
|
inlinelocals:=tlist.create;
|
||||||
{ get copy of the procedure body }
|
{ get copy of the procedure body }
|
||||||
@ -2227,6 +2235,11 @@ type
|
|||||||
createinlineparas(createstatement,deletestatement);
|
createinlineparas(createstatement,deletestatement);
|
||||||
{ replace the parameter loads with the parameter values }
|
{ replace the parameter loads with the parameter values }
|
||||||
foreachnode(body,@replaceparaload,@fileinfo);
|
foreachnode(body,@replaceparaload,@fileinfo);
|
||||||
|
|
||||||
|
{ copy methodpointer fini code }
|
||||||
|
if assigned(methodpointerdone) then
|
||||||
|
addstatement(deletestatement,methodpointerdone.getcopy);
|
||||||
|
|
||||||
{ free the temps for the locals }
|
{ free the temps for the locals }
|
||||||
for i := 0 to inlinelocals.count-1 do
|
for i := 0 to inlinelocals.count-1 do
|
||||||
if assigned(inlinelocals[i]) then
|
if assigned(inlinelocals[i]) then
|
||||||
@ -2249,6 +2262,12 @@ type
|
|||||||
include(procdefinition.procoptions,po_inline);
|
include(procdefinition.procoptions,po_inline);
|
||||||
{ return inlined block }
|
{ return inlined block }
|
||||||
result := createblock;
|
result := createblock;
|
||||||
|
|
||||||
|
{$ifdef DEBUGINLINE}
|
||||||
|
writeln;
|
||||||
|
writeln('**************************',tprocdef(procdefinition).mangledname);
|
||||||
|
printnode(output,result);
|
||||||
|
{$endif DEBUGINLINE}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user