Browse Source

[PATCH 082/188] writing out constant parameters

From f628b39868ab7547b215ee2fd92164484909e1b7 Mon Sep 17 00:00:00 2001
From: Dmitry Boyarintsev <[email protected]>
Date: Mon, 9 Mar 2020 10:59:49 -0400

git-svn-id: branches/wasm@46078 -
nickysn 5 years ago
parent
commit
4f7ba10fe1
2 changed files with 21 additions and 1 deletions
  1. 20 0
      utils/wasmbin/wasmbinwriter.pas
  2. 1 1
      utils/wasmbin/wasmmodule.pas

+ 20 - 0
utils/wasmbin/wasmbinwriter.pas

@@ -461,15 +461,35 @@ begin
   end;
   end;
 end;
 end;
 
 
+
 procedure TBinWriter.WriteInstList(list: TWasmInstrList; ofsAddition: LongWord);
 procedure TBinWriter.WriteInstList(list: TWasmInstrList; ofsAddition: LongWord);
 var
 var
   i  : integer;
   i  : integer;
   ci : TWasmInstr;
   ci : TWasmInstr;
+  u32  : LongWord;
+  i32  : LongWord;
+  err  : integer;
+
 begin
 begin
   for i:=0 to list.Count-1 do begin
   for i:=0 to list.Count-1 do begin
     ci :=list[i];
     ci :=list[i];
     dst.WriteByte(ci.code);
     dst.WriteByte(ci.code);
     case INST_FLAGS[ci.code].Param of
     case INST_FLAGS[ci.code].Param of
+      ipi32: begin
+        Val(ci.operandText, u32, err);
+        if err = 0 then begin
+          WriteU32(dst, u32);
+        end else begin
+          Val(ci.operandText, i32, err);
+          if err = 0 then WriteU32(dst, i32);
+        end;
+      end;
+
+      ipi64,     // signed Leb of maximum 8 bytes
+      ipf32,     // float point single
+      ipf64,     // float point double
+
+
       ipLeb:
       ipLeb:
         if INST_RELOC_FLAGS[ci.code].doReloc then begin
         if INST_RELOC_FLAGS[ci.code].doReloc then begin
           AddReloc(INST_RELOC_FLAGS[ci.code].relocType, dst.Position+ofsAddition, ci.operandNum);
           AddReloc(INST_RELOC_FLAGS[ci.code].relocType, dst.Position+ofsAddition, ci.operandNum);

+ 1 - 1
utils/wasmbin/wasmmodule.pas

@@ -629,7 +629,7 @@ begin
 
 
       INST_CALL:
       INST_CALL:
       begin
       begin
-        if (ci.operandIdx<>'') and (     ci.operandNum<0) then
+        if (ci.operandIdx<>'') and (ci.operandNum<0) then
           ci.operandNum:=FindFunc(m,ci.operandIdx);
           ci.operandNum:=FindFunc(m,ci.operandIdx);
       end;
       end;
     end;
     end;