Преглед на файлове

[PATCH 109/188] writing out binary float-point

From 814363bcc1c03513bc0db08d347a32c5e6883c06 Mon Sep 17 00:00:00 2001
From: Dmitry Boyarintsev <[email protected]>
Date: Wed, 18 Mar 2020 08:47:16 -0400

git-svn-id: branches/wasm@46105 -
nickysn преди 5 години
родител
ревизия
d557557e1c
променени са 1 файла, в които са добавени 27 реда и са изтрити 0 реда
  1. 27 0
      utils/wasmbin/wasmbinwriter.pas

+ 27 - 0
utils/wasmbin/wasmbinwriter.pas

@@ -571,6 +571,30 @@ begin
 end;
 
 
+procedure WriteF32Operand(dst: TStream; const txt: string);
+var
+  f   : single;
+  err : integer;
+begin
+  //todo: float point parsing!
+  f:=0;
+  Val(txt, f, err);
+  // valid or not, it still should write out the value
+  dst.Write(f, sizeof(f));
+end;
+
+procedure WriteF64Operand(dst: TStream; const txt: string);
+var
+  f   : double;
+  err : integer;
+begin
+  //todo: float point parsing!
+  f:=0;
+  Val(txt, f, err);
+  dst.Write(f, sizeof(f));
+end;
+
+
 procedure TBinWriter.WriteInstList(list: TWasmInstrList; ofsAddition: LongWord);
 var
   i   : integer;
@@ -597,6 +621,9 @@ begin
         WriteI64Operand(dst, ci.operandText);
       end;
 
+      ipf32: WriteF32Operand(dst, ci.operandText);
+      ipf64: WriteF64Operand(dst, ci.operandText);
+
       ipi32OrFunc: begin
         if ci.hasRelocIdx then
           // should have been populated with Normalize