+ introduced is_wasm_externref(tdef) helper

This commit is contained in:
Nikolay Nikolov 2023-06-05 04:55:33 +03:00
parent 022d2804a9
commit c33f47a707
2 changed files with 10 additions and 2 deletions

View File

@ -208,6 +208,9 @@ const
{# Returns true if p is a WebAssembly funcref reference type }
function is_wasm_funcref(p : tdef): boolean;
{# Returns true if p is a WebAssembly externref reference type }
function is_wasm_externref(p : tdef): boolean;
implementation
uses
@ -225,6 +228,11 @@ implementation
result:=(p.typ=procvardef) and (po_wasm_funcref in tprocvardef(p).procoptions);
end;
function is_wasm_externref(p: tdef): boolean;
begin
result:=(p.typ=pointerdef) and (tcpupointerdef(p).is_wasm_externref);
end;
{****************************************************************************
tcpuproptertysym
@ -298,7 +306,7 @@ implementation
prm := tcpuparavarsym(pd.paras[i]);
if is_wasm_funcref(prm.vardef) then
result.add_param(wbt_funcref)
else if (prm.vardef.typ=pointerdef) and (tcpupointerdef(prm.vardef).is_wasm_externref) then
else if is_wasm_externref(prm.vardef) then
result.add_param(wbt_externref)
else case prm.paraloc[callerside].Size of
OS_8..OS_32, OS_S8..OS_S32:

View File

@ -107,7 +107,7 @@ unit tgcpu;
if is_wasm_funcref(def) then
wbt := wbt_funcref
else if (def.typ=pointerdef) and (tcpupointerdef(def).is_wasm_externref) then
else if is_wasm_externref(def) then
wbt := wbt_externref
else if is_pointer(def) then
wbt := wbt_i32 // wasm32