Browse Source

* WriteWasmBasicType and WriteWasmResultType converted to global functions to allow reuse in the exe writer

Nikolay Nikolov 1 year ago
parent
commit
a387accf81
1 changed files with 14 additions and 16 deletions
  1. 14 16
      compiler/ogwasm.pas

+ 14 - 16
compiler/ogwasm.pas

@@ -184,8 +184,6 @@ interface
         procedure WriteWasmCustomSection(wcst: TWasmCustomSectionType);
         procedure CopyDynamicArray(src, dest: tdynamicarray; size: QWord);
         procedure WriteZeros(dest: tdynamicarray; size: QWord);
-        procedure WriteWasmResultType(dest: tdynamicarray; wrt: TWasmResultType);
-        procedure WriteWasmBasicType(dest: tdynamicarray; wbt: TWasmBasicType);
         function IsExternalFunction(sym: TObjSymbol): Boolean;
         function IsExportedFunction(sym: TWasmObjSymbol): Boolean;
         procedure WriteFunctionLocals(dest: tdynamicarray; ed: TWasmObjSymbolExtraData);
@@ -365,6 +363,20 @@ implementation
         d.writestr(s);
       end;
 
+    procedure WriteWasmBasicType(dest: tdynamicarray; wbt: TWasmBasicType);
+      begin
+        WriteByte(dest,encode_wasm_basic_type(wbt));
+      end;
+
+    procedure WriteWasmResultType(dest: tdynamicarray; wrt: TWasmResultType);
+      var
+        i: Integer;
+      begin
+        WriteUleb(dest,Length(wrt));
+        for i:=low(wrt) to high(wrt) do
+          WriteWasmBasicType(dest,wrt[i]);
+      end;
+
     function ReadUleb(d: tdynamicarray): uint64;
       var
         b: byte;
@@ -1048,20 +1060,6 @@ implementation
           end;
       end;
 
-    procedure TWasmObjOutput.WriteWasmResultType(dest: tdynamicarray; wrt: TWasmResultType);
-      var
-        i: Integer;
-      begin
-        WriteUleb(dest,Length(wrt));
-        for i:=low(wrt) to high(wrt) do
-          WriteWasmBasicType(dest,wrt[i]);
-      end;
-
-    procedure TWasmObjOutput.WriteWasmBasicType(dest: tdynamicarray; wbt: TWasmBasicType);
-      begin
-        WriteByte(dest,encode_wasm_basic_type(wbt));
-      end;
-
     function TWasmObjOutput.IsExternalFunction(sym: TObjSymbol): Boolean;
       var
         ExtraData: TWasmObjSymbolExtraData;