Browse Source

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 years ago
parent
commit
70cb650d89
1 changed files with 2 additions and 0 deletions
  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;