CDebugCommands.mesa
Edited by Bruce, 14-Oct-81 11:06:09
Edited by Sweet, 14-Jan-83 15:48:28
Edited by Haynes, 29-Nov-82 20:27:52
Sweet February 11, 1986 11:18:32 am PST
DIRECTORY
CDebugDefs USING [
CCCur, CCFirst, CellCard, CmdIndex, GetLongSelectionValue, GetSelectionValue, GoFwd,
Handle, PutAsCC, PutAsComponent, PutAsLabelInfoIndex,
PutAsStack, PutAsVar, PutCurrentBody, PutCurrentExpr,
PutCurrentSource, PutCurrentStmt, PutLabelState, PutNextCC, PutPrevCC,
PutRecentCC, PutStackDown, PutStackState, PutStackUp, PutTempState,
RopeForFop, RopeForMop, StackTop],
CodeDefs USING [StackIndex, StackNull],
IO,
Labels USING [Set],
Menus USING [MouseButton],
RESOut USING [PCr, PDecimal, POctal, PRope],
Rope USING [Concat, ROPE],
STDebugDefs USING [
NextSe, PutAsBti, PutAsCti, PutAsHti, PutAsMdi, PutAsSei, PutAsTree,
PutAsVariousRep],
Symbols USING [ISEIndex, ISENull, SEIndex],
Tree USING [Index],
ViewerTools USING [GetContents];
CDebugCommands: PROGRAM
IMPORTS CDebugDefs, IO, Labels, RESOut, Rope, STDebugDefs, ViewerTools
EXPORTS CDebugDefs, RESOut, STDebugDefs =
BEGIN OPEN CDebugDefs, STDebugDefs;
ROPE: TYPE = Rope.ROPE;
Handle: TYPE = CDebugDefs.Handle;
cancelAction: PUBLIC ERROR [endLine: BOOLEANFALSE] = CODE;
DoCommand: PUBLIC PROC [h: Handle, cmd: CmdIndex, button: Menus.MouseButton] =
BEGIN
ENABLE cancelAction => GO TO dont;
Complain[h: h, msg: NIL, abort: FALSE];
h.stopFlag ← FALSE;
SELECT cmd FROM
tree => {
index: Tree.Index ← GetSelectionValue[h];
PutAsTree[h, [subtree[index]]]};
asCC => PutAsCC[h, GetSelectionValue[h]];
var =>
BEGIN
RESOut.PCr[h];
PutAsVar[h, GetSelectionValue[h]];
END;
vcomp =>
BEGIN OPEN RESOut;
val: UNSPECIFIED ← GetSelectionValue[h];
PCr[h];
POctal[h, val]; PRope[h, "^ = "];
PutAsComponent[h, val];
END;
first => PutAsCC[h, CCFirst[h]];
cur => PutAsCC[h, CCCur[h]];
next => PutNextCC[h];
prev => PutPrevCC[h];
fwd => GoFwd[h, GetSelectionValue[h]];
rcnt => PutRecentCC[h, GetSelectionValue[h]];
temp => PutTempState[h];
allStack => PutStackState[h];
stack => PutAsStack[h, GetSelectionValue[h]];
tos => {
st: CodeDefs.StackIndex ← StackTop[h];
IF st = CodeDefs.StackNull THEN RESOut.PRope[h, "\nStack empty"]
ELSE PutAsStack[h, st]};
down => PutStackDown[h];
up => PutStackUp[h];
lbl => PutLabelState[h];
lii => PutAsLabelInfoIndex[h, GetSelectionValue[h]];
sei => {
sei: Symbols.SEIndex ← GetSelectionValue[h];
IF PutAsSei[h, sei] THEN h.lastId ← LOOPHOLE[sei]};
nextse => {
nsei: Symbols.ISEIndex ← NextSe[h, h.lastId];
IF nsei # Symbols.ISENull THEN {[] ← PutAsSei[h, nsei]; h.lastId ← nsei};
};
hti => PutAsHti[h, GetSelectionValue[h]];
cti => PutAsCti[h, GetSelectionValue[h]];
bti => PutAsBti[h, GetSelectionValue[h]];
mdi => PutAsMdi[h, GetSelectionValue[h]];
mop => PutAsMopcode[h, GetSelectionValue[h]];
fop => PutAsFopcode[h, GetSelectionValue[h]];
rep => PutAsVariousRep[h, GetLongSelectionValue[h]];
body => PutCurrentBody[h];
stmt => PutCurrentStmt[h];
expr => PutCurrentExpr[h];
gFrames => GFrameSheet[h];
source => PutCurrentSource[h];
ENDCASE;
EXITS
dont => RETURN;
END;
PutAsMopcode: PROCEDURE [h: Handle, n: CARDINAL] =
BEGIN OPEN RESOut;
PCr[h];
PDecimal[h, n];
PRope[h, " = z"];
PRope[h, RopeForMop[n]];
RETURN
END;
PutAsFopcode: PROCEDURE [h: Handle, n: CARDINAL] =
BEGIN OPEN RESOut;
PCr[h];
PDecimal[h, n];
PRope[h, " =q"];
PRope[h, RopeForFop[n]];
RETURN
END;
Things exported to STDebugDefs
TreeDepth: PUBLIC SAFE PROC [h: REF ANY] RETURNS [CARDINAL] = TRUSTED {
han: Handle ← NARROW[h];
RETURN [CDebugDefs.CellCard[han, han.cmd.dVal]]};
ShowLinks: PUBLIC SAFE PROCEDURE [h: REF ANY] RETURNS [BOOL] = TRUSTED {
han: Handle ← NARROW[h];
RETURN[han.showLinks^]};
Complain: PUBLIC SAFE PROCEDURE [h: REF ANY , msg: ROPE, abort, clear: BOOLEANTRUE] =
TRUSTED BEGIN
handle: Handle ← NARROW[h];
IF ~clear THEN msg ← Rope.Concat[ViewerTools.GetContents[handle.msg], msg];
Labels.Set[handle.msg, msg];
IF abort THEN ERROR cancelAction;
END;
log writing procedures
PChar: PUBLIC SAFE PROCEDURE [h: REF ANY , c: CHARACTER] = TRUSTED
BEGIN
handle: Handle = NARROW[h];
IF handle.stopFlag THEN ERROR cancelAction[TRUE];
handle.out.PutChar[c];
handle.charsOnLine ← SELECT c FROM
'\n => 0,
ENDCASE => handle.charsOnLine + 1;
END;
MakeRoom: PUBLIC SAFE PROCEDURE [h: REF ANY , chars, indent: CARDINAL]
RETURNS [was: BOOLEAN] = TRUSTED
BEGIN
handle: Handle = NARROW[h];
charsPerLine: CARDINAL = handle.ts.ww/handle.en-3;
IF handle.charsOnLine + chars <= charsPerLine THEN RETURN [TRUE];
PChar[h, '\n];
THROUGH [0..indent) DO PChar[h, ' ]; ENDLOOP;
RETURN[FALSE];
END;
END.