Browse Source

+ support try_table blocks in resolve_labels_of_asmlist_with_try_blocks_recursive

Nikolay Nikolov 3 days ago
parent
commit
c19dcab3f5
1 changed files with 20 additions and 13 deletions
  1. 20 13
      compiler/wasm32/cpupi.pas

+ 20 - 13
compiler/wasm32/cpupi.pas

@@ -962,20 +962,27 @@ implementation
             begin
               if hp.typ=ait_wasm_structured_instruction then
                 begin
-                  if not (taicpu_wasm_structured_instruction(hp).wstyp in [aitws_legacy_try_catch,aitws_legacy_try_delegate]) then
-                    internalerror(2023102201);
-                  resolve_labels_of_asmlist_with_try_blocks_recursive(tai_wasmstruc_legacy_try(hp).try_asmlist);
-                  if taicpu_wasm_structured_instruction(hp).wstyp=aitws_legacy_try_catch then
-                    with tai_wasmstruc_legacy_try_catch(hp) do
-                      begin
-                        for i:=low(catch_list) to high(catch_list) do
-                          resolve_labels_of_asmlist_with_try_blocks_recursive(catch_list[i].asmlist);
-                        resolve_labels_of_asmlist_with_try_blocks_recursive(catch_all_asmlist);
-                      end
-                  else if taicpu_wasm_structured_instruction(hp).wstyp=aitws_legacy_try_delegate then
-                    {nothing}
+                  if taicpu_wasm_structured_instruction(hp).wstyp=aitws_try_table then
+                    begin
+                      resolve_labels_of_asmlist_with_try_blocks_recursive(tai_wasmstruc_try_table(hp).inner_asmlist);
+                    end
                   else
-                    internalerror(2023102202);
+                    begin
+                      if not (taicpu_wasm_structured_instruction(hp).wstyp in [aitws_legacy_try_catch,aitws_legacy_try_delegate]) then
+                        internalerror(2023102201);
+                      resolve_labels_of_asmlist_with_try_blocks_recursive(tai_wasmstruc_legacy_try(hp).try_asmlist);
+                      if taicpu_wasm_structured_instruction(hp).wstyp=aitws_legacy_try_catch then
+                        with tai_wasmstruc_legacy_try_catch(hp) do
+                          begin
+                            for i:=low(catch_list) to high(catch_list) do
+                              resolve_labels_of_asmlist_with_try_blocks_recursive(catch_list[i].asmlist);
+                            resolve_labels_of_asmlist_with_try_blocks_recursive(catch_all_asmlist);
+                          end
+                      else if taicpu_wasm_structured_instruction(hp).wstyp=aitws_legacy_try_delegate then
+                        {nothing}
+                      else
+                        internalerror(2023102202);
+                    end;
                 end;
               hp:=tai(hp.next);
             end;