Browse Source

+ handle the local and global variable instructions with a constant integer
parameter in twasmreader.HandlePlainInstruction

Nikolay Nikolov 1 year ago
parent
commit
95593f15dd
1 changed files with 41 additions and 0 deletions
  1. 41 0
      compiler/wasm32/rawasmtext.pas

+ 41 - 0
compiler/wasm32/rawasmtext.pas

@@ -843,6 +843,47 @@ Unit rawasmtext;
                     result.operands[1].opr.typ:=OPR_CONSTANT;
                     result.operands[1].opr.typ:=OPR_CONSTANT;
                     result.operands[1].opr.val:=0;
                     result.operands[1].opr.val:=0;
                   end;
                   end;
+
+                { instructions that take a local variable parameter (or index) }
+                a_local_get,
+                a_local_set,
+                a_local_tee:
+                  case actasmtoken of
+                    AS_INTNUM:
+                      begin
+                        result.operands[1].opr.typ:=OPR_CONSTANT;
+                        result.operands[1].opr.val:=actinttoken;
+                        Consume(AS_INTNUM);
+                      end;
+                    {TODO:AS_ID}
+                    else
+                      begin
+                        { error: expected integer }
+                        result.Free;
+                        result:=nil;
+                        Consume(AS_INTNUM);
+                      end;
+                  end;
+
+                a_global_get,
+                a_global_set:
+                  case actasmtoken of
+                    AS_INTNUM:
+                      begin
+                        result.operands[1].opr.typ:=OPR_CONSTANT;
+                        result.operands[1].opr.val:=actinttoken;
+                        Consume(AS_INTNUM);
+                      end;
+                    {TODO:AS_ID}
+                    else
+                      begin
+                        { error: expected integer }
+                        result.Free;
+                        result:=nil;
+                        Consume(AS_INTNUM);
+                      end;
+                  end;
+
                 else
                 else
                   internalerror(2024071401);
                   internalerror(2024071401);
               end;
               end;