mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 18:29:13 +02:00
* moved creating block/statement for reference temps into
maybereplacewithtempref() helper git-svn-id: branches/jvmbackend@18591 -
This commit is contained in:
parent
ad6ae44093
commit
4be0ba267a
@ -366,11 +366,11 @@ implementation
|
|||||||
{ start with org (save assignmenttarget itself to assign the result back to) }
|
{ start with org (save assignmenttarget itself to assign the result back to) }
|
||||||
{ store left into a temp in case it may contain a function call
|
{ store left into a temp in case it may contain a function call
|
||||||
(which must not be evaluated twice) }
|
(which must not be evaluated twice) }
|
||||||
lefttemp:=maybereplacewithtempref(tcallparanode(left).left,tcallparanode(left).left.resultdef.size,false);
|
newblock:=nil;
|
||||||
|
newstatement:=nil;
|
||||||
|
lefttemp:=maybereplacewithtempref(tcallparanode(left).left,newblock,newstatement,tcallparanode(left).left.resultdef.size,false);
|
||||||
if assigned(lefttemp) then
|
if assigned(lefttemp) then
|
||||||
begin
|
begin
|
||||||
newblock:=internalstatements(newstatement);
|
|
||||||
addstatement(newstatement,lefttemp);
|
|
||||||
assignmenttarget:=ctemprefnode.create(lefttemp);
|
assignmenttarget:=ctemprefnode.create(lefttemp);
|
||||||
typecheckpass(tnode(assignmenttarget));
|
typecheckpass(tnode(assignmenttarget));
|
||||||
end
|
end
|
||||||
@ -461,11 +461,11 @@ implementation
|
|||||||
stringtype:=tstringdef(left.resultdef);
|
stringtype:=tstringdef(left.resultdef);
|
||||||
{ store left into a temp in case it may contain a function call
|
{ store left into a temp in case it may contain a function call
|
||||||
(which must not be evaluated twice) }
|
(which must not be evaluated twice) }
|
||||||
lefttemp:=maybereplacewithtempref(tcallparanode(left).left,stringtype.size,false);
|
newblock:=nil;
|
||||||
|
newstatement:=nil;
|
||||||
|
lefttemp:=maybereplacewithtempref(tcallparanode(left).left,newblock,newstatement,stringtype.size,false);
|
||||||
if assigned(lefttemp) then
|
if assigned(lefttemp) then
|
||||||
begin
|
begin
|
||||||
newblock:=internalstatements(newstatement);
|
|
||||||
addstatement(newstatement,lefttemp);
|
|
||||||
assignmenttarget:=ctemprefnode.create(lefttemp);
|
assignmenttarget:=ctemprefnode.create(lefttemp);
|
||||||
typecheckpass(tnode(assignmenttarget));
|
typecheckpass(tnode(assignmenttarget));
|
||||||
end
|
end
|
||||||
|
@ -257,7 +257,7 @@ interface
|
|||||||
|
|
||||||
{ if the complexity of n is "high", creates a reference temp to n's
|
{ if the complexity of n is "high", creates a reference temp to n's
|
||||||
location and replace n with a ttemprefnode referring to that location }
|
location and replace n with a ttemprefnode referring to that location }
|
||||||
function maybereplacewithtempref(var n: tnode; size: ASizeInt; readonly: boolean): ttempcreatenode;
|
function maybereplacewithtempref(var n: tnode; var block: tblocknode; var stat: tstatementnode; size: ASizeInt; readonly: boolean): ttempcreatenode;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@ -300,7 +300,7 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function maybereplacewithtempref(var n: tnode; size: ASizeInt; readonly: boolean): ttempcreatenode;
|
function maybereplacewithtempref(var n: tnode; var block: tblocknode; var stat: tstatementnode; size: ASizeInt; readonly: boolean): ttempcreatenode;
|
||||||
begin
|
begin
|
||||||
result:=nil;
|
result:=nil;
|
||||||
if node_complexity(n) > 4 then
|
if node_complexity(n) > 4 then
|
||||||
@ -309,6 +309,9 @@ implementation
|
|||||||
typecheckpass(tnode(result));
|
typecheckpass(tnode(result));
|
||||||
n:=ctemprefnode.create(result);
|
n:=ctemprefnode.create(result);
|
||||||
typecheckpass(n);
|
typecheckpass(n);
|
||||||
|
if not assigned(stat) then
|
||||||
|
block:=internalstatements(stat);
|
||||||
|
addstatement(stat,result)
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user