mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-20 18:29:28 +02:00
[PATCH 126/188] adding data entity parsing
From e996d96b6bf876611f7803f5e3367cae8a35c010 Mon Sep 17 00:00:00 2001 From: Dmitry Boyarintsev <skalogryz.lists@gmail.com> Date: Mon, 23 Mar 2020 16:23:09 -0400 git-svn-id: branches/wasm@46122 -
This commit is contained in:
parent
f1d711a61d
commit
0ff587582b
@ -347,6 +347,35 @@ begin
|
||||
ConsumeToken(sc, weCloseBrace);
|
||||
end;
|
||||
|
||||
procedure ParseData(sc: TWatScanner; dst: TWasmData);
|
||||
var
|
||||
l : integer;
|
||||
begin
|
||||
if sc.token=weData then sc.Next;
|
||||
|
||||
//id (if not exists, should be zero)
|
||||
if sc.token in [weIdent, weNumber] then
|
||||
ParseId(sc, dst.id);
|
||||
|
||||
// offset (if not exist, should be zero)
|
||||
if (sc.token = weOpenBrace) then begin
|
||||
sc.Next;
|
||||
ParseInstrList(sc, dst.StartOffset);
|
||||
ConsumeToken(sc, weCloseBrace);
|
||||
end;
|
||||
|
||||
// data (if not exist, then blank)
|
||||
if sc.token = weString then begin
|
||||
l := length(sc.resText);
|
||||
SetLength(dst.databuf, l);
|
||||
if l>0 then
|
||||
Move(sc.resText[1], dst.databuf[0], l);
|
||||
sc.Next;
|
||||
end;
|
||||
|
||||
ConsumeToken(sc, weCloseBrace);
|
||||
end;
|
||||
|
||||
procedure ParseMemory(sc: TWatScanner; dst: TWasmMemory);
|
||||
begin
|
||||
if sc.token=weMemory then sc.Next;
|
||||
@ -476,7 +505,6 @@ begin
|
||||
end;
|
||||
weMemory:
|
||||
begin
|
||||
writeln('trying to parse memory');
|
||||
m:=dst.AddMemory;
|
||||
symlist.ToLinkInfo(f.LinkInfo);
|
||||
symlist.Clear;
|
||||
@ -487,6 +515,10 @@ begin
|
||||
ParseExport(sc, dst.AddExport);
|
||||
symlist.Clear;
|
||||
end;
|
||||
weData:begin
|
||||
ParseData(sc, dst.AddData);
|
||||
symlist.Clear;
|
||||
end;
|
||||
else
|
||||
ErrorExpectButFound(sc, 'func', TokenStr[sc.token]);
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user