RoseLoggingImpl.Mesa
Last Edited by: Spreitzer, October 6, 1984 5:23:29 pm PDT
DIRECTORY IO, RoseCreate, RoseEvents, RoseLogging, RoseTypes;
RoseLoggingImpl:
CEDAR
PROGRAM
IMPORTS IO, RoseCreate, RoseEvents, RoseTypes
EXPORTS RoseLogging =
BEGIN OPEN RoseTypes, RoseLogging;
LORA: TYPE = LIST OF REF ANY;
WriteRow:
PUBLIC PROC [row: Row] = {
IF row.intro # NIL THEN row.intro[row];
FOR elts: EltList ← row.elts, elts.rest
WHILE elts #
NIL
DO
val: ROPE;
val ← elts.first.nFmt.FormatValue[elts.first.n, elts.first.nFmt, ValWP[elts.first.n]];
row.to.PutF[elts.first.ioFmt, IO.rope[val]];
ENDLOOP;
};
WriteEverySettle:
PUBLIC
PROC [row: Row, sim: Simulation] = {
RoseEvents.AddWatcher[event: $Settled, watcher: [NoteSettled, row], watched: sim];
};
DontWriteEverySettle:
PUBLIC
PROC [row: Row, sim: Simulation] = {
RoseEvents.RemoveWatcher[event: $Settled, watcher: [NoteSettled, row], watched: sim];
};
NoteSettled:
PROC [event:
ATOM, watched, watcherData, arg:
REF
ANY]
--RoseEvents.NotifyProc-- = {
row: Row ← NARROW[watcherData];
WriteRow[row];
};
RowFromNames:
PUBLIC
PROC [to:
STREAM, enl: EltNamesList, pathPrefix:
LORA ←
NIL, from: Cell ←
NIL]
RETURNS [row: Row] = {
last: EltList ← NIL;
row ← NEW [RowRep ← [to: to, elts: NIL]];
FOR enl ← enl, enl.rest
WHILE enl #
NIL
DO
thisFrom: Cell;
thisNode: Node;
next: EltList;
thisFrom ←
IF enl.first.from # NIL THEN enl.first.from
ELSE
IF from #
NIL
OR pathPrefix #
NIL
THEN RoseCreate.LookupCell[path: pathPrefix, from: from]
ELSE NIL;
thisNode ← RoseCreate.LookupNode[
path:
WITH enl.first.name
SELECT
FROM
r: ROPE => LIST[r],
rt: REF TEXT => LIST[rt],
l: LORA => l,
ENDCASE => ERROR,
from: thisFrom];
IF thisNode = NIL THEN ERROR;
next ←
LIST[[
n: thisNode,
nFmt: thisNode.type.procs.GetFormat[
thisNode.type,
enl.first.nodeFormat],
ioFmt: IF enl.first.ioFormat # NIL THEN enl.first.ioFormat ELSE IF enl.rest = NIL THEN "%g\n" ELSE "%g\t"
]];
IF next.first.nFmt = NIL THEN ERROR;
IF last = NIL THEN row.elts ← next ELSE last.rest ← next;
last ← next;
ENDLOOP;
};
END.