mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 13:06:18 +02:00
* moved "reverseparameters" from ninl.pas to ncal.pas
+ support for non-persistent temps in ttempcreatenode.create, for use with typeconversion nodes
This commit is contained in:
parent
808ab9e7e7
commit
fc1b58c22c
@ -80,16 +80,25 @@ interface
|
|||||||
valid: boolean;
|
valid: boolean;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ a node which will create a *persistent* temp of a given type with a given size }
|
{ a node which will create a (non)persistent temp of a given type with a given }
|
||||||
{ (the size is separate to allow creating "void" temps with a custom size) }
|
{ size (the size is separate to allow creating "void" temps with a custom size) }
|
||||||
ttempcreatenode = class(tnode)
|
ttempcreatenode = class(tnode)
|
||||||
size: longint;
|
size: longint;
|
||||||
tempinfo: ptempinfo;
|
tempinfo: ptempinfo;
|
||||||
constructor create(const _restype: ttype; _size: longint); virtual;
|
{ * persistent temps are used in manually written code where the temp }
|
||||||
|
{ be usable among different statements and where you can manually say }
|
||||||
|
{ when the temp has to be freed (using a ttempdeletenode) }
|
||||||
|
{ * non-persistent temps are mostly used in typeconversion helpers, }
|
||||||
|
{ where the node that receives the temp becomes responsible for }
|
||||||
|
{ freeing it. In this last case, you should use only one reference }
|
||||||
|
{ to it and *not* generate a ttempdeletenode }
|
||||||
|
constructor create(const _restype: ttype; _size: longint; _persistent: boolean); virtual;
|
||||||
function getcopy: tnode; override;
|
function getcopy: tnode; override;
|
||||||
function pass_1 : tnode; override;
|
function pass_1 : tnode; override;
|
||||||
function det_resulttype: tnode; override;
|
function det_resulttype: tnode; override;
|
||||||
function docompare(p: tnode): boolean; override;
|
function docompare(p: tnode): boolean; override;
|
||||||
|
protected
|
||||||
|
persistent: boolean;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ a node which is a reference to a certain temp }
|
{ a node which is a reference to a certain temp }
|
||||||
@ -442,13 +451,14 @@ implementation
|
|||||||
TEMPCREATENODE
|
TEMPCREATENODE
|
||||||
*****************************************************************************}
|
*****************************************************************************}
|
||||||
|
|
||||||
constructor ttempcreatenode.create(const _restype: ttype; _size: longint);
|
constructor ttempcreatenode.create(const _restype: ttype; _size: longint; _persistent: boolean);
|
||||||
begin
|
begin
|
||||||
inherited create(tempn);
|
inherited create(tempn);
|
||||||
size := _size;
|
size := _size;
|
||||||
new(tempinfo);
|
new(tempinfo);
|
||||||
fillchar(tempinfo^,sizeof(tempinfo^),0);
|
fillchar(tempinfo^,sizeof(tempinfo^),0);
|
||||||
tempinfo^.restype := _restype;
|
tempinfo^.restype := _restype;
|
||||||
|
persistent := _persistent;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ttempcreatenode.getcopy: tnode;
|
function ttempcreatenode.getcopy: tnode;
|
||||||
@ -610,7 +620,12 @@ begin
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.14 2001-08-23 14:28:35 jonas
|
Revision 1.15 2001-08-24 13:47:26 jonas
|
||||||
|
* moved "reverseparameters" from ninl.pas to ncal.pas
|
||||||
|
+ support for non-persistent temps in ttempcreatenode.create, for use
|
||||||
|
with typeconversion nodes
|
||||||
|
|
||||||
|
Revision 1.14 2001/08/23 14:28:35 jonas
|
||||||
+ tempcreate/ref/delete nodes (allows the use of temps in the
|
+ tempcreate/ref/delete nodes (allows the use of temps in the
|
||||||
resulttype and first pass)
|
resulttype and first pass)
|
||||||
* made handling of read(ln)/write(ln) processor independent
|
* made handling of read(ln)/write(ln) processor independent
|
||||||
|
@ -96,6 +96,9 @@ interface
|
|||||||
function docompare(p: tnode): boolean; override;
|
function docompare(p: tnode): boolean; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function reverseparameters(p: tcallparanode): tcallparanode;
|
||||||
|
|
||||||
|
|
||||||
var
|
var
|
||||||
ccallnode : class of tcallnode;
|
ccallnode : class of tcallnode;
|
||||||
ccallparanode : class of tcallparanode;
|
ccallparanode : class of tcallparanode;
|
||||||
@ -116,6 +119,29 @@ implementation
|
|||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
{****************************************************************************
|
||||||
|
HELPERS
|
||||||
|
****************************************************************************}
|
||||||
|
|
||||||
|
function reverseparameters(p: tcallparanode): tcallparanode;
|
||||||
|
var
|
||||||
|
hp1, hp2: tcallparanode;
|
||||||
|
begin
|
||||||
|
hp1:=nil;
|
||||||
|
while assigned(p) do
|
||||||
|
begin
|
||||||
|
{ pull out }
|
||||||
|
hp2:=p;
|
||||||
|
p:=tcallparanode(p.right);
|
||||||
|
{ pull in }
|
||||||
|
hp2.right:=hp1;
|
||||||
|
hp1:=hp2;
|
||||||
|
end;
|
||||||
|
reverseparameters:=hp1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{****************************************************************************
|
{****************************************************************************
|
||||||
TCALLPARANODE
|
TCALLPARANODE
|
||||||
****************************************************************************}
|
****************************************************************************}
|
||||||
@ -1691,7 +1717,12 @@ begin
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.43 2001-08-23 14:28:35 jonas
|
Revision 1.44 2001-08-24 13:47:27 jonas
|
||||||
|
* moved "reverseparameters" from ninl.pas to ncal.pas
|
||||||
|
+ support for non-persistent temps in ttempcreatenode.create, for use
|
||||||
|
with typeconversion nodes
|
||||||
|
|
||||||
|
Revision 1.43 2001/08/23 14:28:35 jonas
|
||||||
+ tempcreate/ref/delete nodes (allows the use of temps in the
|
+ tempcreate/ref/delete nodes (allows the use of temps in the
|
||||||
resulttype and first pass)
|
resulttype and first pass)
|
||||||
* made handling of read(ln)/write(ln) processor independent
|
* made handling of read(ln)/write(ln) processor independent
|
||||||
|
@ -242,7 +242,10 @@ interface
|
|||||||
internalerror(200108222);
|
internalerror(200108222);
|
||||||
|
|
||||||
{ get a (persistent) temp }
|
{ get a (persistent) temp }
|
||||||
gettempofsizereferencepersistant(size,tempinfo^.ref);
|
if persistent then
|
||||||
|
gettempofsizereferencepersistant(size,tempinfo^.ref)
|
||||||
|
else
|
||||||
|
gettempofsizereference(size,tempinfo^.ref);
|
||||||
tempinfo^.valid := true;
|
tempinfo^.valid := true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -282,7 +285,12 @@ begin
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.5 2001-08-23 14:28:35 jonas
|
Revision 1.6 2001-08-24 13:47:27 jonas
|
||||||
|
* moved "reverseparameters" from ninl.pas to ncal.pas
|
||||||
|
+ support for non-persistent temps in ttempcreatenode.create, for use
|
||||||
|
with typeconversion nodes
|
||||||
|
|
||||||
|
Revision 1.5 2001/08/23 14:28:35 jonas
|
||||||
+ tempcreate/ref/delete nodes (allows the use of temps in the
|
+ tempcreate/ref/delete nodes (allows the use of temps in the
|
||||||
resulttype and first pass)
|
resulttype and first pass)
|
||||||
* made handling of read(ln)/write(ln) processor independent
|
* made handling of read(ln)/write(ln) processor independent
|
||||||
|
@ -99,24 +99,6 @@ implementation
|
|||||||
|
|
||||||
{$ifdef hascompilerproc}
|
{$ifdef hascompilerproc}
|
||||||
|
|
||||||
{ helper, doesn't really belong here (JM) }
|
|
||||||
function reverseparameters(p: tcallparanode): tcallparanode;
|
|
||||||
var
|
|
||||||
hp1, hp2: tcallparanode;
|
|
||||||
begin
|
|
||||||
hp1:=nil;
|
|
||||||
while assigned(p) do
|
|
||||||
begin
|
|
||||||
{ pull out }
|
|
||||||
hp2:=p;
|
|
||||||
p:=tcallparanode(p.right);
|
|
||||||
{ pull in }
|
|
||||||
hp2.right:=hp1;
|
|
||||||
hp1:=hp2;
|
|
||||||
end;
|
|
||||||
reverseparameters:=hp1;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function tinlinenode.handle_str : tnode;
|
function tinlinenode.handle_str : tnode;
|
||||||
var
|
var
|
||||||
lenpara,
|
lenpara,
|
||||||
@ -394,7 +376,7 @@ implementation
|
|||||||
if (filepara.left.nodetype <> loadn) then
|
if (filepara.left.nodetype <> loadn) then
|
||||||
begin
|
begin
|
||||||
{ create a temp which will hold a pointer to the file }
|
{ create a temp which will hold a pointer to the file }
|
||||||
filetemp := ctempcreatenode.create(voidpointertype,voidpointertype.def.size);
|
filetemp := ctempcreatenode.create(voidpointertype,voidpointertype.def.size,true);
|
||||||
|
|
||||||
{ add it to the statements }
|
{ add it to the statements }
|
||||||
newstatement.left := cstatementnode.create(nil,filetemp);
|
newstatement.left := cstatementnode.create(nil,filetemp);
|
||||||
@ -704,7 +686,7 @@ implementation
|
|||||||
restype := @u32bittype;
|
restype := @u32bittype;
|
||||||
|
|
||||||
{ create the parameter list: the temp ... }
|
{ create the parameter list: the temp ... }
|
||||||
temp := ctempcreatenode.create(restype^,restype^.def.size);
|
temp := ctempcreatenode.create(restype^,restype^.def.size,true);
|
||||||
newstatement.left := cstatementnode.create(nil,temp);
|
newstatement.left := cstatementnode.create(nil,temp);
|
||||||
newstatement := tstatementnode(newstatement.left);
|
newstatement := tstatementnode(newstatement.left);
|
||||||
|
|
||||||
@ -879,7 +861,7 @@ implementation
|
|||||||
if not assigned(codepara) or
|
if not assigned(codepara) or
|
||||||
(torddef(codepara.resulttype.def).typ in [u8bit,u16bit,s8bit,s16bit]) then
|
(torddef(codepara.resulttype.def).typ in [u8bit,u16bit,s8bit,s16bit]) then
|
||||||
begin
|
begin
|
||||||
tempcode := ctempcreatenode.create(s32bittype,4);
|
tempcode := ctempcreatenode.create(s32bittype,4,true);
|
||||||
newstatement.left := cstatementnode.create(nil,tempcode);
|
newstatement.left := cstatementnode.create(nil,tempcode);
|
||||||
newstatement := tstatementnode(newstatement.left);
|
newstatement := tstatementnode(newstatement.left);
|
||||||
{ set the resulttype of the temp (needed to be able to get }
|
{ set the resulttype of the temp (needed to be able to get }
|
||||||
@ -2730,7 +2712,12 @@ begin
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.50 2001-08-24 12:33:54 jonas
|
Revision 1.51 2001-08-24 13:47:27 jonas
|
||||||
|
* moved "reverseparameters" from ninl.pas to ncal.pas
|
||||||
|
+ support for non-persistent temps in ttempcreatenode.create, for use
|
||||||
|
with typeconversion nodes
|
||||||
|
|
||||||
|
Revision 1.50 2001/08/24 12:33:54 jonas
|
||||||
* fixed big bug in handle_str that caused it to (almost) always call
|
* fixed big bug in handle_str that caused it to (almost) always call
|
||||||
fpc_<stringtype>_longint
|
fpc_<stringtype>_longint
|
||||||
* fixed small bug in handle_read_write that caused wrong warnigns about
|
* fixed small bug in handle_read_write that caused wrong warnigns about
|
||||||
|
Loading…
Reference in New Issue
Block a user