Browse Source

* unit implicit first in uses clause

git-svn-id: trunk@15809 -
marco 15 years ago
parent
commit
c6698af39c
2 changed files with 19 additions and 9 deletions
  1. 3 0
      packages/fcl-passrc/src/pastree.pp
  2. 16 9
      packages/fcl-passrc/src/pparser.pp

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

@@ -248,6 +248,9 @@ type
   TImplementationSection = class(TPasSection)
   end;
 
+  TProgramSection = class(TPasSection)
+  end;
+
   TInitializationSection = class;
   TFinalizationSection = class;
 

+ 16 - 9
packages/fcl-passrc/src/pparser.pp

@@ -1544,21 +1544,28 @@ end;
 
 // Starts after the "uses" token
 procedure TPasParser.ParseUsesList(ASection: TPasSection);
+
+function CheckUnit(AUnitName : string):TPasElement;
+begin
+    result := Engine.FindModule(AUnitName);  // should we resolve module here when "IN" filename is not known yet?
+    if Assigned(result) then
+      result.AddRef
+    else
+      Result := TPasType(CreateElement(TPasUnresolvedTypeRef, AUnitName,
+        ASection));
+    ASection.UsesList.Add(Result);
+end;
+
 var
   AUnitName: String;
   Element: TPasElement;
 begin
+  If not (Asection is TImplementationSection) Then // interface,program,library,package
+    Element:=CheckUnit('System'); // system always implicitely first.    
   while True do
   begin
-    AUnitName := ExpectIdentifier;
-
-    Element := Engine.FindModule(AUnitName); // should we resolve module here when "IN" filename is not known yet?
-    if Assigned(Element) then
-      Element.AddRef
-    else
-      Element := TPasType(CreateElement(TPasUnresolvedTypeRef, AUnitName,
-        ASection));
-    ASection.UsesList.Add(Element);
+    AUnitName := ExpectIdentifier; 
+    Element :=CheckUnit(AUnitName);
 
     NextToken;