浏览代码

+ introduced is_wasm_externref(tdef) helper

Nikolay Nikolov 2 年之前
父节点
当前提交
c33f47a707
共有 2 个文件被更改,包括 10 次插入2 次删除
  1. 9 1
      compiler/wasm32/symcpu.pas
  2. 1 1
      compiler/wasm32/tgcpu.pas

+ 9 - 1
compiler/wasm32/symcpu.pas

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

+ 1 - 1
compiler/wasm32/tgcpu.pas

@@ -107,7 +107,7 @@ unit tgcpu;
 
 
       if is_wasm_funcref(def) then
       if is_wasm_funcref(def) then
         wbt := wbt_funcref
         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
         wbt := wbt_externref
       else if is_pointer(def) then
       else if is_pointer(def) then
         wbt := wbt_i32 // wasm32
         wbt := wbt_i32 // wasm32