<> <> <> <<>> DIRECTORY Rope, Termination; TerminationImpl: CEDAR MONITOR IMPORTS Rope EXPORTS Termination ~ BEGIN Closure: TYPE = RECORD [proc: PROC[REF], data: REF]; callbacks: LIST OF Closure ¬ NIL; debuggingMode: PUBLIC BOOL ¬ FALSE; quitWorld: PUBLIC ERROR [msg: Rope.ROPE] = CODE; XRExitWorld: PROC [status: INT] = TRUSTED MACHINE CODE { ".XR_ExitWorld" }; XRWrite: PROC [c: CHAR] = TRUSTED MACHINE CODE { "XR_DebugPutChar" }; SetDebuggingMode: PUBLIC PROC [] = { debuggingMode ¬ TRUE }; CallBeforeQuitWorld: PUBLIC ENTRY PROC [proc: PROC[REF], data: REF ¬ NIL] = { callbacks ¬ CONS[[proc, data], callbacks]; }; QuitWorld: PUBLIC PROC [userMsg: Rope.ROPE, interceptable: BOOL] = { EachChar: Rope.ActionType = {XRWrite[c]}; len: INT ¬ Rope.Length[userMsg]; IF debuggingMode AND interceptable THEN ERROR quitWorld[userMsg]; FOR l: LIST OF Closure ¬ callbacks, l.rest WHILE l#NIL DO l.first.proc[l.first.data] ENDLOOP; [] ¬ Rope.Map[base: userMsg, action: EachChar]; IF len>0 AND Rope.Fetch[userMsg, len-1]#'\n THEN XRWrite['\n]; XRExitWorld[IF interceptable THEN 0 ELSE -1]; }; <<>> END.