Browse Source

+ fix for the conversion of try..catch blocks to structured form

Nikolay Nikolov 1 year ago
parent
commit
8e66041b79
1 changed files with 6 additions and 7 deletions
  1. 6 7
      compiler/wasm32/aasmcpu.pas

+ 6 - 7
compiler/wasm32/aasmcpu.pas

@@ -521,10 +521,7 @@ uses
             repeat
             repeat
               pp:=tai(srclist.First);
               pp:=tai(srclist.First);
               if (pp.typ=ait_instruction) and (taicpu(pp).opcode in [a_catch,a_catch_all,a_end_try]) then
               if (pp.typ=ait_instruction) and (taicpu(pp).opcode in [a_catch,a_catch_all,a_end_try]) then
-                begin
-                  srclist.Remove(pp);
-                  Done:=True;
-                end
+                Done:=True
               else
               else
                 al.Concat(wasm_convert_first_item_to_structured(srclist));
                 al.Concat(wasm_convert_first_item_to_structured(srclist));
             until Done;
             until Done;
@@ -561,7 +558,11 @@ uses
           if p.typ=ait_instruction then
           if p.typ=ait_instruction then
             case taicpu(p).opcode of
             case taicpu(p).opcode of
               a_catch:
               a_catch:
-                parse_next_catch_block;
+                begin
+                  parse_next_catch_block;
+                  p:=tai(srclist.First);
+                  srclist.Remove(p);
+                end;
               a_catch_all:
               a_catch_all:
                 begin
                 begin
                   parse_catch_all;
                   parse_catch_all;
@@ -574,8 +575,6 @@ uses
             end
             end
           else
           else
             internalerror(2023100312);
             internalerror(2023100312);
-          p:=tai(srclist.First);
-          srclist.Remove(p);
         until Done;
         until Done;
       end;
       end;