mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 09:06:02 +02:00
* fixed unit interdependency with circular uses
This commit is contained in:
parent
b6bf708ca9
commit
226a917014
@ -116,6 +116,7 @@ unit files;
|
|||||||
do_compile, { need to compile the sources }
|
do_compile, { need to compile the sources }
|
||||||
sources_avail, { if all sources are reachable }
|
sources_avail, { if all sources are reachable }
|
||||||
is_unit,
|
is_unit,
|
||||||
|
in_second_compile, { is this unit being compiled for the 2nd time? }
|
||||||
in_implementation, { processing the implementation part? }
|
in_implementation, { processing the implementation part? }
|
||||||
in_global : boolean; { allow global settings }
|
in_global : boolean; { allow global settings }
|
||||||
|
|
||||||
@ -126,6 +127,8 @@ unit files;
|
|||||||
{$ifdef UseBrowser}
|
{$ifdef UseBrowser}
|
||||||
implsymtable : pointer;
|
implsymtable : pointer;
|
||||||
{$endif UseBrowser}
|
{$endif UseBrowser}
|
||||||
|
scanner : pointer; { scanner object used }
|
||||||
|
loaded_from : pmodule;
|
||||||
uses_imports : boolean; { Set if the module imports from DLL's.}
|
uses_imports : boolean; { Set if the module imports from DLL's.}
|
||||||
imports : plinkedlist;
|
imports : plinkedlist;
|
||||||
|
|
||||||
@ -135,8 +138,6 @@ unit files;
|
|||||||
linkofiles : tstringcontainer;
|
linkofiles : tstringcontainer;
|
||||||
used_units : tlinkedlist;
|
used_units : tlinkedlist;
|
||||||
|
|
||||||
{ used in firstpass for faster settings }
|
|
||||||
scanner : pointer;
|
|
||||||
|
|
||||||
path, { path where the module is find/created }
|
path, { path where the module is find/created }
|
||||||
modulename, { name of the module in uppercase }
|
modulename, { name of the module in uppercase }
|
||||||
@ -151,6 +152,7 @@ unit files;
|
|||||||
|
|
||||||
constructor init(const s:string;_is_unit:boolean);
|
constructor init(const s:string;_is_unit:boolean);
|
||||||
destructor done;virtual;
|
destructor done;virtual;
|
||||||
|
procedure reset;
|
||||||
procedure setfilename(const fn:string;allowoutput:boolean);
|
procedure setfilename(const fn:string;allowoutput:boolean);
|
||||||
function openppu:boolean;
|
function openppu:boolean;
|
||||||
function search_unit(const n : string):boolean;
|
function search_unit(const n : string):boolean;
|
||||||
@ -770,6 +772,20 @@ unit files;
|
|||||||
search_unit:=Found;
|
search_unit:=Found;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure tmodule.reset;
|
||||||
|
begin
|
||||||
|
sourcefiles^.done;
|
||||||
|
sourcefiles^.init;
|
||||||
|
used_units.done;
|
||||||
|
used_units.init;
|
||||||
|
linkofiles.done;
|
||||||
|
linkofiles.init;
|
||||||
|
linkstaticlibs.done;
|
||||||
|
linkstaticlibs.init;
|
||||||
|
linksharedlibs.done;
|
||||||
|
linksharedlibs.init;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
constructor tmodule.init(const s:string;_is_unit:boolean);
|
constructor tmodule.init(const s:string;_is_unit:boolean);
|
||||||
var
|
var
|
||||||
@ -814,6 +830,7 @@ unit files;
|
|||||||
{$ifdef UseBrowser}
|
{$ifdef UseBrowser}
|
||||||
implsymtable:=nil;
|
implsymtable:=nil;
|
||||||
{$endif UseBrowser}
|
{$endif UseBrowser}
|
||||||
|
loaded_from:=nil;
|
||||||
flags:=0;
|
flags:=0;
|
||||||
crc:=0;
|
crc:=0;
|
||||||
unitcount:=1;
|
unitcount:=1;
|
||||||
@ -823,6 +840,7 @@ unit files;
|
|||||||
do_compile:=false;
|
do_compile:=false;
|
||||||
sources_avail:=true;
|
sources_avail:=true;
|
||||||
compiled:=false;
|
compiled:=false;
|
||||||
|
in_second_compile:=false;
|
||||||
in_implementation:=false;
|
in_implementation:=false;
|
||||||
in_global:=true;
|
in_global:=true;
|
||||||
is_unit:=_is_unit;
|
is_unit:=_is_unit;
|
||||||
@ -907,7 +925,10 @@ unit files;
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.49 1998-09-28 16:57:20 pierre
|
Revision 1.50 1998-09-30 16:43:34 peter
|
||||||
|
* fixed unit interdependency with circular uses
|
||||||
|
|
||||||
|
Revision 1.49 1998/09/28 16:57:20 pierre
|
||||||
* changed all length(p^.value_str^) into str_length(p)
|
* changed all length(p^.value_str^) into str_length(p)
|
||||||
to get it work with and without ansistrings
|
to get it work with and without ansistrings
|
||||||
* changed sourcefiles field of tmodule to a pointer
|
* changed sourcefiles field of tmodule to a pointer
|
||||||
|
@ -204,18 +204,7 @@ unit parser;
|
|||||||
|
|
||||||
{ reset the unit or create a new program }
|
{ reset the unit or create a new program }
|
||||||
if assigned(current_module) then
|
if assigned(current_module) then
|
||||||
begin
|
current_module^.reset
|
||||||
current_module^.sourcefiles^.done;
|
|
||||||
current_module^.sourcefiles^.init;
|
|
||||||
current_module^.used_units.done;
|
|
||||||
current_module^.used_units.init;
|
|
||||||
current_module^.linkofiles.done;
|
|
||||||
current_module^.linkofiles.init;
|
|
||||||
current_module^.linkstaticlibs.done;
|
|
||||||
current_module^.linkstaticlibs.init;
|
|
||||||
current_module^.linksharedlibs.done;
|
|
||||||
current_module^.linksharedlibs.init;
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
current_module:=new(pmodule,init(filename,false));
|
current_module:=new(pmodule,init(filename,false));
|
||||||
@ -235,9 +224,10 @@ unit parser;
|
|||||||
if compile_system then
|
if compile_system then
|
||||||
aktmoduleswitches:=aktmoduleswitches+[cs_compilesystem];
|
aktmoduleswitches:=aktmoduleswitches+[cs_compilesystem];
|
||||||
|
|
||||||
{ startup scanner }
|
{ startup scanner, and save in current_module }
|
||||||
current_scanner:=new(pscannerfile,Init(filename));
|
current_scanner:=new(pscannerfile,Init(filename));
|
||||||
current_scanner^.readtoken;
|
current_scanner^.readtoken;
|
||||||
|
current_module^.scanner:=current_scanner;
|
||||||
|
|
||||||
{ init code generator for a new module }
|
{ init code generator for a new module }
|
||||||
codegen_newmodule;
|
codegen_newmodule;
|
||||||
@ -374,7 +364,10 @@ unit parser;
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.52 1998-09-28 16:57:22 pierre
|
Revision 1.53 1998-09-30 16:43:36 peter
|
||||||
|
* fixed unit interdependency with circular uses
|
||||||
|
|
||||||
|
Revision 1.52 1998/09/28 16:57:22 pierre
|
||||||
* changed all length(p^.value_str^) into str_length(p)
|
* changed all length(p^.value_str^) into str_length(p)
|
||||||
to get it work with and without ansistrings
|
to get it work with and without ansistrings
|
||||||
* changed sourcefiles field of tmodule to a pointer
|
* changed sourcefiles field of tmodule to a pointer
|
||||||
|
@ -35,7 +35,7 @@ unit pmodules;
|
|||||||
uses
|
uses
|
||||||
cobjects,comphook,systems,globals,
|
cobjects,comphook,systems,globals,
|
||||||
symtable,aasm,files,
|
symtable,aasm,files,
|
||||||
hcodegen,verbose, { don't use hcodegen.message !! }
|
hcodegen,verbose,
|
||||||
link,assemble,import,gendef,ppu
|
link,assemble,import,gendef,ppu
|
||||||
{$ifdef i386}
|
{$ifdef i386}
|
||||||
,i386
|
,i386
|
||||||
@ -184,6 +184,7 @@ unit pmodules;
|
|||||||
fillchar(current_module^.map^,sizeof(tunitmap),#0);
|
fillchar(current_module^.map^,sizeof(tunitmap),#0);
|
||||||
nextmapentry:=1;
|
nextmapentry:=1;
|
||||||
{ load the used units from interface }
|
{ load the used units from interface }
|
||||||
|
current_module^.in_implementation:=false;
|
||||||
pu:=pused_unit(current_module^.used_units.first);
|
pu:=pused_unit(current_module^.used_units.first);
|
||||||
while assigned(pu) do
|
while assigned(pu) do
|
||||||
begin
|
begin
|
||||||
@ -270,10 +271,12 @@ unit pmodules;
|
|||||||
|
|
||||||
|
|
||||||
function loadunit(const s : string;compile_system:boolean) : pmodule;
|
function loadunit(const s : string;compile_system:boolean) : pmodule;
|
||||||
|
const
|
||||||
|
ImplIntf : array[boolean] of string[15]=('interface','implementation');
|
||||||
var
|
var
|
||||||
st : punitsymtable;
|
st : punitsymtable;
|
||||||
old_current_ppu : pppufile;
|
old_current_ppu : pppufile;
|
||||||
old_current_module,hp : pmodule;
|
old_current_module,hp,hp2 : pmodule;
|
||||||
|
|
||||||
procedure loadppufile;
|
procedure loadppufile;
|
||||||
begin
|
begin
|
||||||
@ -286,7 +289,7 @@ unit pmodules;
|
|||||||
{ recompile if set }
|
{ recompile if set }
|
||||||
if current_module^.do_compile then
|
if current_module^.do_compile then
|
||||||
begin
|
begin
|
||||||
{ we needn't the ppufile }
|
{ we don't need the ppufile anymore }
|
||||||
if assigned(current_module^.ppufile) then
|
if assigned(current_module^.ppufile) then
|
||||||
begin
|
begin
|
||||||
dispose(current_module^.ppufile,done);
|
dispose(current_module^.ppufile,done);
|
||||||
@ -321,8 +324,8 @@ unit pmodules;
|
|||||||
begin
|
begin
|
||||||
old_current_module:=current_module;
|
old_current_module:=current_module;
|
||||||
old_current_ppu:=current_ppu;
|
old_current_ppu:=current_ppu;
|
||||||
{ be sure not to mix lines from different files }
|
{ Info }
|
||||||
{ update_line; }
|
Message3(unit_t_load_unit,current_module^.modulename^,ImplIntf[current_module^.in_implementation],s);
|
||||||
{ unit not found }
|
{ unit not found }
|
||||||
st:=nil;
|
st:=nil;
|
||||||
{ search all loaded units }
|
{ search all loaded units }
|
||||||
@ -339,9 +342,21 @@ unit pmodules;
|
|||||||
st:=punitsymtable(hp^.symtable)
|
st:=punitsymtable(hp^.symtable)
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
{ recompile the unit ? }
|
{ both units in interface ? }
|
||||||
if (not current_module^.in_implementation) and (not hp^.in_implementation) then
|
if (not current_module^.in_implementation) and (not hp^.in_implementation) then
|
||||||
Message(unit_f_circular_unit_reference);
|
begin
|
||||||
|
{ check for a cycle }
|
||||||
|
hp2:=current_module^.loaded_from;
|
||||||
|
while assigned(hp2) and (hp2<>hp) do
|
||||||
|
begin
|
||||||
|
if hp2^.in_implementation then
|
||||||
|
hp2:=nil
|
||||||
|
else
|
||||||
|
hp2:=hp2^.loaded_from;
|
||||||
|
end;
|
||||||
|
if assigned(hp2) then
|
||||||
|
Message2(unit_f_circular_unit_reference,current_module^.modulename^,hp^.modulename^);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
@ -360,12 +375,14 @@ unit pmodules;
|
|||||||
hp^.done;
|
hp^.done;
|
||||||
hp^.init(s,true);
|
hp^.init(s,true);
|
||||||
current_module:=hp;
|
current_module:=hp;
|
||||||
|
current_module^.in_second_compile:=true;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
{ generates a new unit info record }
|
{ generates a new unit info record }
|
||||||
current_module:=new(pmodule,init(s,true));
|
current_module:=new(pmodule,init(s,true));
|
||||||
current_ppu:=current_module^.ppufile;
|
current_ppu:=current_module^.ppufile;
|
||||||
{ now we can register the unit }
|
{ now we can register the unit }
|
||||||
|
current_module^.loaded_from:=old_current_module;
|
||||||
loaded_units.insert(current_module);
|
loaded_units.insert(current_module);
|
||||||
{ now realy load the ppu }
|
{ now realy load the ppu }
|
||||||
loadppufile;
|
loadppufile;
|
||||||
@ -982,7 +999,10 @@ unit pmodules;
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.57 1998-09-30 12:11:52 peter
|
Revision 1.58 1998-09-30 16:43:37 peter
|
||||||
|
* fixed unit interdependency with circular uses
|
||||||
|
|
||||||
|
Revision 1.57 1998/09/30 12:11:52 peter
|
||||||
* fixed circular uses which looped forever
|
* fixed circular uses which looped forever
|
||||||
|
|
||||||
Revision 1.56 1998/09/28 11:22:15 pierre
|
Revision 1.56 1998/09/28 11:22:15 pierre
|
||||||
|
@ -226,9 +226,12 @@ implementation
|
|||||||
destructor tscannerfile.done;
|
destructor tscannerfile.done;
|
||||||
begin
|
begin
|
||||||
checkpreprocstack;
|
checkpreprocstack;
|
||||||
{ close file }
|
{ close file, but only if we are the first compile }
|
||||||
if not inputfile^.closed then
|
if not current_module^.in_second_compile then
|
||||||
closeinputfile;
|
begin
|
||||||
|
if not inputfile^.closed then
|
||||||
|
closeinputfile;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -1424,7 +1427,10 @@ begin
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.55 1998-09-28 16:57:26 pierre
|
Revision 1.56 1998-09-30 16:43:38 peter
|
||||||
|
* fixed unit interdependency with circular uses
|
||||||
|
|
||||||
|
Revision 1.55 1998/09/28 16:57:26 pierre
|
||||||
* changed all length(p^.value_str^) into str_length(p)
|
* changed all length(p^.value_str^) into str_length(p)
|
||||||
to get it work with and without ansistrings
|
to get it work with and without ansistrings
|
||||||
* changed sourcefiles field of tmodule to a pointer
|
* changed sourcefiles field of tmodule to a pointer
|
||||||
|
Loading…
Reference in New Issue
Block a user