Browse Source

[PATCH 113/188] adding parsing a type block

From e335bce46dc54fdd2e9e36e57090f8cc86ebafca Mon Sep 17 00:00:00 2001
From: Dmitry Boyarintsev <[email protected]>
Date: Wed, 18 Mar 2020 13:15:31 -0400

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

+ 18 - 1
utils/wasmbin/watparser.pas

@@ -261,7 +261,24 @@ begin
 
       //ip2Leb,  // memory arguments, ask for offset + align
       //ipTable,   // a complex structure... used for br_table only
-      //ipResType  // result type used for blocks, such as If, block or loop
+      ipResType:  // result type used for blocks, such as If, block or loop
+      begin
+        if (sc.token = weOpenBrace) then begin
+          ConsumeToken(sc, weOpenBrace);
+          ConsumeToken(sc, weResult);
+          case sc.token of
+            wei32: ci.operandNum := valtype_i32;
+            wei64: ci.operandNum := valtype_i64;
+            wef32: ci.operandNum := valtype_f32;
+            wef64: ci.operandNum := valtype_f64;
+          else
+            ErrorExpectButFound(sc, 'i32');
+          end;
+          sc.Next;
+          ConsumeToken(sc, weCloseBrace);
+        end else
+          ci.operandNum := block_type; // no value type
+      end;
 
     end;
   end;