-- file CompilerUtil.Mesa
-- last modified by Satterthwaite, January 10, 1983 8:49 am

DIRECTORY
  Alloc: TYPE USING [Handle],
  CompilerOps: TYPE USING [StreamId],
  FileStream: TYPE USING [FileByteIndex],
  Stream: TYPE USING [Handle],
  Strings: TYPE USING [String],
  Tree: TYPE USING [Link, Map, Scan];

CompilerUtil: DEFINITIONS = {

 -- stream management

  StreamId: TYPE = CompilerOps.StreamId;

  AcquireStream: PROC [StreamId] RETURNS [Stream.Handle];
  ReleaseStream: PROC [StreamId];

 -- scratch zone management
 
  AcquireZone: PROC RETURNS [UNCOUNTED ZONE];
  ReleaseZone: PROC [UNCOUNTED ZONE] = INLINE {};
  
 -- binary table management

  TableId: TYPE = MACHINE DEPENDENT {error, debug, (255)};

  AcquireTable: PROC [TableId] RETURNS [LONG POINTER];
  ReleaseTable: PROC [TableId];

 -- compiler passes

  InstallParseTables: PROC [LONG POINTER];
  PrefillSymbols: PROC;

  P1Unit: PROC RETURNS [BOOL];
  P2Unit: Tree.Map;
  P3Unit: Tree.Map;
  P3Postlude: PROC [expand: BOOL];
  P4Unit: Tree.Scan;
  P5module: PROC;

 -- object output

  Address: TYPE = LONG POINTER;
  
  StartObjectFile: PROC [Stream.Handle, UNCOUNTED ZONE];
  EndObjectFile: PROC [update: BOOL];
  TableOut: PROC [Alloc.Handle];
  RTTableOut: PROC [Alloc.Handle];

  NextFilePage: PROC RETURNS [CARDINAL];
  StartBCD: PROC;
  ReadBCDOffset: PROC RETURNS [CARDINAL];
  ReadBCDIndex: PROC RETURNS [FileStream.FileByteIndex];
  AppendBCDWord: PROC [word: UNSPECIFIED];
  AppendBCDWords: PROC [addr: Address, n: CARDINAL];
  AppendBCDString: PROC [s: Strings.String];
  FillBCDPage: PROC;
  UpdateBCDWords: PROC [offset: CARDINAL, addr: Address, n: CARDINAL];
  EndBCD: PROC;

 -- debugging

  PrintTree: PROC [table: Alloc.Handle, root: Tree.Link];
  PrintBodies: PROC [table: Alloc.Handle];
  PrintSymbols: PROC [table: Alloc.Handle, definitions: BOOL];

  }.