DMImpl.mesa
Written By: Pradeep Sindhu, August 24, 1985 7:17:26 pm PDT
LastEdited By: Pradeep Sindhu, September 2, 1985 10:30:40 pm PDT
DIRECTORY
AMBridge,
AMTypes,
Convert,
DM,
DragOpsCrossUtils,
IO,
PrintTV,
Rope;
DMImpl: CEDAR PROGRAM
IMPORTS AMBridge, Convert, DragOpsCrossUtils, IO, PrintTV
EXPORTS DM
= BEGIN OPEN DM;
Apply: PUBLIC PROC [component: Component, action: Action] = {
IF component#NIL THEN component.action[action][component]
};
ListApply: PUBLIC PROC [componentList: ComponentList, action: Action] = {
Applies action to each of the components in the list c.subComponents
FOR cl: ComponentList ← componentList, cl.rest WHILE cl#NIL DO
cl.first.action[action][cl.first]
ENDLOOP
};
ConsHistory: PUBLIC PROC [phase: Action, data: REF ANY, history: LIST OF HistoryElement] RETURNS [newHistory: LIST OF HistoryElement] = {
he: HistoryElement ← NEW [HistoryElementRec ← [phase: phase, data: data]];
newHistory ← CONS[he, history]
};
PrintHistory: PUBLIC PROC [c: DM.Component, out: IO.STREAM] = {
tv: AMTypes.TV;
Print c's history
out.PutF["Component: %g\n", [rope[Convert.RopeFromAtom[c.componentType]]]];
FOR h: LIST OF HistoryElement ← Reverse[c.history], h.rest WHILE h#NIL DO
TRUSTED{tv ← AMBridge.TVForReferent[h.first]};
PrintTV.Print[tv: tv, put: out, depth: 1000, width: 1000, verbose: FALSE];
out.PutF["\n"]
ENDLOOP;
out.PutF["\n"];
Print the history for each of c's subcomponents
FOR cl: DM.ComponentList ← c.subComponents, cl.rest WHILE cl#NIL DO
PrintHistory[cl.first, out]
ENDLOOP
};
Reverse: PROC [list: LIST OF HistoryElement] RETURNS [rev: LIST OF HistoryElement] = {
rev ← NIL;
WHILE list#NIL DO rev ← CONS[list.first, rev]; list ← list.rest ENDLOOP;
};
PrintWord: PrintTV.TVPrintProc = {
[tv: TV, data: REF ANY, stream: STREAM, depth: INT ← 4, width: INT ← 32, verbose: BOOL ← FALSE] RETURNS [useOld: BOOL ← FALSE]
wdRef: REF Word;
TRUSTED{wdRef ← NARROW[AMBridge.SomeRefFromTV[tv]]};
stream.Put[[integer[DragOpsCrossUtils.WordToInt[wdRef^]]]]
};
PrintTV.RegisterTVPrintProc[type: CODE[Word], proc: PrintWord];
END.