-- file IncludeCheckerTable.Mesa
-- last modified by Satterthwaite, July 30, 1980  10:32 AM
-- last modified by Paul Rovner, June 16, 1982 12:54 pm

DIRECTORY
  Bases: FROM "LongBases" USING [
    Base, BaseDescriptor, Finger, Index, IPointer, Limit, OrderedIndex,
    SizeDescriptor];

IncludeCheckerTable: DEFINITIONS =
  BEGIN

  Selector: TYPE = CARDINAL;

  Base: TYPE = Bases.Base;
  Finger: TYPE = Bases.Finger;
  Limit: CARDINAL = Bases.Limit;
  Index: TYPE = Bases.Index;
  OrderedIndex: TYPE = Bases.OrderedIndex;

  IPointer: TYPE = Bases.IPointer;

  BaseDescriptor: TYPE = Bases.BaseDescriptor;
  SizeDescriptor: TYPE = Bases.SizeDescriptor;

  -- allocation from the tables as stacks

  Allocate: PROC [table: IncludeCheckerTable.Selector, size: CARDINAL]
    RETURNS [IncludeCheckerTable.OrderedIndex];
  Bounds: PROC [table: IncludeCheckerTable.Selector] RETURNS [base: IncludeCheckerTable.Base, size: CARDINAL];
  Top: PROC [table: IncludeCheckerTable.Selector] RETURNS [IncludeCheckerTable.OrderedIndex] = INLINE {
    RETURN[FIRST[IncludeCheckerTable.OrderedIndex] + Bounds[table].size]};

  Trim: PROC [table: IncludeCheckerTable.Selector, size: CARDINAL];

  -- allocation from free list (first table only)

  chunkType: IncludeCheckerTable.Selector = FIRST[IncludeCheckerTable.Selector];

  GetChunk: PROC [size: CARDINAL] RETURNS [IncludeCheckerTable.Index];
  FreeChunk: PROC [index: IncludeCheckerTable.Index, size: CARDINAL];

  -- inquiries

  WordsUsed: PROC RETURNS [CARDINAL];
  WordsFree: PROC RETURNS [CARDINAL];

  -- notification of repacking

  Notifier: TYPE = PROC [base: IncludeCheckerTable.BaseDescriptor];

  AddNotify: PROC [proc: IncludeCheckerTable.Notifier];
  DropNotify: PROC [proc: IncludeCheckerTable.Notifier];

  -- initialization and termination

  Region: TYPE = RECORD [origin: IncludeCheckerTable.Base, size: CARDINAL];

  Create: PROC [region: IncludeCheckerTable.Region, weights: DESCRIPTOR FOR ARRAY OF CARDINAL];
  Destroy: PROC;

  Overflow: SIGNAL RETURNS [Region];
  Failure: ERROR [table: IncludeCheckerTable.Selector];

  END.