-- file CompilerUtil.Mesa
-- last modified by Satterthwaite, March 13, 1979  11:02 AM

DIRECTORY
  CompilerOps: FROM "compilerops" USING [TableId],
  SegmentDefs: FROM "segmentdefs" USING [FileHandle, FileSegmentHandle],
  StreamDefs: FROM "streamdefs" USING [StreamHandle, StreamIndex],
  Tree: FROM "tree" USING [Link, Map, Scan];

CompilerUtil: DEFINITIONS =
  BEGIN

 -- binary table management

  TableId: TYPE = CompilerOps.TableId;
    parse: TableId = 0;
    error: TableId = 1;
    debug: TableId = 2;

  TableSegment: PROCEDURE [CompilerOps.TableId] RETURNS [SegmentDefs.FileSegmentHandle];

 -- compiler passes

  PassIndex: TYPE = {utilities, pass1, pass2, pass3, pass4, pass5, debug};

  P1Unit: PROCEDURE RETURNS [BOOLEAN];
  P2Unit: Tree.Map;
  P3Unit: Tree.Map;
  P4Unit: Tree.Scan;
  P5module: PROCEDURE;

 -- object output

  SetObjectStamp: PROCEDURE;
  StartObjectFile: PROCEDURE [SegmentDefs.FileHandle] RETURNS [StreamDefs.StreamHandle];
  EndObjectFile: PROCEDURE [success: BOOLEAN];
  TableOut: PROCEDURE [sourceFile: STRING];

  nextFilePage: PROCEDURE RETURNS [CARDINAL];
  StartBCD: PROCEDURE;
  ReadBCDOffset: PROCEDURE RETURNS [CARDINAL];
  ReadBCDIndex: PROCEDURE RETURNS [StreamDefs.StreamIndex];
  AppendBCDWord: PROCEDURE [word: UNSPECIFIED];
  AppendBCDWords: PROCEDURE [addr: POINTER, n: CARDINAL];
  AppendBCDString: PROCEDURE [s: STRING];
  UpdateBCDWords: PROCEDURE [offset: CARDINAL, addr: POINTER, n: CARDINAL];
  EndBCD: PROCEDURE;

 -- debugging

  PrintTree: PROCEDURE [Tree.Link];
  PrintBodies: PROCEDURE;
  PrintSymbols: PROCEDURE;

 -- swapping control

  MakeSwappable: PUBLIC PROCEDURE [module: PROGRAM, pass: PassIndex];

  Pass1, Pass2, Pass3, Pass4, Code: PROGRAM;

  END.