Browse Source

[PATCH 123/188] parsing memory entries

From ab8b51f0bda3e4fc9ca192ad10b635d94ce2ca28 Mon Sep 17 00:00:00 2001
From: Dmitry Boyarintsev <[email protected]>
Date: Mon, 23 Mar 2020 16:09:27 -0400

git-svn-id: branches/wasm@46119 -
nickysn 5 years ago
parent
commit
5f4ca22e1a
1 changed files with 22 additions and 0 deletions
  1. 22 0
      utils/wasmbin/watparser.pas

+ 22 - 0
utils/wasmbin/watparser.pas

@@ -347,6 +347,19 @@ begin
   ConsumeToken(sc, weCloseBrace);
 end;
 
+procedure ParseMemory(sc: TWatScanner; dst: TWasmMemory);
+begin
+  if sc.token=weMemory then sc.Next;
+
+  if sc.token in [weIdent, weNumber] then
+    ParseId(sc, dst.id);
+
+  // todo: parsing of ImportInfo
+  // todo: parsing of ExportInfo
+
+  ConsumeToken(sc, weCloseBrace);
+end;
+
 procedure ParseExport(sc: TWatScanner; dst: TWasmExport);
 begin
   if sc.token=weExport then
@@ -433,6 +446,7 @@ var
   symlist : TAsmSymList;
   f       : TWasmFunc;
   imp     : TWasmImport;
+  m       : TWasmMemory;
 begin
   if not ConsumeOpenToken(sc, weModule) then
     ErrorExpectButFound(sc, 'module');
@@ -457,8 +471,16 @@ begin
         weFunc: begin
           f:=dst.AddFunc;
           symlist.ToLinkInfo(f.LinkInfo);
+          symlist.Clear;
           ParseFunc(sc, f);
+        end;
+        weMemory:
+        begin
+          writeln('trying to parse memory');
+          m:=dst.AddMemory;
+          symlist.ToLinkInfo(f.LinkInfo);
           symlist.Clear;
+          ParseMemory(sc, m);
         end;
         weExport:
         begin