Преглед изворни кода

+ added TWasmControlStack and frame. Not used, yet. Will be used in the future
for WebAssembly stack tracking and validation.

Nikolay Nikolov пре 1 година
родитељ
комит
fadf43a33b
1 измењених фајлова са 48 додато и 0 уклоњено
  1. 48 0
      compiler/wasm32/aasmcpu.pas

+ 48 - 0
compiler/wasm32/aasmcpu.pas

@@ -55,6 +55,34 @@ uses
         property Items[AIndex: Integer]: TWasmBasicType read GetItems write SetItems; default;
         property Items[AIndex: Integer]: TWasmBasicType read GetItems write SetItems; default;
       end;
       end;
 
 
+      { TWasmControlFrame }
+
+      TWasmControlFrame = class
+        opcode: tasmop;
+        start_types: array of TWasmBasicType;
+        end_types: array of TWasmBasicType;
+        height: Integer;
+        unreachable: Boolean;
+      end;
+
+      { TWasmControlStack }
+
+      TWasmControlStack = class
+      end;
+
+      { TWasmValidationStacks }
+
+      TWasmValidationStacks = class
+      private
+        FValueStack: TWasmValueStack;
+        FCtrlStack: TWasmControlStack;
+      public
+        constructor Create;
+        destructor Destroy; override;
+
+        procedure PushVal(vt: TWasmBasicType);
+      end;
+
       twasmstruc_stack = class;
       twasmstruc_stack = class;
       TAsmMapFuncResultType = (amfrtNoChange, amfrtNewAi, amfrtNewList, amfrtDeleteAi);
       TAsmMapFuncResultType = (amfrtNoChange, amfrtNewAi, amfrtNewList, amfrtDeleteAi);
       TAsmMapFuncResult = record
       TAsmMapFuncResult = record
@@ -346,6 +374,26 @@ uses
         SetLength(FValStack,Length(FValStack)-1);
         SetLength(FValStack,Length(FValStack)-1);
       end;
       end;
 
 
+    { TWasmValidationStacks }
+
+    constructor TWasmValidationStacks.Create;
+      begin
+        FValueStack:=TWasmValueStack.Create;
+        FCtrlStack:=TWasmControlStack.Create;
+      end;
+
+    destructor TWasmValidationStacks.Destroy;
+      begin
+        FValueStack.Free;
+        FCtrlStack.Free;
+        inherited Destroy;
+      end;
+
+    procedure TWasmValidationStacks.PushVal(vt: TWasmBasicType);
+      begin
+        FValueStack.Push(vt);
+      end;
+
     { twasmstruc_stack }
     { twasmstruc_stack }
 
 
     function twasmstruc_stack.Get(Index: Integer): taicpu_wasm_structured_instruction;
     function twasmstruc_stack.Get(Index: Integer): taicpu_wasm_structured_instruction;