mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-21 20:29:32 +02:00
* fixed unitsym-globalsymtable relation so the uses of a unit
is counted correctly
This commit is contained in:
parent
37762b957f
commit
fcabdbbf35
@ -42,7 +42,7 @@ interface
|
||||
uses
|
||||
cutils,cclasses,
|
||||
globals,finput,
|
||||
symbase,aasmbase;
|
||||
symbase,symsym,aasmbase;
|
||||
|
||||
|
||||
type
|
||||
@ -76,8 +76,11 @@ interface
|
||||
tmodule = class;
|
||||
tused_unit = class;
|
||||
|
||||
tunitmap = array[0..maxunits-1] of tmodule;
|
||||
punitmap = ^tunitmap;
|
||||
tunitmaprec = record
|
||||
u : tmodule;
|
||||
unitsym : tunitsym;
|
||||
end;
|
||||
punitmap = ^tunitmaprec;
|
||||
|
||||
tmodule = class(tmodulebase)
|
||||
do_reload, { force reloading of the unit }
|
||||
@ -93,7 +96,7 @@ interface
|
||||
flags : cardinal; { the PPU flags }
|
||||
islibrary : boolean; { if it is a library (win32 dll) }
|
||||
map : punitmap; { mapping of all used units }
|
||||
unitcount : longint; { local unit counter }
|
||||
mapsize : longint; { number of units in the map }
|
||||
globalsymtable, { pointer to the global symtable of this unit }
|
||||
localsymtable : tsymtable;{ pointer to the local symtable of this unit }
|
||||
scanner : pointer; { scanner object used }
|
||||
@ -130,8 +133,9 @@ interface
|
||||
procedure reset;virtual;
|
||||
procedure adddependency(callermodule:tmodule);
|
||||
procedure flagdependent(callermodule:tmodule);
|
||||
function addusedunit(hp:tmodule;inuses:boolean):tused_unit;
|
||||
function addusedunit(hp:tmodule;inuses:boolean;usym:tunitsym):tused_unit;
|
||||
procedure numberunits;
|
||||
procedure allunitsused;
|
||||
procedure setmodulename(const s:string);
|
||||
end;
|
||||
|
||||
@ -143,7 +147,8 @@ interface
|
||||
in_interface,
|
||||
is_stab_written : boolean;
|
||||
u : tmodule;
|
||||
constructor create(_u : tmodule;intface,inuses:boolean);
|
||||
unitsym : tunitsym;
|
||||
constructor create(_u : tmodule;intface,inuses:boolean;usym:tunitsym);
|
||||
end;
|
||||
|
||||
tdependent_unit = class(tlinkedlistitem)
|
||||
@ -302,13 +307,14 @@ implementation
|
||||
TUSED_UNIT
|
||||
****************************************************************************}
|
||||
|
||||
constructor tused_unit.create(_u : tmodule;intface,inuses:boolean);
|
||||
constructor tused_unit.create(_u : tmodule;intface,inuses:boolean;usym:tunitsym);
|
||||
begin
|
||||
u:=_u;
|
||||
in_interface:=intface;
|
||||
in_uses:=inuses;
|
||||
is_stab_written:=false;
|
||||
unitid:=0;
|
||||
unitsym:=usym;
|
||||
if _u.state=ms_compiled then
|
||||
begin
|
||||
checksum:=u.crc;
|
||||
@ -373,12 +379,12 @@ implementation
|
||||
interface_crc:=0;
|
||||
flags:=0;
|
||||
scanner:=nil;
|
||||
new(map);
|
||||
map:=nil;
|
||||
mapsize:=0;
|
||||
globalsymtable:=nil;
|
||||
localsymtable:=nil;
|
||||
loaded_from:=LoadedFrom;
|
||||
do_reload:=false;
|
||||
unitcount:=1;
|
||||
do_compile:=false;
|
||||
sources_avail:=true;
|
||||
recompile_reason:=rr_unknown;
|
||||
@ -509,7 +515,12 @@ implementation
|
||||
localsymtable.free;
|
||||
localsymtable:=nil;
|
||||
end;
|
||||
fillchar(map^,sizeof(tunitmap),#0);
|
||||
if assigned(map) then
|
||||
begin
|
||||
freemem(map);
|
||||
map:=nil;
|
||||
end;
|
||||
mapsize:=0;
|
||||
sourcefiles.free;
|
||||
sourcefiles:=tinputfilemanager.create;
|
||||
librarydata.free;
|
||||
@ -546,7 +557,6 @@ implementation
|
||||
crc:=0;
|
||||
interface_crc:=0;
|
||||
flags:=0;
|
||||
unitcount:=1;
|
||||
recompile_reason:=rr_unknown;
|
||||
{
|
||||
The following fields should not
|
||||
@ -596,11 +606,11 @@ implementation
|
||||
end;
|
||||
|
||||
|
||||
function tmodule.addusedunit(hp:tmodule;inuses:boolean):tused_unit;
|
||||
function tmodule.addusedunit(hp:tmodule;inuses:boolean;usym:tunitsym):tused_unit;
|
||||
var
|
||||
pu : tused_unit;
|
||||
begin
|
||||
pu:=tused_unit.create(hp,in_interface,inuses);
|
||||
pu:=tused_unit.create(hp,in_interface,inuses,usym);
|
||||
used_units.concat(pu);
|
||||
addusedunit:=pu;
|
||||
end;
|
||||
@ -608,33 +618,54 @@ implementation
|
||||
|
||||
procedure tmodule.numberunits;
|
||||
var
|
||||
counter : word;
|
||||
hp : tused_unit;
|
||||
hp1 : tmodule;
|
||||
pu : tused_unit;
|
||||
hp : tmodule;
|
||||
i : integer;
|
||||
begin
|
||||
{ Reset all numbers to -1 }
|
||||
hp1:=tmodule(loaded_units.first);
|
||||
while assigned(hp1) do
|
||||
hp:=tmodule(loaded_units.first);
|
||||
while assigned(hp) do
|
||||
begin
|
||||
if assigned(hp1.globalsymtable) then
|
||||
hp1.globalsymtable.unitid:=$ffff;
|
||||
hp1:=tmodule(hp1.next);
|
||||
if assigned(hp.globalsymtable) then
|
||||
hp.globalsymtable.unitid:=$ffff;
|
||||
hp:=tmodule(hp.next);
|
||||
end;
|
||||
{ Allocate map }
|
||||
mapsize:=used_units.count+1;
|
||||
reallocmem(map,mapsize*sizeof(tunitmaprec));
|
||||
{ Our own symtable gets unitid 0, for a program there is
|
||||
no globalsymtable }
|
||||
if assigned(globalsymtable) then
|
||||
globalsymtable.unitid:=0;
|
||||
map^[0]:=self;
|
||||
map[0].u:=self;
|
||||
map[0].unitsym:=nil;
|
||||
{ number units and map }
|
||||
counter:=1;
|
||||
hp:=tused_unit(used_units.first);
|
||||
while assigned(hp) do
|
||||
begin
|
||||
tsymtable(hp.u.globalsymtable).unitid:=counter;
|
||||
map^[counter]:=hp.u;
|
||||
inc(counter);
|
||||
hp:=tused_unit(hp.next);
|
||||
end;
|
||||
i:=1;
|
||||
pu:=tused_unit(used_units.first);
|
||||
while assigned(pu) do
|
||||
begin
|
||||
if assigned(pu.u.globalsymtable) then
|
||||
begin
|
||||
tsymtable(pu.u.globalsymtable).unitid:=i;
|
||||
map[i].u:=pu.u;
|
||||
map[i].unitsym:=pu.unitsym;
|
||||
inc(i);
|
||||
end;
|
||||
pu:=tused_unit(pu.next);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure tmodule.allunitsused;
|
||||
var
|
||||
i : longint;
|
||||
begin
|
||||
for i:=0 to mapsize-1 do
|
||||
begin
|
||||
if assigned(map[i].unitsym) and
|
||||
(map[i].unitsym.refs=0) then
|
||||
MessagePos2(map[i].unitsym.fileinfo,sym_n_unit_not_used,map[i].u.modulename^,modulename^);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
@ -652,7 +683,11 @@ implementation
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.38 2003-10-01 20:34:48 peter
|
||||
Revision 1.39 2003-10-22 15:22:33 peter
|
||||
* fixed unitsym-globalsymtable relation so the uses of a unit
|
||||
is counted correctly
|
||||
|
||||
Revision 1.38 2003/10/01 20:34:48 peter
|
||||
* procinfo unit contains tprocinfo
|
||||
* cginfo renamed to cgbase
|
||||
* moved cgmessage to verbose
|
||||
|
@ -692,7 +692,7 @@ uses
|
||||
{ set the state of this unit before registering, this is
|
||||
needed for a correct circular dependency check }
|
||||
hp:=registerunit(self,hs,'');
|
||||
pu:=addusedunit(hp,false);
|
||||
pu:=addusedunit(hp,false,nil);
|
||||
pu.checksum:=checksum;
|
||||
pu.interface_checksum:=intfchecksum;
|
||||
end;
|
||||
@ -834,7 +834,7 @@ uses
|
||||
procedure tppumodule.load_symtable_refs;
|
||||
var
|
||||
b : byte;
|
||||
unitindex : word;
|
||||
i : longint;
|
||||
begin
|
||||
{ load local symtable first }
|
||||
if ((flags and uf_local_browser)<>0) then
|
||||
@ -847,13 +847,8 @@ uses
|
||||
if (flags and uf_has_browser)<>0 then
|
||||
begin
|
||||
tstoredsymtable(globalsymtable).load_references(ppufile,true);
|
||||
unitindex:=1;
|
||||
while assigned(map^[unitindex]) do
|
||||
begin
|
||||
{ each unit wrote one browser entry }
|
||||
tstoredsymtable(globalsymtable).load_references(ppufile,false);
|
||||
inc(unitindex);
|
||||
end;
|
||||
for i:=0 to mapsize-1 do
|
||||
tstoredsymtable(globalsymtable).load_references(ppufile,false);
|
||||
b:=ppufile.readentry;
|
||||
if b<>ibendbrowser then
|
||||
Message1(unit_f_ppu_invalid_entry,tostr(b));
|
||||
@ -1046,14 +1041,10 @@ uses
|
||||
var
|
||||
pu : tused_unit;
|
||||
load_refs : boolean;
|
||||
nextmapentry : longint;
|
||||
begin
|
||||
if current_module<>self then
|
||||
internalerror(200212284);
|
||||
load_refs:=true;
|
||||
{ Add current unit to the map }
|
||||
map^[0]:=self;
|
||||
nextmapentry:=1;
|
||||
{ load the used units from interface }
|
||||
in_interface:=true;
|
||||
pu:=tused_unit(used_units.first);
|
||||
@ -1081,14 +1072,10 @@ uses
|
||||
do_compile:=true;
|
||||
exit;
|
||||
end;
|
||||
{ setup the map entry for deref }
|
||||
map^[nextmapentry]:=pu.u;
|
||||
inc(nextmapentry);
|
||||
if nextmapentry>maxunits then
|
||||
Message(unit_f_too_much_units);
|
||||
end;
|
||||
pu:=tused_unit(pu.next);
|
||||
end;
|
||||
numberunits;
|
||||
|
||||
{ ok, now load the interface of this unit }
|
||||
if current_module<>self then
|
||||
@ -1118,14 +1105,10 @@ uses
|
||||
do_compile:=true;
|
||||
exit;
|
||||
end;
|
||||
{ setup the map entry for deref }
|
||||
map^[nextmapentry]:=pu.u;
|
||||
inc(nextmapentry);
|
||||
if nextmapentry>maxunits then
|
||||
Message(unit_f_too_much_units);
|
||||
end;
|
||||
pu:=tused_unit(pu.next);
|
||||
end;
|
||||
numberunits;
|
||||
|
||||
{ read the implementation/objectdata part }
|
||||
load_implementation;
|
||||
@ -1326,7 +1309,7 @@ uses
|
||||
if second_time then
|
||||
reload_flagged_units
|
||||
else
|
||||
usedunits.concat(tused_unit.create(self,true,false));
|
||||
usedunits.concat(tused_unit.create(self,true,false,nil));
|
||||
|
||||
{ reopen the old module }
|
||||
{$ifdef SHORT_ON_FILE_HANDLES}
|
||||
@ -1421,7 +1404,11 @@ uses
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.39 2003-09-05 17:41:12 florian
|
||||
Revision 1.40 2003-10-22 15:22:33 peter
|
||||
* fixed unitsym-globalsymtable relation so the uses of a unit
|
||||
is counted correctly
|
||||
|
||||
Revision 1.39 2003/09/05 17:41:12 florian
|
||||
* merged Wiktor's Watcom patches in 1.1
|
||||
|
||||
Revision 1.38 2003/08/23 22:29:24 peter
|
||||
|
@ -32,8 +32,8 @@ uses
|
||||
{$else}
|
||||
strings,
|
||||
{$endif}
|
||||
globtype,cpubase,
|
||||
globals,aasmtai;
|
||||
globtype,
|
||||
aasmtai;
|
||||
|
||||
{stab constants }
|
||||
Const
|
||||
@ -233,7 +233,11 @@ end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.16 2002-11-17 16:31:56 carl
|
||||
Revision 1.17 2003-10-22 15:22:33 peter
|
||||
* fixed unitsym-globalsymtable relation so the uses of a unit
|
||||
is counted correctly
|
||||
|
||||
Revision 1.16 2002/11/17 16:31:56 carl
|
||||
* memory optimization (3-4%) : cleanup of tai fields,
|
||||
cleanup of tdef and tsym fields.
|
||||
* make it work for m68k
|
||||
|
@ -79,8 +79,6 @@ interface
|
||||
maxparasize = high(word);
|
||||
{ maximum nesting of routines }
|
||||
maxnesting = 32;
|
||||
{ maximum of units which are supported for a compilation }
|
||||
maxunits = 1024;
|
||||
|
||||
treelogfilename = 'tree.log';
|
||||
|
||||
@ -238,7 +236,7 @@ interface
|
||||
RelocSection : boolean = true;
|
||||
RelocSectionSetExplicitly : boolean = false;
|
||||
LinkTypeSetExplicitly : boolean = false;
|
||||
|
||||
|
||||
DLLsource : boolean = false;
|
||||
DLLImageBase : pstring = nil;
|
||||
UseDeffileForExport : boolean = true;
|
||||
@ -1616,7 +1614,7 @@ implementation
|
||||
{ Utils directory }
|
||||
utilsdirectory:='';
|
||||
utilsprefix:='';
|
||||
|
||||
|
||||
|
||||
{ Search Paths }
|
||||
librarysearchpath:=TSearchPathList.Create;
|
||||
@ -1712,7 +1710,11 @@ implementation
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.109 2003-10-11 19:32:04 marco
|
||||
Revision 1.110 2003-10-22 15:22:33 peter
|
||||
* fixed unitsym-globalsymtable relation so the uses of a unit
|
||||
is counted correctly
|
||||
|
||||
Revision 1.109 2003/10/11 19:32:04 marco
|
||||
* -Xd
|
||||
|
||||
Revision 1.108 2003/10/08 14:10:16 mazen
|
||||
|
@ -833,9 +833,8 @@ implementation
|
||||
begin
|
||||
hp:=nil;
|
||||
{ reads the parent class }
|
||||
if token=_LKLAMMER then
|
||||
if try_to_consume(_LKLAMMER) then
|
||||
begin
|
||||
consume(_LKLAMMER);
|
||||
id_type(tt,pattern,false);
|
||||
childof:=tobjectdef(tt.def);
|
||||
if (not assigned(childof)) or
|
||||
@ -1158,7 +1157,11 @@ implementation
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.70 2003-10-21 18:16:13 peter
|
||||
Revision 1.71 2003-10-22 15:22:33 peter
|
||||
* fixed unitsym-globalsymtable relation so the uses of a unit
|
||||
is counted correctly
|
||||
|
||||
Revision 1.70 2003/10/21 18:16:13 peter
|
||||
* IncompatibleTypes() added that will include unit names when
|
||||
the typenames are the same
|
||||
|
||||
|
@ -408,7 +408,6 @@ implementation
|
||||
hp:=registerunit(current_module,s,'');
|
||||
hp.loadppu;
|
||||
hp.adddependency(current_module);
|
||||
current_module.addusedunit(hp,false);
|
||||
{ add to symtable stack }
|
||||
tsymtable(hp.globalsymtable).next:=symtablestack;
|
||||
symtablestack:=hp.globalsymtable;
|
||||
@ -416,6 +415,8 @@ implementation
|
||||
unitsym:=tunitsym.create(s,hp.globalsymtable);
|
||||
inc(unitsym.refs);
|
||||
refsymtable.insert(unitsym);
|
||||
{ add to used units }
|
||||
current_module.addusedunit(hp,false,unitsym);
|
||||
end;
|
||||
|
||||
begin
|
||||
@ -511,8 +512,13 @@ implementation
|
||||
{ Need to register the unit? }
|
||||
if not assigned(hp2) then
|
||||
hp2:=registerunit(current_module,sorg,fn);
|
||||
{ Create unitsym, we need to use the name as specified, we
|
||||
can not use the modulename because that can be different
|
||||
when -Un is used }
|
||||
unitsym:=tunitsym.create(sorg,nil);
|
||||
refsymtable.insert(unitsym);
|
||||
{ the current module uses the unit hp2 }
|
||||
current_module.addusedunit(hp2,true);
|
||||
current_module.addusedunit(hp2,true,unitsym);
|
||||
end
|
||||
else
|
||||
Message1(sym_e_duplicate_id,s);
|
||||
@ -530,29 +536,27 @@ implementation
|
||||
pu:=tused_unit(current_module.used_units.first);
|
||||
while assigned(pu) do
|
||||
begin
|
||||
if pu.in_uses then
|
||||
{ Only load the units that are in the current
|
||||
(interface/implementation) uses clause }
|
||||
if pu.in_uses and
|
||||
(pu.in_interface=current_module.in_interface) then
|
||||
begin
|
||||
{ store the original name to create the unitsym }
|
||||
sorg:=pu.u.realmodulename^;
|
||||
tppumodule(pu.u).loadppu;
|
||||
{ is our module compiled? then we can stop }
|
||||
if current_module.state=ms_compiled then
|
||||
exit;
|
||||
{ add this unit to the dependencies }
|
||||
pu.u.adddependency(current_module);
|
||||
{ save crc values }
|
||||
pu.checksum:=pu.u.crc;
|
||||
pu.interface_checksum:=pu.u.interface_crc;
|
||||
{ Create unitsym, we need to use the name as specified, we
|
||||
can not use the modulename because that can be different
|
||||
when -Un is used. But when the names are the same then
|
||||
force the name of the module so there will be no difference
|
||||
in the case of the name }
|
||||
if upper(sorg)=pu.u.modulename^ then
|
||||
sorg:=pu.u.realmodulename^;
|
||||
unitsym:=tunitsym.create(sorg,pu.u.globalsymtable);
|
||||
{ connect unitsym to the globalsymtable of the unit }
|
||||
pu.unitsym.unitsymtable:=pu.u.globalsymtable;
|
||||
{ increase refs of the unitsym when the unit contains
|
||||
initialization/finalization code so it doesn't trigger
|
||||
the unit not used hint }
|
||||
if (pu.u.flags and (uf_init or uf_finalize))<>0 then
|
||||
inc(unitsym.refs);
|
||||
refsymtable.insert(unitsym);
|
||||
inc(pu.unitsym.refs);
|
||||
end;
|
||||
pu:=tused_unit(pu.next);
|
||||
end;
|
||||
@ -654,7 +658,7 @@ implementation
|
||||
{$EndIf GDB}
|
||||
|
||||
|
||||
procedure parse_implementation_uses(symt:tsymtable);
|
||||
procedure parse_implementation_uses;
|
||||
begin
|
||||
if token=_USES then
|
||||
begin
|
||||
@ -749,7 +753,7 @@ implementation
|
||||
end;
|
||||
|
||||
|
||||
procedure gen_implicit_initfinal(list:taasmoutput;flag:word;st:tsymtable);
|
||||
procedure gen_implicit_initfinal(flag:word;st:tsymtable);
|
||||
var
|
||||
pd : tprocdef;
|
||||
begin
|
||||
@ -802,7 +806,6 @@ implementation
|
||||
store_crc,store_interface_crc : cardinal;
|
||||
s2 : ^string; {Saves stack space}
|
||||
force_init_final : boolean;
|
||||
initfinalcode : taasmoutput;
|
||||
pd : tprocdef;
|
||||
begin
|
||||
consume(_UNIT);
|
||||
@ -879,13 +882,7 @@ implementation
|
||||
loadunits;
|
||||
{ has it been compiled at a higher level ?}
|
||||
if current_module.state=ms_compiled then
|
||||
begin
|
||||
{ this unit symtable is obsolete }
|
||||
{ dispose(unitst,done);
|
||||
disposed as localsymtable !! }
|
||||
RestoreUnitSyms;
|
||||
exit;
|
||||
end;
|
||||
exit;
|
||||
end;
|
||||
{ ... but insert the symbol table later }
|
||||
st.next:=symtablestack;
|
||||
@ -956,13 +953,10 @@ implementation
|
||||
refsymtable:=st;
|
||||
|
||||
{ Read the implementation units }
|
||||
parse_implementation_uses(unitst);
|
||||
parse_implementation_uses;
|
||||
|
||||
if current_module.state=ms_compiled then
|
||||
begin
|
||||
RestoreUnitSyms;
|
||||
exit;
|
||||
end;
|
||||
exit;
|
||||
|
||||
{ reset ranges/stabs in exported definitions }
|
||||
reset_global_defs;
|
||||
@ -1015,12 +1009,7 @@ implementation
|
||||
{ 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
|
||||
initfinalcode:=taasmoutput.create;
|
||||
gen_implicit_initfinal(initfinalcode,uf_init,st);
|
||||
codesegment.concatlist(initfinalcode);
|
||||
initfinalcode.free;
|
||||
end;
|
||||
gen_implicit_initfinal(uf_init,st);
|
||||
{ finalize? }
|
||||
if token=_FINALIZATION then
|
||||
begin
|
||||
@ -1036,12 +1025,7 @@ implementation
|
||||
release_main_proc(pd);
|
||||
end
|
||||
else if force_init_final then
|
||||
begin
|
||||
initfinalcode:=taasmoutput.create;
|
||||
gen_implicit_initfinal(initfinalcode,uf_finalize,st);
|
||||
codesegment.concatlist(initfinalcode);
|
||||
initfinalcode.free;
|
||||
end;
|
||||
gen_implicit_initfinal(uf_finalize,st);
|
||||
|
||||
{ the last char should always be a point }
|
||||
consume(_POINT);
|
||||
@ -1059,17 +1043,14 @@ implementation
|
||||
ResourceStrings.WriteResourceFile(ForceExtension(current_module.ppufilename^,'.rst'));
|
||||
end;
|
||||
|
||||
{ test static symtable }
|
||||
if (Errorcount=0) then
|
||||
begin
|
||||
{ test static symtable }
|
||||
tstoredsymtable(st).allsymbolsused;
|
||||
tstoredsymtable(st).allunitsused;
|
||||
tstoredsymtable(st).allprivatesused;
|
||||
current_module.allunitsused;
|
||||
end;
|
||||
|
||||
{ size of the static data }
|
||||
// datasize:=st.datasize;
|
||||
|
||||
{$ifdef GDB}
|
||||
{ add all used definitions even for implementation}
|
||||
if (cs_debuginfo in aktmoduleswitches) then
|
||||
@ -1169,8 +1150,6 @@ implementation
|
||||
current_module.localsymtable:=nil;
|
||||
end;
|
||||
|
||||
RestoreUnitSyms;
|
||||
|
||||
{ leave when we got an error }
|
||||
if (Errorcount>0) and not status.skip_error then
|
||||
begin
|
||||
@ -1188,7 +1167,6 @@ implementation
|
||||
main_file: tinputfile;
|
||||
st : tsymtable;
|
||||
hp : tmodule;
|
||||
initfinalcode : taasmoutput;
|
||||
pd : tprocdef;
|
||||
begin
|
||||
DLLsource:=islibrary;
|
||||
@ -1317,14 +1295,10 @@ implementation
|
||||
{ should we force unit initialization? }
|
||||
if tstaticsymtable(current_module.localsymtable).needs_init_final then
|
||||
begin
|
||||
initfinalcode:=taasmoutput.create;
|
||||
{ initialize section }
|
||||
gen_implicit_initfinal(initfinalcode,uf_init,st);
|
||||
codesegment.concatlist(initfinalcode);
|
||||
gen_implicit_initfinal(uf_init,st);
|
||||
{ finalize section }
|
||||
gen_implicit_initfinal(initfinalcode,uf_finalize,st);
|
||||
codesegment.concatlist(initfinalcode);
|
||||
initfinalcode.free;
|
||||
gen_implicit_initfinal(uf_finalize,st);
|
||||
end;
|
||||
|
||||
{ Add symbol to the exports section for win32 so smartlinking a
|
||||
@ -1371,12 +1345,12 @@ implementation
|
||||
exit;
|
||||
end;
|
||||
|
||||
{ test static symtable }
|
||||
if (Errorcount=0) then
|
||||
begin
|
||||
{ test static symtable }
|
||||
tstoredsymtable(st).allsymbolsused;
|
||||
tstoredsymtable(st).allunitsused;
|
||||
tstoredsymtable(st).allprivatesused;
|
||||
current_module.allunitsused;
|
||||
end;
|
||||
|
||||
{ generate a list of threadvars }
|
||||
@ -1444,7 +1418,11 @@ implementation
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.129 2003-10-21 15:14:33 peter
|
||||
Revision 1.130 2003-10-22 15:22:33 peter
|
||||
* fixed unitsym-globalsymtable relation so the uses of a unit
|
||||
is counted correctly
|
||||
|
||||
Revision 1.129 2003/10/21 15:14:33 peter
|
||||
* fixed memleak for initfinalcode
|
||||
* exit from generatecode when there are already errors
|
||||
|
||||
|
@ -28,7 +28,7 @@ unit symnot;
|
||||
|
||||
interface
|
||||
|
||||
uses cclasses,symbase,symtype;
|
||||
uses cclasses,symtype;
|
||||
|
||||
type Tnotification_flag=(vn_onread,vn_onwrite,vn_unknown);
|
||||
Tnotification_flags=set of Tnotification_flag;
|
||||
@ -65,7 +65,11 @@ end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.2 2002-12-31 09:55:58 daniel
|
||||
Revision 1.3 2003-10-22 15:22:33 peter
|
||||
* fixed unitsym-globalsymtable relation so the uses of a unit
|
||||
is counted correctly
|
||||
|
||||
Revision 1.2 2002/12/31 09:55:58 daniel
|
||||
+ Notification implementation complete
|
||||
+ Add for loop code optimization using notifications
|
||||
results in 1.5-1.9% speed improvement in nestloop benchmark
|
||||
|
@ -89,12 +89,10 @@ interface
|
||||
|
||||
tunitsym = class(tstoredsym)
|
||||
unitsymtable : tsymtable;
|
||||
prevsym : tunitsym;
|
||||
constructor create(const n : string;ref : tsymtable);
|
||||
constructor ppuload(ppufile:tcompilerppufile);
|
||||
destructor destroy;override;
|
||||
procedure ppuwrite(ppufile:tcompilerppufile);override;
|
||||
procedure restoreunitsym;
|
||||
{$ifdef GDB}
|
||||
procedure concatstabto(asmlist : taasmoutput);override;
|
||||
{$endif GDB}
|
||||
@ -681,12 +679,6 @@ implementation
|
||||
make_ref:=old_make_ref;
|
||||
typ:=unitsym;
|
||||
unitsymtable:=ref;
|
||||
if assigned(ref) and
|
||||
(ref.symtabletype=globalsymtable) then
|
||||
begin
|
||||
prevsym:=tglobalsymtable(ref).unitsym;
|
||||
tglobalsymtable(ref).unitsym:=self;
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor tunitsym.ppuload(ppufile:tcompilerppufile);
|
||||
@ -695,43 +687,11 @@ implementation
|
||||
inherited loadsym(ppufile);
|
||||
typ:=unitsym;
|
||||
unitsymtable:=nil;
|
||||
prevsym:=nil;
|
||||
refs:=0;
|
||||
end;
|
||||
|
||||
{ we need to remove it from the prevsym chain ! }
|
||||
|
||||
procedure tunitsym.restoreunitsym;
|
||||
var pus,ppus : tunitsym;
|
||||
begin
|
||||
if assigned(unitsymtable) and
|
||||
(unitsymtable.symtabletype=globalsymtable) then
|
||||
begin
|
||||
ppus:=nil;
|
||||
pus:=tglobalsymtable(unitsymtable).unitsym;
|
||||
if pus=self then
|
||||
tglobalsymtable(unitsymtable).unitsym:=prevsym
|
||||
else while assigned(pus) do
|
||||
begin
|
||||
if pus=self then
|
||||
begin
|
||||
ppus.prevsym:=prevsym;
|
||||
break;
|
||||
end
|
||||
else
|
||||
begin
|
||||
ppus:=pus;
|
||||
pus:=ppus.prevsym;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
unitsymtable:=nil;
|
||||
prevsym:=nil;
|
||||
end;
|
||||
|
||||
destructor tunitsym.destroy;
|
||||
begin
|
||||
restoreunitsym;
|
||||
inherited destroy;
|
||||
end;
|
||||
|
||||
@ -2645,7 +2605,11 @@ implementation
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.128 2003-10-21 18:14:30 peter
|
||||
Revision 1.129 2003-10-22 15:22:33 peter
|
||||
* fixed unitsym-globalsymtable relation so the uses of a unit
|
||||
is counted correctly
|
||||
|
||||
Revision 1.128 2003/10/21 18:14:30 peter
|
||||
* fix writing of widechar to ppu
|
||||
|
||||
Revision 1.127 2003/10/17 14:38:32 peter
|
||||
|
@ -50,7 +50,6 @@ interface
|
||||
procedure _needs_init_final(p : tnamedindexitem;arg:pointer);
|
||||
procedure check_forward(sym : TNamedIndexItem;arg:pointer);
|
||||
procedure labeldefined(p : TNamedIndexItem;arg:pointer);
|
||||
procedure unitsymbolused(p : TNamedIndexItem;arg:pointer);
|
||||
procedure varsymbolused(p : TNamedIndexItem;arg:pointer);
|
||||
procedure TestPrivate(p : TNamedIndexItem;arg:pointer);
|
||||
procedure objectprivatesymbolused(p : TNamedIndexItem;arg:pointer);
|
||||
@ -77,7 +76,6 @@ interface
|
||||
function speedsearch(const s : stringid;speedvalue : cardinal) : tsymentry;override;
|
||||
procedure allsymbolsused;
|
||||
procedure allprivatesused;
|
||||
procedure allunitsused;
|
||||
procedure check_forwards;
|
||||
procedure checklabels;
|
||||
function needs_init_final : boolean;
|
||||
@ -147,10 +145,8 @@ interface
|
||||
|
||||
tglobalsymtable = class(tabstractunitsymtable)
|
||||
public
|
||||
unitsym : tunitsym;
|
||||
unittypecount : word;
|
||||
constructor create(const n : string);
|
||||
destructor destroy;override;
|
||||
procedure ppuload(ppufile:tcompilerppufile);override;
|
||||
procedure ppuwrite(ppufile:tcompilerppufile);override;
|
||||
procedure load_references(ppufile:tcompilerppufile;locals:boolean);override;
|
||||
@ -214,7 +210,6 @@ interface
|
||||
function search_default_property(pd : tobjectdef) : tpropertysym;
|
||||
|
||||
{*** symtable stack ***}
|
||||
procedure RestoreUnitSyms;
|
||||
{$ifdef DEBUG}
|
||||
procedure test_symtablestack;
|
||||
procedure list_symtablestack;
|
||||
@ -592,8 +587,10 @@ implementation
|
||||
{ unit uses count }
|
||||
if (unitid<>0) and
|
||||
(symtabletype = globalsymtable) and
|
||||
assigned(tglobalsymtable(self).unitsym) then
|
||||
inc(tglobalsymtable(self).unitsym.refs);
|
||||
assigned(current_module) and
|
||||
(unitid<current_module.mapsize) and
|
||||
assigned(current_module.map[unitid].unitsym) then
|
||||
inc(current_module.map[unitid].unitsym.refs);
|
||||
|
||||
{$ifdef GDB}
|
||||
{ if it is a type, we need the stabs of this type
|
||||
@ -677,17 +674,6 @@ implementation
|
||||
end;
|
||||
|
||||
|
||||
procedure TStoredSymtable.unitsymbolused(p : TNamedIndexItem;arg:pointer);
|
||||
begin
|
||||
if (tsym(p).typ=unitsym) and
|
||||
(tunitsym(p).refs=0) and
|
||||
{ do not claim for unit name itself !! }
|
||||
assigned(tunitsym(p).unitsymtable) and
|
||||
(tunitsym(p).unitsymtable.symtabletype=globalsymtable) then
|
||||
MessagePos2(tsym(p).fileinfo,sym_n_unit_not_used,p.name,current_module.modulename^);
|
||||
end;
|
||||
|
||||
|
||||
procedure TStoredSymtable.varsymbolused(p : TNamedIndexItem;arg:pointer);
|
||||
begin
|
||||
if (tsym(p).typ=varsym) and
|
||||
@ -891,12 +877,6 @@ implementation
|
||||
end;
|
||||
|
||||
|
||||
procedure tstoredsymtable.allunitsused;
|
||||
begin
|
||||
foreach({$ifdef FPCPROCVAR}@{$endif}unitsymbolused,nil);
|
||||
end;
|
||||
|
||||
|
||||
procedure tstoredsymtable.allsymbolsused;
|
||||
begin
|
||||
foreach({$ifdef FPCPROCVAR}@{$endif}varsymbolused,nil);
|
||||
@ -1338,12 +1318,12 @@ implementation
|
||||
exit;
|
||||
if not assigned(name) then
|
||||
name := stringdup('Main_program');
|
||||
if (symtabletype = globalsymtable) and
|
||||
{if (symtabletype = globalsymtable) and
|
||||
(current_module.globalsymtable<>self) then
|
||||
begin
|
||||
unitid:=current_module.unitcount;
|
||||
inc(current_module.unitcount);
|
||||
end;
|
||||
end;}
|
||||
asmList.concat(tai_comment.Create(strpnew('Begin unit '+name^+' has index '+tostr(unitid))));
|
||||
if cs_gdb_dbx in aktglobalswitches then
|
||||
begin
|
||||
@ -1479,7 +1459,6 @@ implementation
|
||||
symtabletype:=globalsymtable;
|
||||
symtablelevel:=main_program_level;
|
||||
unitid:=0;
|
||||
unitsym:=nil;
|
||||
{$ifdef GDB}
|
||||
if cs_gdb_dbx in aktglobalswitches then
|
||||
begin
|
||||
@ -1500,22 +1479,6 @@ implementation
|
||||
end;
|
||||
|
||||
|
||||
destructor tglobalsymtable.destroy;
|
||||
var
|
||||
pus : tunitsym;
|
||||
begin
|
||||
pus:=unitsym;
|
||||
while assigned(pus) do
|
||||
begin
|
||||
unitsym:=pus.prevsym;
|
||||
pus.prevsym:=nil;
|
||||
pus.unitsymtable:=nil;
|
||||
pus:=unitsym;
|
||||
end;
|
||||
inherited destroy;
|
||||
end;
|
||||
|
||||
|
||||
procedure tglobalsymtable.ppuload(ppufile:tcompilerppufile);
|
||||
{$ifdef GDB}
|
||||
var
|
||||
@ -2215,22 +2178,6 @@ implementation
|
||||
Symtable Stack
|
||||
****************************************************************************}
|
||||
|
||||
procedure RestoreUnitSyms;
|
||||
var
|
||||
p : tsymtable;
|
||||
begin
|
||||
p:=symtablestack;
|
||||
while assigned(p) do
|
||||
begin
|
||||
if (p.symtabletype=globalsymtable) and
|
||||
assigned(tglobalsymtable(p).unitsym) and
|
||||
((tglobalsymtable(p).unitsym.owner=current_module.globalsymtable) or
|
||||
(tglobalsymtable(p).unitsym.owner=current_module.localsymtable)) then
|
||||
tglobalsymtable(p).unitsym.restoreunitsym;
|
||||
p:=p.next;
|
||||
end;
|
||||
end;
|
||||
|
||||
{$ifdef DEBUG}
|
||||
procedure test_symtablestack;
|
||||
var
|
||||
@ -2312,7 +2259,11 @@ implementation
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.117 2003-10-21 18:16:13 peter
|
||||
Revision 1.118 2003-10-22 15:22:33 peter
|
||||
* fixed unitsym-globalsymtable relation so the uses of a unit
|
||||
is counted correctly
|
||||
|
||||
Revision 1.117 2003/10/21 18:16:13 peter
|
||||
* IncompatibleTypes() added that will include unit names when
|
||||
the typenames are the same
|
||||
|
||||
|
@ -772,9 +772,9 @@ implementation
|
||||
begin
|
||||
idx:=(data[i] shl 8) or data[i+1];
|
||||
inc(i,2);
|
||||
if idx>maxunits then
|
||||
if idx>current_module.mapsize then
|
||||
internalerror(200306231);
|
||||
pm:=current_module.map^[idx];
|
||||
pm:=current_module.map[idx].u;
|
||||
if not assigned(pm) then
|
||||
internalerror(200212273);
|
||||
st:=pm.globalsymtable;
|
||||
@ -862,7 +862,11 @@ finalization
|
||||
end.
|
||||
{
|
||||
$Log$
|
||||
Revision 1.29 2003-10-17 14:38:32 peter
|
||||
Revision 1.30 2003-10-22 15:22:33 peter
|
||||
* fixed unitsym-globalsymtable relation so the uses of a unit
|
||||
is counted correctly
|
||||
|
||||
Revision 1.29 2003/10/17 14:38:32 peter
|
||||
* 64k registers supported
|
||||
* fixed some memory leaks
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user