浏览代码

Fixed address of trap instruction at end of procedures that don't return values

The generated trap instruction is the last one of a procedure. If the system reports its successor when handling the trap, its address does not lie within the boundary of the procedure. This fix solves the problem by artificial appending dead code (i.e. another trap instruction for brevity)

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@8170 8c9fc860-2736-0410-a75d-ab315db34111
negelef 7 年之前
父节点
当前提交
70cb650d89
共有 1 个文件被更改,包括 2 次插入0 次删除
  1. 2 0
      source/FoxIntermediateBackend.Mod

+ 2 - 0
source/FoxIntermediateBackend.Mod

@@ -1591,6 +1591,8 @@ TYPE
 				CallThis(position,"Runtime","Trap",1); 
 			ELSE
 				Emit(Trap(position,trapNo));
+				(* Artificially append code to keep address of the instruction following the trap at the end of procedure within its boundary *)
+				IF trapNo = ReturnTrap THEN Emit(Trap(position,NoReturnTrap)) END;
 			END;
 		END EmitTrap;