Browse Source

[PATCH 007/188] convenience functions for leb128

From b3886efbbefc9c1b569c55bfee80262c560fc25c Mon Sep 17 00:00:00 2001
From: Dmitry Boyarintsev <[email protected]>
Date: Wed, 25 Sep 2019 16:38:00 -0400

git-svn-id: branches/wasm@46003 -
nickysn 5 years ago
parent
commit
85267156f5
1 changed files with 18 additions and 0 deletions
  1. 18 0
      utils/wasmbin/lebutils.pas

+ 18 - 0
utils/wasmbin/lebutils.pas

@@ -10,6 +10,9 @@ function ReadS(src: TStream; bits: Integer): Int64;
 
 procedure WriteU(src: TStream; vl: UInt64; bits: integer; fixedSize: Boolean = false);
 procedure WriteS(src: TStream; vl: Int64; bits: integer);
+procedure WriteU32(src: TStream; vl: UInt32);
+procedure WriteU16(src: TStream; vl: UInt16);
+procedure WriteU8(src: TStream; vl: UInt8);
 
 implementation
 
@@ -104,4 +107,19 @@ begin
   end;
 end;
 
+procedure WriteU32(src: TStream; vl: UInt32);
+begin
+  WriteU(src, vl, sizeof(vl)*8);
+end;
+
+procedure WriteU16(src: TStream; vl: UInt16);
+begin
+  WriteU(src, vl, sizeof(vl)*8);
+end;
+
+procedure WriteU8(src: TStream; vl: UInt8);
+begin
+  WriteU(src, vl, sizeof(vl)*8);
+end;
+
 end.