mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-07 13:10:34 +02:00
[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:
parent
bf0a263074
commit
7facec1371
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user