Browse Source

+ introduced TWasmValidationStacks.PushCtrl

Nikolay Nikolov 1 year ago
parent
commit
4cc5cf4d0e
1 changed files with 18 additions and 0 deletions
  1. 18 0
      compiler/wasm32/aasmcpu.pas

+ 18 - 0
compiler/wasm32/aasmcpu.pas

@@ -98,6 +98,8 @@ uses
         function PopVal(expect: TWasmBasicType): TWasmBasicType;
         procedure PushVals(vals: TWasmBasicTypeList);
         function PopVals(vals: TWasmBasicTypeList): TWasmBasicTypeList;
+
+        procedure PushCtrl(_opcode: tasmop; _in, _out: TWasmBasicTypeList);
       end;
 
       twasmstruc_stack = class;
@@ -499,6 +501,22 @@ uses
           Result[I]:=PopVal(vals[I]);
       end;
 
+    procedure TWasmValidationStacks.PushCtrl(_opcode: tasmop; _in, _out: TWasmBasicTypeList);
+      var
+        frame: TWasmControlFrame;
+      begin
+        FillChar(frame,SizeOf(frame),0);
+        with frame do
+          begin
+            opcode:=_opcode;
+            start_types:=Copy(_in);
+            end_types:=Copy(_out);
+            height:=FValueStack.Count;
+            unreachable:=False;
+          end;
+        FCtrlStack.Push(frame);
+      end;
+
     { twasmstruc_stack }
 
     function twasmstruc_stack.Get(Index: Integer): taicpu_wasm_structured_instruction;