mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-13 11:19:58 +02:00
* finalize all (also procedure local) typedconst at unit finalization
This commit is contained in:
parent
384e764831
commit
180c042911
@ -819,14 +819,25 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ generates the code for finalisation of local data }
|
procedure finalize_sym(asmlist:taasmoutput;sym:tsym);
|
||||||
procedure finalize_data(p : tnamedindexitem;arg:pointer);
|
|
||||||
var
|
var
|
||||||
oldexprasmlist : TAAsmoutput;
|
|
||||||
hp : tnode;
|
hp : tnode;
|
||||||
dofinalize : boolean;
|
oldexprasmlist : TAAsmoutput;
|
||||||
|
begin
|
||||||
|
include(current_procinfo.flags,pi_needs_implicit_finally);
|
||||||
|
oldexprasmlist:=exprasmlist;
|
||||||
|
exprasmlist:=asmlist;
|
||||||
|
hp:=finalize_data_node(cloadnode.create(sym,sym.owner));
|
||||||
|
firstpass(hp);
|
||||||
|
secondpass(hp);
|
||||||
|
hp.free;
|
||||||
|
exprasmlist:=oldexprasmlist;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{ generates the code for finalisation of local variables }
|
||||||
|
procedure finalize_local_vars(p : tnamedindexitem;arg:pointer);
|
||||||
begin
|
begin
|
||||||
dofinalize:=false;
|
|
||||||
case tsym(p).typ of
|
case tsym(p).typ of
|
||||||
varsym :
|
varsym :
|
||||||
begin
|
begin
|
||||||
@ -834,28 +845,72 @@ implementation
|
|||||||
not(vo_is_funcret in tvarsym(p).varoptions) and
|
not(vo_is_funcret in tvarsym(p).varoptions) and
|
||||||
not(is_class(tvarsym(p).vartype.def)) and
|
not(is_class(tvarsym(p).vartype.def)) and
|
||||||
tvarsym(p).vartype.def.needs_inittable then
|
tvarsym(p).vartype.def.needs_inittable then
|
||||||
dofinalize:=true;
|
finalize_sym(taasmoutput(arg),tsym(p));
|
||||||
end;
|
end;
|
||||||
{
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{ generates the code for finalisation of local typedconsts }
|
||||||
|
procedure finalize_local_typedconst(p : tnamedindexitem;arg:pointer);
|
||||||
|
var
|
||||||
|
i : longint;
|
||||||
|
pd : tprocdef;
|
||||||
|
begin
|
||||||
|
case tsym(p).typ of
|
||||||
typedconstsym :
|
typedconstsym :
|
||||||
begin
|
begin
|
||||||
if ttypedconstsym(p).is_writable and
|
if ttypedconstsym(p).is_writable and
|
||||||
ttypedconstsym(p).typedconsttype.def.needs_inittable then
|
ttypedconstsym(p).typedconsttype.def.needs_inittable then
|
||||||
dofinalize:=true;
|
finalize_sym(taasmoutput(arg),tsym(p));
|
||||||
|
end;
|
||||||
|
procsym :
|
||||||
|
begin
|
||||||
|
for i:=1 to tprocsym(p).procdef_count do
|
||||||
|
begin
|
||||||
|
pd:=tprocsym(p).procdef[i];
|
||||||
|
if assigned(pd.localst) and
|
||||||
|
(pd.localst.symtabletype<>staticsymtable) then
|
||||||
|
pd.localst.foreach_static(@finalize_local_typedconst,arg);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{ generates the code for finalization of static symtable and
|
||||||
|
all local (static) typedconsts }
|
||||||
|
procedure finalize_static_data(p : tnamedindexitem;arg:pointer);
|
||||||
|
var
|
||||||
|
i : longint;
|
||||||
|
pd : tprocdef;
|
||||||
|
begin
|
||||||
|
case tsym(p).typ of
|
||||||
|
varsym :
|
||||||
|
begin
|
||||||
|
if (tvarsym(p).refs>0) and
|
||||||
|
not(vo_is_funcret in tvarsym(p).varoptions) and
|
||||||
|
not(is_class(tvarsym(p).vartype.def)) and
|
||||||
|
tvarsym(p).vartype.def.needs_inittable then
|
||||||
|
finalize_sym(taasmoutput(arg),tsym(p));
|
||||||
|
end;
|
||||||
|
typedconstsym :
|
||||||
|
begin
|
||||||
|
if ttypedconstsym(p).is_writable and
|
||||||
|
ttypedconstsym(p).typedconsttype.def.needs_inittable then
|
||||||
|
finalize_sym(taasmoutput(arg),tsym(p));
|
||||||
|
end;
|
||||||
|
procsym :
|
||||||
|
begin
|
||||||
|
for i:=1 to tprocsym(p).procdef_count do
|
||||||
|
begin
|
||||||
|
pd:=tprocsym(p).procdef[i];
|
||||||
|
if assigned(pd.localst) and
|
||||||
|
(pd.localst.symtabletype<>staticsymtable) then
|
||||||
|
pd.localst.foreach_static(@finalize_local_typedconst,arg);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
}
|
|
||||||
end;
|
end;
|
||||||
if dofinalize then
|
|
||||||
begin
|
|
||||||
include(current_procinfo.flags,pi_needs_implicit_finally);
|
|
||||||
oldexprasmlist:=exprasmlist;
|
|
||||||
exprasmlist:=taasmoutput(arg);
|
|
||||||
hp:=finalize_data_node(cloadnode.create(tsym(p),tsym(p).owner));
|
|
||||||
firstpass(hp);
|
|
||||||
secondpass(hp);
|
|
||||||
hp.free;
|
|
||||||
exprasmlist:=oldexprasmlist;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -1210,15 +1265,15 @@ implementation
|
|||||||
{ this is also used for initialization of variables in a
|
{ this is also used for initialization of variables in a
|
||||||
program which does not have a globalsymtable }
|
program which does not have a globalsymtable }
|
||||||
if assigned(current_module.globalsymtable) then
|
if assigned(current_module.globalsymtable) then
|
||||||
tsymtable(current_module.globalsymtable).foreach_static({$ifndef TP}@{$endif}finalize_data,list);
|
tsymtable(current_module.globalsymtable).foreach_static({$ifndef TP}@{$endif}finalize_static_data,list);
|
||||||
tsymtable(current_module.localsymtable).foreach_static({$ifndef TP}@{$endif}finalize_data,list);
|
tsymtable(current_module.localsymtable).foreach_static({$ifndef TP}@{$endif}finalize_static_data,list);
|
||||||
end;
|
end;
|
||||||
{ units/progs have separate code for initialization and finalization }
|
{ units/progs have separate code for initialization and finalization }
|
||||||
potype_unitinit: ;
|
potype_unitinit: ;
|
||||||
{ program init/final is generated in separate procedure }
|
{ program init/final is generated in separate procedure }
|
||||||
potype_proginit: ;
|
potype_proginit: ;
|
||||||
else
|
else
|
||||||
current_procinfo.procdef.localst.foreach_static({$ifndef TP}@{$endif}finalize_data,list);
|
current_procinfo.procdef.localst.foreach_static({$ifndef TP}@{$endif}finalize_local_vars,list);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ finalize paras data }
|
{ finalize paras data }
|
||||||
@ -2091,7 +2146,10 @@ implementation
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.213 2004-08-23 11:00:06 michael
|
Revision 1.214 2004-09-13 20:30:05 peter
|
||||||
|
* finalize all (also procedure local) typedconst at unit finalization
|
||||||
|
|
||||||
|
Revision 1.213 2004/08/23 11:00:06 michael
|
||||||
+ Patch from Peter to fix debuginfo in constructor.
|
+ Patch from Peter to fix debuginfo in constructor.
|
||||||
|
|
||||||
Revision 1.212 2004/07/17 13:14:17 jonas
|
Revision 1.212 2004/07/17 13:14:17 jonas
|
||||||
|
Loading…
Reference in New Issue
Block a user