fcl-passrc: passrcutil, paswrite: using usesclause

git-svn-id: trunk@35964 -
This commit is contained in:
Mattias Gaertner 2017-04-27 11:45:36 +00:00
parent 0a88d5465f
commit 09504f95f9
3 changed files with 27 additions and 13 deletions

View File

@ -192,7 +192,11 @@ procedure TPasSrcAnalysis.GetUses(ASection : TPasSection; List: TStrings);
Var
I : Integer;
begin
If Assigned(ASection) and Assigned(ASection.UsesList) then
If not Assigned(ASection) then exit;
if ASection.UsesList.Count=length(ASection.UsesClause) then
For I:=0 to length(ASection.UsesClause)-1 do
List.Add(ASection.UsesClause[i].Identifier)
else
For I:=0 to ASection.UsesList.Count-1 do
List.Add(TPasElement(ASection.UsesList[i]).Name);
end;

View File

@ -4016,11 +4016,11 @@ var
begin
{$IFDEF VerbosePasTreeMem}writeln('TPasSection.Destroy UsesList');{$ENDIF}
for i := 0 to UsesList.Count - 1 do
begin
TPasType(UsesList[i]).Release;
UsesClause[i].Release;
end;
FreeAndNil(UsesList);
{$IFDEF VerbosePasTreeMem}writeln('TPasSection.Destroy UsesClause');{$ENDIF}
for i := 0 to length(UsesClause) - 1 do
UsesClause[i].Release;
SetLength(UsesClause,0);
{$IFDEF VerbosePasTreeMem}writeln('TPasSection.Destroy inherited');{$ENDIF}

View File

@ -182,18 +182,28 @@ procedure TPasWriter.WriteSection(ASection: TPasSection);
var
i: Integer;
begin
if ASection.UsesList.Count > 0 then
begin
wrt('uses ');
for i := 0 to ASection.UsesList.Count - 1 do
if ASection.UsesList.Count>0 then
begin
if i > 0 then
wrt(', ');
wrt(TPasElement(ASection.UsesList[i]).Name);
end;
wrt('uses ');
if length(ASection.UsesClause)=ASection.UsesList.Count then
for i := 0 to length(ASection.UsesClause)-1 do
begin
if i > 0 then
wrt(', ');
wrt(ASection.UsesClause[i].Identifier);
if ASection.UsesClause[i].InFilename is TPrimitiveExpr then
wrt(' in '''+TPrimitiveExpr(ASection.UsesClause[i].InFilename).Value+'''');
end
else
for i := 0 to ASection.UsesList.Count - 1 do
begin
if i > 0 then
wrt(', ');
wrt(TPasElement(ASection.UsesList[i]).Name);
end;
wrtln(';');
wrtln;
end;
end;
CurDeclSection := '';