瀏覽代碼

+ support using nil constants for setting values of WebAssembly reference types (funcref and externref)

Nikolay Nikolov 2 年之前
父節點
當前提交
9daabb2123

+ 12 - 0
compiler/wasm32/hlcgcpu.pas

@@ -449,6 +449,18 @@ implementation
                 internalerror(2010110702);
             end;
           end;
+        R_EXTERNREFREGISTER:
+          begin
+            if a<>0 then
+              internalerror(2023061101);
+            list.Concat(taicpu.op_none(a_ref_null_externref));
+          end;
+        R_FUNCREFREGISTER:
+          begin
+            if a<>0 then
+              internalerror(2023061102);
+            list.Concat(taicpu.op_none(a_ref_null_funcref));
+          end;
         else
           internalerror(2010110703);
       end;

+ 9 - 0
tests/test/wasm/twasmexternref1.pp

@@ -25,5 +25,14 @@ begin
   testproc4 := q;
 end;
 
+function testproc5(q: WasmExternRef): WasmExternRef;
+var
+  w: WasmExternRef;
+begin
+  w := nil;
+  testproc5 := nil;
+end;
+
 begin
+  testproc5(nil);
 end.

+ 9 - 0
tests/test/wasm/twasmfuncref1.pp

@@ -30,5 +30,14 @@ begin
   testproc4 := q;
 end;
 
+function testproc5(q: TWasmFuncRef): TWasmFuncRef;
+var
+  w: TWasmFuncRef;
+begin
+  w := nil;
+  testproc5 := nil;
+end;
+
 begin
+  testproc5(nil);
 end.

+ 9 - 0
tests/test/wasm/twasmfuncref1a.pp

@@ -30,5 +30,14 @@ begin
   testproc4 := q;
 end;
 
+function testproc5(q: TWasmFuncRef): TWasmFuncRef;
+var
+  w: TWasmFuncRef;
+begin
+  w := nil;
+  testproc5 := nil;
+end;
+
 begin
+  testproc5(nil);
 end.