CSegDebugCommands.mesa
Edited by Sweet, 29-Nov-82 15:07:46
Edited by Bruce, 15-Sep-81 18:36:33
Edited by Haynes, 29-Nov-82 15:31:38
Last Edited by: Sweet, July 31, 1984 2:07:33 pm PDT
DIRECTORY
Ascii USING [CR, SP],
Convert,
CSegDebugDefs,
IO,
Labels,
Menus,
PrincOps,
RESOut,
Rope,
ViewerTools;
CSegDebugCommands: CEDAR PROGRAM
IMPORTS
Convert, CSegDebugDefs, IO, Labels, RESOut, Rope, ViewerTools
EXPORTS CSegDebugDefs, RESOut =
BEGIN OPEN CSegDebugDefs;
cancelAction: PUBLIC ERROR [endLine: BOOLEANFALSE] = CODE;
DoCommand: PUBLIC PROC [handle: Handle, cmd: CmdIndex, button: Menus.MouseButton] = {
ENABLE RESOut.cancelAction => GO TO dont;
Complain[h: handle, msg: NIL, abort: FALSE];
handle.stopFlag ← FALSE;
SELECT cmd FROM
wpc => IF button = red THEN {
i: INT = GetLongSelectionValue[handle];
IF ~(i IN [0..CARDINAL.LAST/2]) THEN
RESOut.Complain[h: handle, msg: "not a valid wpc"];
ViewerTools.SetContents [
handle.cmd.bpcVal,
Convert.RopeFromInt[from: 2*i, base: 8, showRadix: TRUE]]};
gfi => IF button = red THEN {
i: INT = GetLongSelectionValue[handle];
IF ~(i IN [1..PrincOps.GFTIndex.LAST]) THEN
RESOut.Complain[h: handle, msg: "not a valid gfi"];
TRUSTED {
gfti: PrincOps.GFTItem ← PrincOps.GFT[i];
gfti.epbias ← 0;
ViewerTools.SetContents [
handle.cmd.gfVal,
Convert.RopeFromInt[from: LOOPHOLE[gfti, CARDINAL], base: 8, showRadix: TRUE]]}};
pd => {PutAsProcDesc[handle, GetSelectionValue[handle]]};
find => {
found: BOOLEANFALSE;
found ← Search[handle ! RESOut.cancelAction => CONTINUE];
IF found OR handle.autoNext^ THEN {
handle.bytesShown ← handle.bytesSeen; DoNext[handle]}};
code => {
PutAsCode[handle ! RESOut.cancelAction => CONTINUE];
IF handle.autoNext^ THEN DoNext[handle]};
octal => {
PutAsOctal[handle ! RESOut.cancelAction => CONTINUE];
IF handle.autoNext^ THEN DoNext[handle]};
bytes => {
PutAsBytes[handle ! RESOut.cancelAction => CONTINUE];
IF handle.autoNext^ THEN DoNext[handle]};
ascii => {
PutAsAscii[handle ! RESOut.cancelAction => CONTINUE];
IF handle.autoNext^ THEN DoNext[handle]};
findEp => FindEP[handle, GetSelectionValue[handle]];
goLf => GoToLf[handle, GetSelectionValue[handle]];
dspLf => DspLf[handle, GetSelectionValue[handle]];
numMop => MopToRope[handle, GetSelectionValue[handle]];
mopNum => RopeToMop[handle, ViewerTools.GetSelectionContents[]];
prefix => DisplayPrefix[handle];
next => DoNext[handle];
back => BackupPc[handle];
link => PutLink[handle, GetSelectionValue[handle]];
evi => PutEntryItem[handle, GetSelectionValue[handle]];
ENDCASE;
EXITS
dont => RETURN;
};
DoNext: PROC [handle: Handle] =
BEGIN
bytePC: CARDINAL ← CSegDebugDefs.CellCard[handle, handle.cmd.bpcVal];
bytePC ← bytePC + handle.bytesShown;
handle.bytesShown ← 0;
ViewerTools.SetContents [
handle.cmd.bpcVal,
Convert.RopeFromInt[from: bytePC, base: 8, showRadix: TRUE]];
END;
RopeToMop: PUBLIC PROC [h: Handle, s: ROPE] =
BEGIN OPEN RESOut;
inst: BYTE = MopForRope[h, s];
PCr[h]; PRope[h, s]; PRope[h, " = "]; POctal[h, inst];
END;
MopToRope: PUBLIC PROC [h: Handle, inst: BYTE] =
BEGIN OPEN RESOut;
s: ROPE ← RopeForMop[h, inst];
PCr[h]; POctal[h, inst]; PRope[h, " = "]; PRope[h, s];
END;
Complain: PUBLIC PROCEDURE [h: REF ANY, msg: ROPE, abort, clear: BOOLEANTRUE] =
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 PROCEDURE [h: REF ANY, c: CHARACTER] =
BEGIN
handle: Handle = NARROW[h];
IF handle.stopFlag THEN ERROR cancelAction[TRUE];
handle.out.PutChar[c];
handle.charsOnLine ← SELECT c FROM
Ascii.CR => 0,
ENDCASE => handle.charsOnLine + 1;
END;
MakeRoom: PUBLIC PROCEDURE [h: REF ANY, chars, indent: CARDINAL]
RETURNS [was: BOOLEAN]=
BEGIN
handle: Handle = NARROW[h];
charsPerLine: CARDINAL = handle.msg.ww/handle.en-3;
IF handle.charsOnLine + chars <= charsPerLine THEN RETURN [TRUE];
PChar[h, Ascii.CR];
THROUGH [0..indent) DO PChar[h, Ascii.SP]; ENDLOOP;
RETURN[FALSE];
END;
END.