瀏覽代碼

+ introduced is_wasm_funcref(tdef) helper

Nikolay Nikolov 2 年之前
父節點
當前提交
022d2804a9
共有 2 個文件被更改,包括 9 次插入2 次删除
  1. 8 1
      compiler/wasm32/symcpu.pas
  2. 1 1
      compiler/wasm32/tgcpu.pas

+ 8 - 1
compiler/wasm32/symcpu.pas

@@ -205,6 +205,8 @@ type
 const
   pbestrealtype : ^tdef = @s64floattype;
 
+  {# Returns true if p is a WebAssembly funcref reference type }
+  function is_wasm_funcref(p : tdef): boolean;
 
 implementation
 
@@ -218,6 +220,11 @@ implementation
     tgcpu
     ;
 
+  function is_wasm_funcref(p: tdef): boolean;
+  begin
+    result:=(p.typ=procvardef) and (po_wasm_funcref in tprocvardef(p).procoptions);
+  end;
+
 
   {****************************************************************************
                                tcpuproptertysym
@@ -289,7 +296,7 @@ implementation
           for i:=0 to pd.paras.Count-1 do
             begin
               prm := tcpuparavarsym(pd.paras[i]);
-              if (prm.vardef.typ=procvardef) and (po_wasm_funcref in tprocvardef(prm.vardef).procoptions) then
+              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
                 result.add_param(wbt_externref)

+ 1 - 1
compiler/wasm32/tgcpu.pas

@@ -105,7 +105,7 @@ unit tgcpu;
       if not Result then
         Exit;
 
-      if (def.typ=procvardef) and (po_wasm_funcref in tprocvardef(def).procoptions) then
+      if is_wasm_funcref(def) then
         wbt := wbt_funcref
       else if (def.typ=pointerdef) and (tcpupointerdef(def).is_wasm_externref) then
         wbt := wbt_externref