Browse Source

[PATCH 141/188] parsing offset and align

From 828b36f3bc1b812aef0edde11a10e914a5432feb Mon Sep 17 00:00:00 2001
From: Dmitry Boyarintsev <[email protected]>
Date: Wed, 25 Mar 2020 10:43:19 -0400

git-svn-id: branches/wasm@46137 -
nickysn 5 years ago
parent
commit
e31e57ceb1
2 changed files with 20 additions and 2 deletions
  1. 2 1
      utils/wasmbin/wasmmodule.pas
  2. 18 1
      utils/wasmbin/watparser.pas

+ 2 - 1
utils/wasmbin/wasmmodule.pas

@@ -77,7 +77,8 @@ type
     operandIdx  : string;
     operandIdx  : string;
     operandNum  : integer;    // for "call_indirect" this is table index
     operandNum  : integer;    // for "call_indirect" this is table index
                               // for "if", "loop", "block" - it's type
                               // for "if", "loop", "block" - it's type
-    operandText : string;
+    operandText : string;     // it's "offset" for load operations
+    operandText2: string;     // it's "align" for load operations
     insttype    : TWasmFuncType; // used by call_indirect only
     insttype    : TWasmFuncType; // used by call_indirect only
 
 
     jumplabel   : string;   // the label is used only for "loop", "block" and "if"
     jumplabel   : string;   // the label is used only for "loop", "block" and "if"

+ 18 - 1
utils/wasmbin/watparser.pas

@@ -30,7 +30,7 @@ const
      'f32', 'f64',
      'f32', 'f64',
      'type',
      'type',
      'import', 'global', 'table', 'memory', 'local', 'export',
      'import', 'global', 'table', 'memory', 'local', 'export',
-     'elem', 'data', 'offset','align'
+     'elem', 'data', 'offset','align','='
      );
      );
 
 
   WasmTypeTokens = [wei32, wei64, wef32, wef64];
   WasmTypeTokens = [wei32, wei64, wef32, wef64];
@@ -261,6 +261,23 @@ begin
       ipLeb:
       ipLeb:
         ParseNumOrIdx(sc, ci.operandNum, ci.operandIdx);
         ParseNumOrIdx(sc, ci.operandNum, ci.operandIdx);
 
 
+      ipOfsAlign: begin
+        if sc.token = weOffset then begin
+          sc.Next;
+          ConsumeToken(sc, weEqual);
+          if sc.token<>weNumber then ErrorExpectButFound(sc, 'number');
+          ci.operandText := sc.resText;
+          sc.Next;
+        end;
+        if sc.token = weAlign then begin
+          sc.Next;
+          ConsumeToken(sc, weEqual);
+          if sc.token<>weNumber then ErrorExpectButFound(sc, 'number');
+          ci.operandText2 := sc.resText;
+          sc.Next;
+        end;
+      end;
+
       ipi32,ipi64,ipf32,ipf64,ipi32OrFunc:
       ipi32,ipi64,ipf32,ipf64,ipi32OrFunc:
       begin
       begin
         if (INST_FLAGS[ci.code].Param = ipi32OrFunc) and (sc.token = weIdent) then
         if (INST_FLAGS[ci.code].Param = ipi32OrFunc) and (sc.token = weIdent) then