浏览代码

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

Nikolay Nikolov 3 年之前
父节点
当前提交
7f1050464a
共有 1 个文件被更改,包括 11 次插入0 次删除
  1. 11 0
      compiler/wasm32/cpupi.pas

+ 11 - 0
compiler/wasm32/cpupi.pas

@@ -323,6 +323,7 @@ implementation
 
 
       twasmblockitem = class(TLinkedListItem)
       twasmblockitem = class(TLinkedListItem)
         blockstart: taicpu;
         blockstart: taicpu;
+        elseinstr: taicpu;
         constructor Create(ablockstart: taicpu);
         constructor Create(ablockstart: taicpu);
       end;
       end;
 
 
@@ -464,6 +465,16 @@ implementation
                           inc(cur_nesting_depth);
                           inc(cur_nesting_depth);
                         end;
                         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_block,
                       a_end_loop,
                       a_end_loop,
                       a_end_if,
                       a_end_if,