Browse Source

[PATCH 104/188] using TWasmId type for elements

From f17f4d7de1bd5337670989c30c5713f86416f9b7 Mon Sep 17 00:00:00 2001
From: Dmitry Boyarintsev <[email protected]>
Date: Tue, 17 Mar 2020 15:42:51 -0400

git-svn-id: branches/wasm@46100 -
nickysn 5 years ago
parent
commit
6cb77ca590
2 changed files with 13 additions and 13 deletions
  1. 3 3
      utils/wasmbin/wasmbinwriter.pas
  2. 10 10
      utils/wasmbin/wasmmodule.pas

+ 3 - 3
utils/wasmbin/wasmbinwriter.pas

@@ -452,12 +452,12 @@ begin
 
     if writeReloc then begin
       for j:=0 to el.funcCount-1 do begin
-        AddReloc(R_WASM_FUNCTION_INDEX_LEB, dst.Position - sc.datapos, el.funcs[j]);
-        WriteRelocU32(el.funcs[j]);
+        AddReloc(R_WASM_FUNCTION_INDEX_LEB, dst.Position - sc.datapos, el.funcs[j].idNum);
+        WriteRelocU32(el.funcs[j].idNum);
       end;
     end else
       for j:=0 to el.funcCount-1 do
-        WriteU32(dst, el.funcs[j]);
+        WriteU32(dst, el.funcs[j].idNum);
   end;
 
   SectionEnd(sc);

+ 10 - 10
utils/wasmbin/wasmmodule.pas

@@ -25,6 +25,13 @@ type
     name     : string;
   end;
 
+  { TWasmId }
+
+  TWasmId = record
+    idNum : integer;
+    id    : string;
+  end;
+
   { TWasmParam }
 
   TWasmParam = class(TObject)
@@ -121,7 +128,7 @@ type
     tableIdx  : Integer;
     offset    : Integer;
     funcCount : Integer;
-    funcs     : array of LongWord;
+    funcs     : array of TWasmId;
     function AddFunc(idx: integer): integer;
     constructor Create;
   end;
@@ -146,13 +153,6 @@ type
     function AddFunc: TWasmFunc;
   end;
 
-  { TWasmId }
-
-  TWasmId = record
-    idNum : integer;
-    id    : string;
-  end;
-
   { TWasmTable }
 
   TWasmTable = class(TObject)
@@ -284,7 +284,7 @@ begin
     else SetLength(funcs, funcCount*2);
   end;
   Result:=funcCount;
-  funcs[funcCount]:=idx;
+  funcs[funcCount].idNum :=idx;
   inc(funcCount);
 end;
 
@@ -870,7 +870,7 @@ begin
     el := m.GetElement(0);
   Result:=-1;
   for i:=0 to el.funcCount-1 do begin
-    if el.funcs[i] = func then
+    if el.funcs[i].idNum = func then
       Result:=i;
   end;
   if Result<0 then