[PATCH 142/188] adding mutable flag for global variables

From fdd0998697323727e0fbd4af6322eb305f1a8960 Mon Sep 17 00:00:00 2001
From: Dmitry Boyarintsev <skalogryz.lists@gmail.com>
Date: Wed, 25 Mar 2020 11:24:36 -0400

git-svn-id: branches/wasm@46138 -
This commit is contained in:
nickysn 2020-08-03 13:01:35 +00:00
parent e31e57ceb1
commit 39c720778f
2 changed files with 18 additions and 7 deletions

View File

@ -114,9 +114,10 @@ type
TWasmGlobal = class(TObject)
public
id : TWasmId;
tp : byte; // byte;
value : TWasmInstrList;
id : TWasmId;
tp : byte; // byte;
isMutable : Boolean; // is mutable
value : TWasmInstrList;
LinkInfo : TLinkInfo;
ExportInfo : TExportInfo;
function StartValue: TWasmInstrList;

View File

@ -429,15 +429,25 @@ begin
allowValue := false;
end else if sc.token=weExport then begin
// export
end else
ErrorExpectButFound(sc, 'import or export')
end;
end;
if sc.token in WasmTypeTokens then begin
TokenTypeToValType(sc.token, dst.tp);
// parsing type. Global can be mutable type (mut i32)
if (sc.token=weOpenBrace) then sc.Next;
if sc.token = weMut then begin
dst.isMutable := true;
sc.Next;
end;
if (sc.token in WasmTypeTokens) then begin
TokenTypeToValType(sc.token, dst.tp);
sc.Next;
end else
ErrorExpectButFound(sc, 'type');
if dst.isMutable then ConsumeToken(sc, weCloseBrace);
if allowValue and (sc.token = weOpenBrace) then begin
sc.Next;
ParseInstrList(sc, dst.StartValue);