Pārlūkot izejas kodu

+ added 'else' tracking for the if..end_if blocks

Nikolay Nikolov 3 gadi atpakaļ
vecāks
revīzija
7f1050464a
1 mainītis faili ar 11 papildinājumiem un 0 dzēšanām
  1. 11 0
      compiler/wasm32/cpupi.pas

+ 11 - 0
compiler/wasm32/cpupi.pas

@@ -323,6 +323,7 @@ implementation
 
       twasmblockitem = class(TLinkedListItem)
         blockstart: taicpu;
+        elseinstr: taicpu;
         constructor Create(ablockstart: taicpu);
       end;
 
@@ -464,6 +465,16 @@ implementation
                           inc(cur_nesting_depth);
                         end;
 
+                      a_else:
+                        begin
+                          cblock:=twasmblockitem(blockstack.Last);
+                          if (cblock=nil) or
+                             (cblock.blockstart.opcode<>a_if) or
+                             assigned(cblock.elseinstr) then
+                            internalerror(2021102302);
+                          cblock.elseinstr:=lastinstr;
+                        end;
+
                       a_end_block,
                       a_end_loop,
                       a_end_if,