Browse Source

fcl-passrc: passrcutil, paswrite: using usesclause

git-svn-id: trunk@35964 -
Mattias Gaertner 8 years ago
parent
commit
09504f95f9

+ 5 - 1
packages/fcl-passrc/src/passrcutil.pp

@@ -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;

+ 3 - 3
packages/fcl-passrc/src/pastree.pp

@@ -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}

+ 19 - 9
packages/fcl-passrc/src/paswrite.pp

@@ -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 := '';