-- Pc.mesa  last edit, Bruce  October 9, 1980  2:23 PM

DIRECTORY
  DebugFormat USING [EXOI],
  MachineDefs USING [FHandle, GFHandle, NullGF],
  PrincOps USING [BytePC, ControlLink, EPRange, SVPointer],
  Symbols USING [BTIndex, CBTIndex, ContextLevel, CTXIndex, ISEIndex, MDIndex];

Pc: DEFINITIONS =
  BEGIN OPEN MachineDefs, Symbols;

  BytePC: TYPE = PrincOps.BytePC;
  NullPC: BytePC = [0];
  EVRange: TYPE = [0..4*PrincOps.EPRange);

  ResetCache: PROC;

  Entry: PROCEDURE [f: FHandle ← NIL, pc: BytePC ← NullPC] RETURNS [BOOLEAN];
  Exit: PROCEDURE [f: FHandle ← NIL, pc: BytePC ← NullPC] RETURNS [BOOLEAN];
  EvalStackEmpty: PROCEDURE [sp: PrincOps.SVPointer ← NIL] RETURNS [BOOLEAN];

  GetPc: PROC [gf: GFHandle, i: EVRange] RETURNS [pc: BytePC];
  Son: PROC [CBTIndex] RETURNS [BOOLEAN];

  EntryPC: PROCEDURE [ep: EVRange, gf: GFHandle, noSyms: BOOLEAN ← FALSE]
    RETURNS [pc: BytePC];
  ExitPC: PROCEDURE [CBTIndex] RETURNS [BytePC];

  EVSize: PROC [Symbols.MDIndex] RETURNS [EVRange];
  Ep: PROC [pc: BytePC, gf: GFHandle] RETURNS [ep: EVRange, start: BytePC];
  EpToCBti: PROC [ep: EVRange, gf: GFHandle, start: BytePC ← NullPC]
    RETURNS [cbti: CBTIndex];
  LinkToCbti: PROC [PrincOps.ControlLink] RETURNS [CBTIndex];
  LinkToIsei: PROC [PrincOps.ControlLink] RETURNS [Symbols.ISEIndex];

  Bti: PROC [pc: BytePC ← NullPC, gf: GFHandle ← NullGF]
    RETURNS [bti: BTIndex];			-- in user's symbol table
  CBti: PROC [pc: BytePC ← NullPC, gf: GFHandle ← NullGF]
    RETURNS [cbti: CBTIndex];

  CacheCBti: PROC [mdi: Symbols.MDIndex, gf: GFHandle, cbti: CBTIndex]
    RETURNS [CBTIndex];

  CtxLink: TYPE = POINTER TO CtxItem;
  CtxItem: TYPE = RECORD [
    link: CtxLink,
    indirect: BOOLEAN,
    onStack: BOOLEAN,
    indent: [0..37777B],
    mapped: BOOLEAN,
    null: BOOLEAN,
    body: SELECT OVERLAID * FROM
      context => [ictx: Symbols.CTXIndex],
      empty => [level: Symbols.ContextLevel],
      ENDCASE];

  Reason: TYPE = {print,search};

  FreeContextList: PROC [CtxLink];
  ContextList: PROC [
    pc: BytePC, gf: GFHandle, reason: Reason, exoi: DebugFormat.EXOI ← in]
    RETURNS [CtxLink];

  NotInAnyProcedure: SIGNAL;

  END.