* bug #701 fixed: ansistrings in interface and implementation part of the units

are now finalized correctly even if there are no explicit initialization/
    finalization statements
This commit is contained in:
florian 2000-04-02 10:18:18 +00:00
parent b16a589d24
commit 339d986a2a
2 changed files with 72 additions and 2 deletions

View File

@ -133,6 +133,11 @@ unit cgai386;
procedure genexitcode(alist : paasmoutput;parasize:longint;
nostackframe,inlined:boolean);
{ if a unit doesn't have a explicit init/final code, }
{ we've to generate one, if the units has ansistrings }
{ in the interface or implementation }
procedure genimplicitunitfinal(alist : paasmoutput);
procedure genimplicitunitinit(alist : paasmoutput);
{$ifdef test_dest_loc}
const
@ -3827,7 +3832,41 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
exprasmlist:=oldexprasmlist;
end;
procedure genimplicitunitfinal(alist : paasmoutput);
begin
{ using current_module^.globalsymtable is hopefully }
{ more robust than symtablestack and symtablestack^.next }
psymtable(current_module^.globalsymtable)^.foreach({$ifndef TP}@{$endif}finalize_data);
psymtable(current_module^.localsymtable)^.foreach({$ifndef TP}@{$endif}finalize_data);
exprasmlist^.insert(new(pai_symbol,initname_global('FINALIZE$$'+current_module^.modulename^,0)));
exprasmlist^.insert(new(pai_symbol,initname_global(target_os.cprefix+current_module^.modulename^+'_finalize',0)));
{$ifdef GDB}
if (cs_debuginfo in aktmoduleswitches) and
target_os.use_function_relative_addresses then
exprasmlist^.insert(new(pai_stab_function_name,init(strpnew('FINALIZE$$'+current_module^.modulename^))));
{$endif GDB}
exprasmlist^.concat(new(paicpu,op_none(A_RET,S_NO)));
alist^.concatlist(exprasmlist);
end;
procedure genimplicitunitinit(alist : paasmoutput);
begin
{ using current_module^.globalsymtable is hopefully }
{ more robust than symtablestack and symtablestack^.next }
psymtable(current_module^.globalsymtable)^.foreach({$ifndef TP}@{$endif}finalize_data);
psymtable(current_module^.localsymtable)^.foreach({$ifndef TP}@{$endif}finalize_data);
exprasmlist^.insert(new(pai_symbol,initname_global('INIT$$'+current_module^.modulename^,0)));
exprasmlist^.insert(new(pai_symbol,initname_global(target_os.cprefix+current_module^.modulename^+'_init',0)));
{$ifdef GDB}
if (cs_debuginfo in aktmoduleswitches) and
target_os.use_function_relative_addresses then
exprasmlist^.insert(new(pai_stab_function_name,init(strpnew('INIT$$'+current_module^.modulename^))));
{$endif GDB}
exprasmlist^.concat(new(paicpu,op_none(A_RET,S_NO)));
alist^.concatlist(exprasmlist);
end;
{$ifdef test_dest_loc}
procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
@ -3855,7 +3894,12 @@ procedure mov_reg_to_dest(p : ptree; s : topsize; reg : tregister);
end.
{
$Log$
Revision 1.92 2000-04-01 14:18:45 peter
Revision 1.93 2000-04-02 10:18:18 florian
* bug 701 fixed: ansistrings in interface and implementation part of the units
are now finalized correctly even if there are no explicit initialization/
finalization statements
Revision 1.92 2000/04/01 14:18:45 peter
* use arraydef.elesize instead of elementtype.def.size
Revision 1.91 2000/03/31 22:56:46 pierre

View File

@ -49,6 +49,9 @@ unit pmodules;
cgbase,
{$else newcg}
hcodegen,
{$ifdef i386}
cgai386,
{$endif i386}
{$endif newcg}
link,assemble,import,export,gendef,ppu,comprsrc,
cresstr,cpubase,cpuasm,
@ -1203,6 +1206,16 @@ unit pmodules;
force_init_final:=needs_init_final(current_module^.globalsymtable)
or needs_init_final(current_module^.localsymtable);
{ should we force unit initialization? }
{ this is a hack, but how can it be done better ? }
if force_init_final and ((current_module^.flags and uf_init)=0) then
begin
current_module^.flags:=current_module^.flags or uf_init;
{ now we can insert a cut }
if (cs_create_smart in aktmoduleswitches) then
codesegment^.concat(new(pai_cut,init));
genimplicitunitinit(codesegment);
end;
{ finalize? }
if token=_FINALIZATION then
begin
@ -1229,6 +1242,14 @@ unit pmodules;
names.done;
{$endif fixLeaksOnError}
codegen_doneprocedure;
end
else if force_init_final then
begin
current_module^.flags:=current_module^.flags or uf_finalize;
{ now we can insert a cut }
if (cs_create_smart in aktmoduleswitches) then
codesegment^.concat(new(pai_cut,init));
genimplicitunitfinal(codesegment);
end;
{ the last char should always be a point }
@ -1639,7 +1660,12 @@ unit pmodules;
end.
{
$Log$
Revision 1.186 2000-03-01 15:36:11 florian
Revision 1.187 2000-04-02 10:18:18 florian
* bug 701 fixed: ansistrings in interface and implementation part of the units
are now finalized correctly even if there are no explicit initialization/
finalization statements
Revision 1.186 2000/03/01 15:36:11 florian
* some new stuff for the new cg
Revision 1.185 2000/02/09 13:22:57 peter