Browse Source

+ wasm internal object reader: read tags from the export section

Nikolay Nikolov 1 year ago
parent
commit
02b7cc0e56
1 changed files with 21 additions and 1 deletions
  1. 21 1
      compiler/ogwasm.pas

+ 21 - 1
compiler/ogwasm.pas

@@ -2428,6 +2428,8 @@ implementation
           ImportModName: ansistring;
           ImportModName: ansistring;
           TagAttr: Byte;
           TagAttr: Byte;
           TagTypeIdx: uint32;
           TagTypeIdx: uint32;
+          IsExported: Boolean;
+          ExportName: ansistring;
         end;
         end;
         TagTypeImportsCount: uint32;
         TagTypeImportsCount: uint32;
 
 
@@ -3566,7 +3568,7 @@ implementation
 
 
         function ReadExportSection: Boolean;
         function ReadExportSection: Boolean;
           var
           var
-            ExportsCount, FuncIdx, TableIdx, MemIdx, GlobalIdx: uint32;
+            ExportsCount, FuncIdx, TableIdx, MemIdx, GlobalIdx, TagIdx: uint32;
             i: Integer;
             i: Integer;
             Name: ansistring;
             Name: ansistring;
             ExportType: Byte;
             ExportType: Byte;
@@ -3668,6 +3670,24 @@ implementation
                           ExportName:=Name;
                           ExportName:=Name;
                         end;
                         end;
                     end;
                     end;
+                  $04:  { tag }
+                    begin
+                      if not ReadUleb32(TagIdx) then
+                        begin
+                          InputError('Error reading a tag index from the export section');
+                          exit;
+                        end;
+                      if TagIdx>high(TagTypes) then
+                        begin
+                          InputError('Tag index too high in the export section');
+                          exit;
+                        end;
+                      with TagTypes[TagIdx] do
+                        begin
+                          IsExported:=True;
+                          ExportName:=Name;
+                        end;
+                    end;
                   else
                   else
                     begin
                     begin
                       InputError('Unsupported export type in the export section: ' + tostr(ExportType));
                       InputError('Unsupported export type in the export section: ' + tostr(ExportType));