[PATCH 122/188] adding parsing of jump vectors for br_table

From 90a6eded0c3af6a418c7949c3589258f65846931 Mon Sep 17 00:00:00 2001
From: Dmitry Boyarintsev <skalogryz.lists@gmail.com>
Date: Mon, 23 Mar 2020 15:43:23 -0400

git-svn-id: branches/wasm@46118 -
This commit is contained in:
nickysn 2020-08-03 13:01:14 +00:00
parent bf0a263074
commit 7facec1371
2 changed files with 30 additions and 6 deletions

View File

@ -85,6 +85,10 @@ type
hasRelocIdx : Boolean;
relocIdx : integer;
relocType : Byte;
vecTableCount : Integer;
vecTable : array of TWasmId;
function addInstType: TWasmFuncType;
constructor Create;
destructor Destroy; override;

View File

@ -144,6 +144,11 @@ begin
if Result then sc.Next;
end;
function ParseId(sc: TWatScanner; var id: TWasmId): boolean;
begin
Result := ParseNumOfId(sc, id.idNum, id.id);
end;
function TokenTypeToValType(t: TWatToken; out tp: byte): Boolean;
begin
Result:=true;
@ -260,7 +265,27 @@ begin
end;
//ip2Leb, // memory arguments, ask for offset + align
//ipTable, // a complex structure... used for br_table only
ipJumpVec:
begin
while (sc.token in [weNumber, weIdent]) do begin
if (ci.vecTableCount = length(ci.vecTable)) then begin
if (ci.vecTableCount = 0) then SetLength(ci.vecTable, 2)
else SetLength(ci.vecTable, ci.vecTableCount * 2);
end;
ParseId(sc, ci.vecTable[ci.vecTableCount]);
inc(ci.vecTableCount);
end;
if (ci.vecTableCount<2) then begin
ErrorExpectButFound(sc, 'label');
Exit;
end;
dec(ci.vecTableCount);
ci.operandIdx := ci.vecTable[ci.vecTableCount].id;
ci.operandNum := ci.vecTable[ci.vecTableCount].idNum;
end;
ipResType: // result type used for blocks, such as If, block or loop
begin
if sc.token = weIdent then begin
@ -393,11 +418,6 @@ begin
sc.Next;
end;
function ParseId(sc: TWatScanner; var id: TWasmId): boolean;
begin
Result := ParseNumOfId(sc, id.idNum, id.id);
end;
procedure ParseTable(sc: TWatScanner; dst: TWasmTable);
begin
sc.Next;