DEFINITION MODULE LongJump; (* (C) Copyright 1987 Fitted Software Tools. All rights reserved. *) (* SetJump saves the current execution environment in the passed parameter, and returns 0. LongJump restores the environment saved by a prior SetJump; execution is resumed as a return from SetJump, with SetJump returning the 'return' value passed to LongJump, which, for obvious reasons, must not be 0. When LongJump is invoked, the procedure that did the corresponding SetJump must still be active !!! Example: PROCEDURE main; ... IF SetJump( env ) = 0 THEN Parse ELSE WriteString("error in Parse") END; ... PROCEDURE Parse; ... IF errorcond THEN LongJump( env, 1 ) END; The procedure main calls SetJump to save the current execution environment in env. SetJump returns 0, and Parse is called. If Parse detects an error, it calls LongJump with a return value of 1. The main procedure is resumed at the point of return from SetJump, the IF fails and the string is written out. *) TYPE JumpBuffer = RECORD savPC, savCS, savSP, savBP :CARDINAL; END; PROCEDURE SetJump( VAR mark :JumpBuffer ) :CARDINAL; (* save the current execution environment in mark, return 0 *) PROCEDURE LongJump( VAR mark :JumpBuffer; return :CARDINAL ); (* restore the environment saved in mark, return from SetJump with the value return. *) END LongJump.