Browse Source

+ introduced TWasmValidationStacks.PopVal(expect)

Nikolay Nikolov 1 year ago
parent
commit
2d5c1d43cf
1 changed files with 8 additions and 0 deletions
  1. 8 0
      compiler/wasm32/aasmcpu.pas

+ 8 - 0
compiler/wasm32/aasmcpu.pas

@@ -95,6 +95,7 @@ uses
 
         procedure PushVal(vt: TWasmBasicType);
         function PopVal: TWasmBasicType;
+        function PopVal(expect: TWasmBasicType): TWasmBasicType;
       end;
 
       twasmstruc_stack = class;
@@ -473,6 +474,13 @@ uses
           Result:=FValueStack.Pop;
       end;
 
+    function TWasmValidationStacks.PopVal(expect: TWasmBasicType): TWasmBasicType;
+      begin
+        Result:=PopVal;
+        if (Result<>expect) and (Result<>wbt_Unknown) and (expect<>wbt_Unknown) then
+          internalerror(2024013105);
+      end;
+
     { twasmstruc_stack }
 
     function twasmstruc_stack.Get(Index: Integer): taicpu_wasm_structured_instruction;