Browse Source

+ added DataSegments dynarray of record, that will store data segment info

Nikolay Nikolov 1 year ago
parent
commit
6f7c1b5b4e
1 changed files with 6 additions and 5 deletions
  1. 6 5
      compiler/ogwasm.pas

+ 6 - 5
compiler/ogwasm.pas

@@ -2222,7 +2222,8 @@ implementation
           CodeSectionRead: Boolean = false;
           DataCountSectionRead: Boolean = false;
 
-          DataCount: uint32;
+          DataSegments: array of record
+          end;
 
         function ReadCustomSection: Boolean;
 
@@ -2245,7 +2246,7 @@ implementation
                 Result:=False;
                 if SegmentInfoSectionRead then
                   begin
-                    InputError('The WASM_SEGMENT_INFO section is duplicated');
+                    InputError('The WASM_SEGMENT_INFO subsection is duplicated');
                     exit;
                   end;
                 SegmentInfoSectionRead:=True;
@@ -2735,7 +2736,7 @@ implementation
 
         function ReadDataCountSection: Boolean;
           var
-            v: uint32;
+            DataCount: uint32;
           begin
             Result:=False;
             if DataCountSectionRead then
@@ -2744,17 +2745,17 @@ implementation
                 exit;
               end;
             DataCountSectionRead:=True;
-            if not ReadUleb32(v) then
+            if not ReadUleb32(DataCount) then
               begin
                 InputError('Error reading the data count from the data count section');
                 exit;
               end;
-            DataCount:=v;
             if AReader.Pos<>(SectionStart+SectionSize) then
               begin
                 InputError('Unexpected data count section size');
                 exit;
               end;
+            SetLength(DataSegments, DataCount);
             Result:=true;
           end;