* make fparainit and fparacopyback public

+ process fparainit and fparacopyback in foreachnode
  + print fparainit and fparacopyback
  + do not break if tcallparanode.copy_value_by_ref_para is called multiple times

git-svn-id: trunk@45236 -
This commit is contained in:
florian 2020-05-03 20:37:07 +00:00
parent 8d1660893b
commit b80d051249
2 changed files with 49 additions and 7 deletions

View File

@ -228,18 +228,17 @@ interface
private
fcontains_stack_tainting_call_cached,
ffollowed_by_stack_tainting_call_cached : boolean;
protected
{ in case of copy-out parameters: initialization code, and the code to
copy back the parameter value after the call (including any required
finalization code) }
fparainit,
fparacopyback: tnode;
procedure handlemanagedbyrefpara(orgparadef: tdef);virtual;
{ on some targets, value parameters that are passed by reference must
be copied to a temp location by the caller (and then a reference to
this temp location must be passed) }
procedure copy_value_by_ref_para;
public
{ in case of copy-out parameters: initialization code, and the code to
copy back the parameter value after the call (including any required
finalization code) }
fparainit,
fparacopyback: tnode;
callparaflags : tcallparaflags;
parasym : tparavarsym;
{ only the processor specific nodes need to override this }
@ -745,6 +744,9 @@ implementation
to be copied by the caller. It's basically the node-level equivalent
of thlcgobj.g_copyvalueparas }
if assigned(fparainit) then
exit;
{ in case of an array constructor, we don't need a copy since the array
constructor itself is already constructed on the fly (and hence if
it's modified by the caller, that's no problem) }
@ -1462,8 +1464,38 @@ implementation
procedure tcallparanode.printnodetree(var t:text);
var
hp: tbinarynode;
begin
printnodelist(t);
hp:=self;
while assigned(hp) do
begin
write(t,printnodeindention,'(');
printnodeindent;
hp.printnodeinfo(t);
writeln(t);
if assigned(tcallparanode(hp).fparainit) then
begin
writeln(t,printnodeindention,'(parainit =');
printnodeindent;
printnode(t,tcallparanode(hp).fparainit);
printnodeunindent;
writeln(t,printnodeindention,')');
end;
if assigned(tcallparanode(hp).fparacopyback) then
begin
writeln(t,printnodeindention,'(fparacopyback =');
printnodeindent;
printnode(t,tcallparanode(hp).fparacopyback);
printnodeunindent;
writeln(t,printnodeindention,')');
end;
printnode(t,hp.left);
writeln(t);
printnodeunindent;
writeln(t,printnodeindention,')');
hp:=tbinarynode(hp.right);
end;
end;

View File

@ -219,6 +219,11 @@ implementation
result := foreachnode(procmethod,tcallnode(n).funcretnode,f,arg) or result;
result := foreachnode(procmethod,tnode(tcallnode(n).callcleanupblock),f,arg) or result;
end;
callparan:
begin
result := foreachnode(procmethod,tnode(tcallparanode(n).fparainit),f,arg) or result;
result := foreachnode(procmethod,tcallparanode(n).fparacopyback,f,arg) or result;
end;
ifn, whilerepeatn, forn, tryexceptn:
begin
{ not in one statement, won't work because of b- }
@ -322,6 +327,11 @@ implementation
result := foreachnodestatic(procmethod,tcallnode(n).funcretnode,f,arg) or result;
result := foreachnodestatic(procmethod,tnode(tcallnode(n).callcleanupblock),f,arg) or result;
end;
callparan:
begin
result := foreachnodestatic(procmethod,tnode(tcallparanode(n).fparainit),f,arg) or result;
result := foreachnodestatic(procmethod,tcallparanode(n).fparacopyback,f,arg) or result;
end;
ifn, whilerepeatn, forn, tryexceptn:
begin
{ not in one statement, won't work because of b- }