Jelajahi Sumber

* explicitely load the system unit if we have at least one required package (as one of those *must* contain the system unit); but don't add it to the used units of the package module as otherwise we'd detect the package to contain the system unit as well

git-svn-id: trunk@34254 -
svenbarth 9 tahun lalu
induk
melakukan
296b7dbaf5
1 mengubah file dengan 19 tambahan dan 3 penghapusan
  1. 19 3
      compiler/pmodules.pas

+ 19 - 3
compiler/pmodules.pas

@@ -174,7 +174,7 @@ implementation
         CheckResourcesUsed:=found;
       end;
 
-    function AddUnit(const s:string): tppumodule;
+    function AddUnit(const s:string;addasused:boolean): tppumodule;
       var
         hp : tppumodule;
         unitsym : tunitsym;
@@ -192,12 +192,19 @@ implementation
         unitsym:=cunitsym.create(s,hp);
         inc(unitsym.refs);
         tabstractunitsymtable(current_module.localsymtable).insertunit(unitsym);
-        { add to used units }
-        current_module.addusedunit(hp,false,unitsym);
+        if addasused then
+          { add to used units }
+          current_module.addusedunit(hp,false,unitsym);
         result:=hp;
       end;
 
 
+    function AddUnit(const s:string):tppumodule;
+      begin
+        result:=AddUnit(s,true);
+      end;
+
+
     procedure maybeloadvariantsunit;
       var
         hp : tmodule;
@@ -1502,6 +1509,15 @@ type
            already provided by one of the loaded packages }
          load_packages;
 
+         if packagelist.Count>0 then
+           begin
+             { this means the SYSTEM unit *must* be part of one of the required
+               packages, so load it }
+             AddUnit('system',false);
+             systemunit:=tglobalsymtable(symtablestack.top);
+             load_intern_types;
+           end;
+
          {Load the units used by the program we compile.}
          if (token=_ID) and (idtoken=_CONTAINS) then
            begin