Browse Source

[PATCH 177/188] update parsing of module level elements

From ee529729a987fda74c312a4e49e8246f127920ce Mon Sep 17 00:00:00 2001
From: Dmitry Boyarintsev <[email protected]>
Date: Wed, 8 Apr 2020 11:58:48 -0400

git-svn-id: branches/wasm@46173 -
nickysn 5 years ago
parent
commit
cdc7401d91
1 changed files with 8 additions and 6 deletions
  1. 8 6
      utils/wasmbin/watparser.pas

+ 8 - 6
utils/wasmbin/watparser.pas

@@ -593,13 +593,9 @@ begin
   if sc.token = weElem then sc.Next;
   if sc.token = weElem then sc.Next;
 
 
   if parseIdOffset then begin
   if parseIdOffset then begin
-    if sc.token<>weIdent then
-      ErrorExpectButFound(sc, 'identifier');
-
-    dst.tableIdx := sc.resInt32;
-    sc.Next;
-
+    ParseId(sc, dst.tableId);
     if (sc.token = weOpenBrace) then begin
     if (sc.token = weOpenBrace) then begin
+      sc.Next;
       ParseInstrList(sc, dst.AddOffset);
       ParseInstrList(sc, dst.AddOffset);
       ConsumeToken(sc, weCloseBrace);
       ConsumeToken(sc, weCloseBrace);
     end;
     end;
@@ -679,6 +675,7 @@ var
   imp     : TWasmImport;
   imp     : TWasmImport;
   m       : TWasmMemory;
   m       : TWasmMemory;
   g       : TWasmGlobal;
   g       : TWasmGlobal;
+  e       : TWasmElement;
 begin
 begin
   if not ConsumeOpenToken(sc, weModule) then
   if not ConsumeOpenToken(sc, weModule) then
     ErrorExpectButFound(sc, 'module');
     ErrorExpectButFound(sc, 'module');
@@ -732,6 +729,11 @@ begin
           symlist.Clear;
           symlist.Clear;
           ParseGlobal(sc, g);
           ParseGlobal(sc, g);
         end;
         end;
+        weElem: begin
+          e:=dst.AddElement;
+          symlist.Clear;
+          ParseElem(sc, e, true);
+        end;
       else
       else
         ErrorExpectButFound(sc, 'func', TokenStr[sc.token]);
         ErrorExpectButFound(sc, 'func', TokenStr[sc.token]);
       end;
       end;