Ver Fonte

psub.pas:
* read_proc: extract the code that creates an import library entry into its own function import_external_proc so that the same code can be used from other locations as well

git-svn-id: branches/svenbarth/packages@32637 -

svenbarth há 9 anos atrás
pai
commit
8718e66382
1 ficheiros alterados com 28 adições e 18 exclusões
  1. 28 18
      compiler/psub.pas

+ 28 - 18
compiler/psub.pas

@@ -81,6 +81,8 @@ interface
       true) }
     procedure read_proc(isclassmethod:boolean; usefwpd: tprocdef);
 
+    procedure import_external_proc(pd:tprocdef);
+
     procedure generate_specialization_procs;
 
 
@@ -2067,24 +2069,7 @@ implementation
              { Handle imports }
              if (po_external in pd.procoptions) then
                begin
-                 { Import DLL specified? }
-                 if assigned(pd.import_dll) then
-                   begin
-                     if assigned (pd.import_name) then
-                       current_module.AddExternalImport(pd.import_dll^,
-                         pd.import_name^,proc_get_importname(pd),
-                         pd.import_nr,false,false)
-                     else
-                       current_module.AddExternalImport(pd.import_dll^,
-                         proc_get_importname(pd),proc_get_importname(pd),
-                         pd.import_nr,false,true);
-                   end
-                 else
-                   begin
-                     { add import name to external list for DLL scanning }
-                     if tf_has_dllscanner in target_info.flags then
-                       current_module.dllscannerinputlist.Add(proc_get_importname(pd),pd);
-                   end;
+                 import_external_proc(pd);
 
                  { External declared in implementation, and there was already a
                    forward (or interface) declaration then we need to generate
@@ -2137,6 +2122,31 @@ implementation
       end;
 
 
+    procedure import_external_proc(pd:tprocdef);
+      begin
+        if not (po_external in pd.procoptions) then
+          internalerror(2015121101);
+
+        { Import DLL specified? }
+        if assigned(pd.import_dll) then
+          begin
+            if assigned (pd.import_name) then
+              current_module.AddExternalImport(pd.import_dll^,
+                pd.import_name^,proc_get_importname(pd),
+                pd.import_nr,false,false)
+            else
+              current_module.AddExternalImport(pd.import_dll^,
+                proc_get_importname(pd),proc_get_importname(pd),
+                pd.import_nr,false,true);
+          end
+        else
+          begin
+            { add import name to external list for DLL scanning }
+            if tf_has_dllscanner in target_info.flags then
+              current_module.dllscannerinputlist.Add(proc_get_importname(pd),pd);
+          end;
+      end;
+
 {****************************************************************************
                              DECLARATION PARSING
 ****************************************************************************}