Browse Source

+ implemented TWasmExeOutput.GenerateLibraryImports

Nikolay Nikolov 1 year ago
parent
commit
541bd66a6c
1 changed files with 26 additions and 0 deletions
  1. 26 0
      compiler/ogwasm.pas

+ 26 - 0
compiler/ogwasm.pas

@@ -227,6 +227,7 @@ interface
       public
         constructor create;override;
         destructor destroy;override;
+        procedure GenerateLibraryImports(ImportLibraryList:TFPHashObjectList);override;
       end;
 
       { TWasmAssembler }
@@ -4034,6 +4035,31 @@ implementation
         inherited destroy;
       end;
 
+    procedure TWasmExeOutput.GenerateLibraryImports(ImportLibraryList: TFPHashObjectList);
+      var
+        i, j: Integer;
+        ImportLibrary: TImportLibrary;
+        ImportSymbol: TImportSymbol;
+        exesym: TExeSymbol;
+      begin
+        for i:=0 to ImportLibraryList.Count-1 do
+          begin
+            ImportLibrary:=TImportLibrary(ImportLibraryList[i]);
+            for j:=0 to ImportLibrary.ImportSymbolList.Count-1 do
+              begin
+                ImportSymbol:=TImportSymbol(ImportLibrary.ImportSymbolList[j]);
+                exesym:=TExeSymbol(ExeSymbolList.Find(ImportSymbol.MangledName));
+                if assigned(exesym) and
+                   (exesym.State<>symstate_defined) then
+                  begin
+                    ImportSymbol.CachedExeSymbol:=exesym;
+                    exesym.State:=symstate_defined;
+                  end;
+              end;
+          end;
+        PackUnresolvedExeSymbols('after module imports');
+      end;
+
 
 {****************************************************************************
                                TWasmAssembler