-- XXDebugInterface.mesa Edited by Bruce,  October 13, 1980  2:23 PM
    
DIRECTORY
  FormSW,
  ImageDefs USING [BcdTime],
  RESOut USING [WindowsObject],
  STDebugDefs USING [depthString, showLinks, STDebugMisc, STDebugSymbols, STDebugTrees],
  String USING [AppendString],
  Time USING [Append, Unpack],
  Tool,
  ToolWindow USING [TransitionProcType],
  Window,
  XXDebugCommandDefs USING [ParamIndex, Params],
  XXDebugDefs; 
      
XXDebugInterface: PROGRAM 
  IMPORTS FormSW, ImageDefs, STDebugDefs,
    String, Time, Tool, XXDebugDefs 
  EXPORTS XXDebugDefs =
  BEGIN
  OPEN FormSW, XXDebugDefs;
    
  windows: RESOut.WindowsObject ← [NIL, NIL, NIL, NIL];

  Init: PRIVATE PROCEDURE =
    BEGIN
    title: STRING = "Mesa 6.0 Debugger Debug of "L;
    herald: STRING ← [60];
    String.AppendString[to: herald, from: title];
    Time.Append[herald, Time.Unpack[ImageDefs.BcdTime[]]];
    herald.length ← herald.length - 3;
    windows.main ← Tool.Create[
      makeSWsProc: MakeMySWs,
      clientTransition: StateChanged,
      name: herald];
    XXDebugDefs.handle ← @windows;
    END;

  StateChanged: ToolWindow.TransitionProcType =
    BEGIN
    IF new = inactive THEN
      windows.msgSW ← windows.formSW ← windows.fileSW ← NIL;
    END;

  MakeMySWs: Tool.MakeSWsProc =
    BEGIN
    windows.msgSW ← Tool.MakeMsgSW[window: window];
    windows.formSW ← Tool.MakeFormSW[window: window, formProc: MakeParameterArray];
    windows.fileSW ← Tool.MakeFileSW[window: window, name: "XXDebug.log"L];
    END;

  TopCtxCol: CARDINAL = 0*7;
  StkCol: CARDINAL = TopCtxCol + 8*7;
  CtxCol: CARDINAL = StkCol + 7*7;
  CtCol: CARDINAL = CtxCol + 8*7;
  MTCol: CARDINAL = CtCol + 4*7;
  LitCol: CARDINAL = MTCol + 4*7;
  SourceCol: CARDINAL = LitCol + 7*7;
  ListCol: CARDINAL = SourceCol + 13*7;

  topctxPlace: Window.Place = [x: TopCtxCol+0*7, y: line0];
  tosPlace: Window.Place = [x: TopCtxCol+0*7, y: line1];
  pcPlace: Window.Place = [x: TopCtxCol+0*7, y: line2];
  nxpcPlace: Window.Place = [x: TopCtxCol+4*7, y: line2];
  pcciPlace: Window.Place = [x: TopCtxCol+0*7, y: line3];

  stkPlace: Window.Place = [x: StkCol+0*7, y: line0];
  brkPlace: Window.Place = [x: StkCol+0*7, y: line1];
  fooPlace: Window.Place = [x: StkCol+1*7, y: line2];

  ctxPlace: Window.Place = [x: CtxCol+1*7, y: line0];
  userPlace: Window.Place = [x: CtxCol+1*7, y: line1];
  nPlace: Window.Place = [x: CtxCol+0*7, y: line2];

  ctiPlace: Window.Place = [x: CtCol+0*7, y: line0];
  btiPlace: Window.Place = [x: CtCol+0*7, y: line1];
  seiPlace: Window.Place = [x: CtCol+0*7, y: line2];

  mdiPlace: Window.Place = [x: MTCol+0*7, y: line0];
  htiPlace: Window.Place = [x: MTCol+0*7, y: line1];
  nextsePlace: Window.Place = [x: MTCol+0*7, y: line2];


  ltiPlace: Window.Place = [x: LitCol+1*7, y: line0];
  repPlace: Window.Place = [x: LitCol+1*7, y: line1];
  treePlace: Window.Place = [x: LitCol+0*7, y: line2];

  sourcePlace: Window.Place = [x: SourceCol+0*7, y: line0];
  filePlace: Window.Place = [x: SourceCol+0*7, y: line1];
  depthPlace: Window.Place = [x: SourceCol+0*7, y: line2];
  linksPlace: Window.Place = [x: SourceCol+6*7, y: line2];

  listPlace: Window.Place = [x: ListCol+0*7, y: line2];
  nxlistPlace: Window.Place = [x: ListCol+6*7, y: line2];
  nsizePlace: Window.Place = [x: ListCol-4*7, y: line3];
  nlinkPlace: Window.Place = [x: ListCol+4*7, y: line3];

  MakeParameterArray: FormSW.ClientItemsProcType =
    BEGIN OPEN FormSW; 
    sourceEnumRec: ARRAY STSource OF Enumerated ← [
      [string: "allocator"L, value: STSource[allocator]],
      [string: "file"L, value: STSource[file]],
      [string: "copier"L, value: STSource[copier]],
      [string: "alFrame"L, value: STSource[alFrame]],
      [string: "spFrame"L, value: STSource[spFrame]],
      [string: "none"L, value: STSource[none]]];
    nParams: CARDINAL =
      LOOPHOLE[LAST[XXDebugCommandDefs.ParamIndex], CARDINAL] + 1;
    params: XXDebugCommandDefs.Params ← 
      LOOPHOLE[AllocateItemDescriptor[nParams]];

    params[topctx] ← CommandItem[
      tag: "TopCtx"L, place: topctxPlace, proc: ParamNotify];
    params[tos] ← CommandItem[
      tag: "TOS"L, place: tosPlace, proc: ParamNotify];
    params[pc] ← CommandItem[
      tag: "PC"L, place: pcPlace, proc: ParamNotify];
    params[nxpc] ← CommandItem[
      tag: "nx"L, place: nxpcPlace, proc: ParamNotify];
    params[pcci] ← CommandItem[
      tag: "pcci"L, place: pcciPlace, proc: ParamNotify];

    params[stk] ← CommandItem[
      tag: "@Stk"L, place: stkPlace, proc: ParamNotify];
    params[brk] ← CommandItem[
      tag: "@Brk"L, place: brkPlace, proc: ParamNotify];
    params[foo] ← CommandItem[
      tag: "Foo"L, place: fooPlace, proc: ParamNotify];

    params[ctx] ← CommandItem[
      tag: "@Ctx"L, place: ctxPlace, proc: ParamNotify];
    params[user] ← CommandItem[
      tag: "user"L, place: userPlace, proc: ParamNotify];
    params[n] ← StringItem[
      tag: "n"L, place: nPlace, string: @XXDebugDefs.nString, inHeap: TRUE];

    params[cti] ← CommandItem[
      tag: "ct"L, place: ctiPlace, proc: ParamNotify];
    params[bti] ← CommandItem[
      tag: "bt"L, place: btiPlace, proc: ParamNotify];
    params[sei] ← CommandItem[
      tag: "se"L, place: seiPlace, proc: ParamNotify];

    params[mdi] ← CommandItem[
      tag: "mt"L, place: mdiPlace, proc: ParamNotify];
    params[hti] ← CommandItem[
      tag: "ht"L, place: htiPlace, proc: ParamNotify];
    params[nextse] ← CommandItem[
      tag: "nx"L, place: nextsePlace, proc: ParamNotify];

    params[lti] ← CommandItem[
      tag: "lit"L, place: ltiPlace, proc: ParamNotify];
    params[rep] ← CommandItem[
      tag: "rep"L, place: repPlace, proc: ParamNotify];
    params[tree] ← CommandItem[
      tag: "Tree"L, place: treePlace, proc: ParamNotify];

    params[source] ← EnumeratedItem[
      tag: "source"L, place: sourcePlace, feedback: one,
      choices: LOOPHOLE[DESCRIPTOR[sourceEnumRec]],
      proc: SourceChanged, value: @stSource];
    params[file] ← StringItem[
      tag: "file/frame"L, place: filePlace, string: @stFile, 
      filterProc: NameChanged, inHeap: TRUE];
    params[depth] ← StringItem[
      tag: "d"L, place: depthPlace, 
      string: @STDebugDefs.depthString, inHeap: TRUE];
    params[links] ← BooleanItem[
      tag: "lnks"L, place: linksPlace, switch: @STDebugDefs.showLinks];

    params[list] ← CommandItem[
      tag: "list"L, place: listPlace, proc: ParamNotify];
    params[nxlist] ← CommandItem[
      tag: "nx"L, place: nxlistPlace, proc: ParamNotify];
    params[nsize] ← StringItem[
      tag: "size"L, place: nsizePlace, 
      string: @XXDebugDefs.nodeSizeString, inHeap: TRUE];
    params[nlink] ← StringItem[
      tag: "link"L, place: nlinkPlace, 
      string: @XXDebugDefs.nodeLinkString, inHeap: TRUE];

    RETURN[items: LOOPHOLE[params], freeDesc: TRUE];
    END;

  NameChanged: FormSW.FilterProcType =
    BEGIN
    IF stSource = file THEN
      BEGIN
      stSource ← none;
      FormSW.DisplayItem[
	sw, LOOPHOLE[XXDebugCommandDefs.ParamIndex[source]]];
      END;
    FormSW.StringEditProc[sw, item, insert, string];
    END;


 -- Mainline code
  START XXDebugCommands;
  START STDebugDefs.STDebugTrees;
  START STDebugDefs.STDebugSymbols;
  START XXDebugGlobals;
  START XXDebugContext;
  START XXDebugUser;
  START XXDebugPC;
  START STDebugDefs.STDebugMisc;

  Init[];
  
END...