OSCedarImpl:
CEDAR
PROGRAM
IMPORTS BasicTime, Commander, IO, RealFns, UnsafeStorage
EXPORTS OSOps = BEGIN
PutChar:
PUBLIC
PROCEDURE [ch:
CHAR] = {
IF ch = '\l THEN out.PutChar[IO.CR] ELSE out.PutChar[ch];
};
GetSystemUZone:
PUBLIC
PROC
RETURNS [
UNCOUNTED
ZONE] =
TRUSTED {
RETURN [UnsafeStorage.GetSystemUZone[]];
};
microSecondsPerMilSec: CARD = 1000;
CurrentTime:
PUBLIC
PROCEDURE
RETURNS [currentTime:
LONG
CARDINAL] ~ {
currentTime ← BasicTime.PulsesToMicroseconds[
BasicTime.GetClockPulses[]]/microSecondsPerMilSec;
};
PutReal:
PUBLIC
PROCEDURE [r:
REAL] = {
IO.PutF[out, "%4.1f", [real[r]]];};
AlmostEqual:
PUBLIC
PROCEDURE [y, x:
REAL, distance:
INTEGER [-126..0]]
RETURNS [BOOLEAN] = {
RETURN[RealFns.AlmostEqual[y, x, distance]];
};
out: IO.STREAM;
Main: Commander.CommandProc
--PROC [cmd: Handle] RETURNS [result: REF ← NIL, msg: ROPE ← NIL] -- = {
out ← cmd.out;
};
Init:
PROCEDURE = {
Commander.Register["OSCedar", Main];
};
Init[];