DIRECTORY Basics USING [LongNumber], PrincOps USING [PsbIndex], PrincOpsUtils USING [ProcessToPsbIndex], Process USING [GetCurrent], Real USING [Exception, ExceptionFlags, Extended, NoExceptions, RealException], RealExceptions USING [CombinedFlags, FlagsArray]; RealExceptionsImpl: CEDAR PROGRAM IMPORTS PrincOpsUtils, Process, Real EXPORTS RealExceptions = BEGIN FlagsArray: TYPE = RealExceptions.FlagsArray; combined: LONG POINTER TO FlagsArray _ NIL; empty: RealExceptions.CombinedFlags = [Real.NoExceptions, Real.NoExceptions]; Init: PUBLIC UNSAFE PROC [lp: LONG POINTER TO FlagsArray] = TRUSTED { IF lp # NIL THEN { lp^ _ ALL[empty]; combined _ lp; }; }; ClearExceptions: PUBLIC PROC = { IF combined # NIL THEN TRUSTED { psbi: PrincOps.PsbIndex _ PrincOpsUtils.ProcessToPsbIndex[Process.GetCurrent[]]; combined[psbi].exceptions _ Real.NoExceptions; }; }; ClearSticky: PUBLIC PROC = { IF combined # NIL THEN TRUSTED { psbi: PrincOps.PsbIndex _ PrincOpsUtils.ProcessToPsbIndex[Process.GetCurrent[]]; combined[psbi].sticky _ Real.NoExceptions; }; }; ClearCombined: PUBLIC PROC = { IF combined # NIL THEN TRUSTED { psbi: PrincOps.PsbIndex _ PrincOpsUtils.ProcessToPsbIndex[Process.GetCurrent[]]; combined[psbi] _ empty; }; }; SetCombined: PUBLIC PROC [flags: RealExceptions.CombinedFlags] = { IF combined # NIL THEN TRUSTED { psbi: PrincOps.PsbIndex _ PrincOpsUtils.ProcessToPsbIndex[Process.GetCurrent[]]; combined[psbi] _ flags; }; }; SetException: PUBLIC PROC [which: Real.Exception] = { IF combined # NIL THEN TRUSTED { psbi: PrincOps.PsbIndex _ PrincOpsUtils.ProcessToPsbIndex[Process.GetCurrent[]]; combined[psbi].exceptions[which] _ TRUE; }; }; SetSticky: PUBLIC PROC [which: Real.Exception] = { IF combined # NIL THEN TRUSTED { psbi: PrincOps.PsbIndex _ PrincOpsUtils.ProcessToPsbIndex[Process.GetCurrent[]]; combined[psbi].sticky[which] _ TRUE; }; }; TestException: PUBLIC PROC [which: Real.Exception] RETURNS [BOOL] = { IF combined # NIL THEN TRUSTED { psbi: PrincOps.PsbIndex _ PrincOpsUtils.ProcessToPsbIndex[Process.GetCurrent[]]; IF combined[psbi].exceptions[which] THEN RETURN [TRUE]; }; RETURN [FALSE]; }; TestSticky: PUBLIC PROC [which: Real.Exception] RETURNS [BOOL] = { IF combined # NIL THEN TRUSTED { psbi: PrincOps.PsbIndex _ PrincOpsUtils.ProcessToPsbIndex[Process.GetCurrent[]]; IF combined[psbi].sticky[which] THEN RETURN [TRUE]; }; RETURN [FALSE]; }; GetExceptions: PUBLIC PROC RETURNS [Real.ExceptionFlags] = { IF combined # NIL THEN TRUSTED { psbi: PrincOps.PsbIndex _ PrincOpsUtils.ProcessToPsbIndex[Process.GetCurrent[]]; RETURN [combined[psbi].exceptions]; }; RETURN [Real.NoExceptions]; }; GetSticky: PUBLIC PROC RETURNS [Real.ExceptionFlags] = { IF combined # NIL THEN TRUSTED { psbi: PrincOps.PsbIndex _ PrincOpsUtils.ProcessToPsbIndex[Process.GetCurrent[]]; RETURN [combined[psbi].sticky]; }; RETURN [Real.NoExceptions]; }; GetCombined: PUBLIC PROC RETURNS [RealExceptions.CombinedFlags] = { IF combined # NIL THEN TRUSTED { psbi: PrincOps.PsbIndex _ PrincOpsUtils.ProcessToPsbIndex[Process.GetCurrent[]]; RETURN [combined[psbi]]; }; RETURN [empty]; }; RaiseException: PUBLIC PROC [ext: Real.Extended] RETURNS [clientFixup: BOOL, fraction: Basics.LongNumber] = { p: REF Real.Extended _ NEW[Real.Extended _ ext]; clientFixup _ SIGNAL Real.RealException[GetExceptions[], p]; fraction.li _ LOOPHOLE[p^.frac, INT]; }; END. ”RealExceptionsImpl.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Russ Atkinson (RRA) May 22, 1985 12:54:15 pm PDT Must be called to enable multi-process REAL exception handling. Clear the exceptions for the current process Clear the sticky bits for the current process Clear the sticky bits for the current process Sets the exception bits & sticky bits for the current process Sets a given exception for the current process Sets a given sticky bit for the current process Tests a particular exception for the current process Tests a particular sticky bit for the current process Samples the combined for the current process Samples the sticky bits for the current process Samples the sticky bits for the current process Raises Real.RealException with the current exception flags and the given extended number. Returns whatever the client directed if the client RESUMEs the signal. Κλ˜codešœ™Kšœ Οmœ1™