|
@@ -341,7 +341,7 @@ implementation
|
|
|
ppu,
|
|
|
symconst,symdef,defutil,defcmp,
|
|
|
pass_1,
|
|
|
- nutils,nld,
|
|
|
+ nutils,nld,ncnv,
|
|
|
procinfo
|
|
|
{$ifdef DEBUG_NODE_XML}
|
|
|
{$ifndef jvm}
|
|
@@ -696,13 +696,24 @@ implementation
|
|
|
end;
|
|
|
|
|
|
|
|
|
+ function NodesEqual(var n: tnode; arg: pointer): foreachnoderesult;
|
|
|
+ begin
|
|
|
+ if n.IsEqual(tnode(arg)) then
|
|
|
+ result:=fen_norecurse_true
|
|
|
+ else
|
|
|
+ result:=fen_false;
|
|
|
+ end;
|
|
|
+
|
|
|
+
|
|
|
function tblocknode.simplify(forinline : boolean): tnode;
|
|
|
+ var
|
|
|
+ a : array[0..3] of tstatementnode;
|
|
|
begin
|
|
|
result := nil;
|
|
|
- { Warning: never replace a blocknode with another node type, }
|
|
|
- { since the block may be the main block of a procedure/function/ }
|
|
|
- { main program body, and those nodes should always be blocknodes }
|
|
|
- { since that's what the compiler expects elsewhere. }
|
|
|
+ { Warning: never replace a blocknode with another node type,
|
|
|
+ since the block may be the main block of a procedure/function/
|
|
|
+ main program body, and those nodes should always be blocknodes
|
|
|
+ since that's what the compiler expects elsewhere. }
|
|
|
|
|
|
if assigned(left) and
|
|
|
not assigned(tstatementnode(left).right) then
|
|
@@ -731,6 +742,25 @@ implementation
|
|
|
;
|
|
|
end;
|
|
|
end;
|
|
|
+ { simple sequence of tempcreate, assign and return temp.? }
|
|
|
+ if GetStatements(left,a) and
|
|
|
+ (a[0].left.nodetype=tempcreaten) and
|
|
|
+ (a[1].left.nodetype=assignn) and
|
|
|
+ (actualtargetnode(@tassignmentnode(a[1].left).left)^.nodetype=temprefn) and
|
|
|
+ (a[2].left.nodetype=tempdeleten) and
|
|
|
+ (a[3].left.nodetype=temprefn) and
|
|
|
+ (ttempcreatenode(a[0].left).tempinfo=ttemprefnode(actualtargetnode(@tassignmentnode(a[1].left).left)^).tempinfo) and
|
|
|
+ (ttempcreatenode(a[0].left).tempinfo=ttempdeletenode(a[2].left).tempinfo) and
|
|
|
+ (ttempcreatenode(a[0].left).tempinfo=ttemprefnode(a[3].left).tempinfo) and
|
|
|
+ { the temp. node might not be references inside the assigned expression }
|
|
|
+ not(foreachnodestatic(tassignmentnode(a[1].left).right,@NodesEqual,actualtargetnode(@tassignmentnode(a[1].left).left)^)) then
|
|
|
+ begin
|
|
|
+ result:=tassignmentnode(a[1].left).right;
|
|
|
+ tassignmentnode(a[1].left).right:=nil;
|
|
|
+ result:=ctypeconvnode.create_internal(result,ttemprefnode(a[3].left).resultdef);
|
|
|
+ firstpass(result);
|
|
|
+ exit;
|
|
|
+ end;
|
|
|
end;
|
|
|
|
|
|
|