-- CodePackProcs.Mesa  Last edited by October 20, 1980  11:34 AM

DIRECTORY
  BcdDefs USING [MTIndex],
  PackageSymbols USING [OPIndex],
  Strings USING [SubString],
  Table USING [Base, Index, Limit];

CodePackProcs: DEFINITIONS =
  BEGIN

  TreeIndex: TYPE = Table.Index;  -- = Tree.Index (avoids circular definition)
 

 -- Describes the procedures from a module that are included in a code pack
  ModuleIndex: TYPE = Table.Base RELATIVE POINTER [0..Table.Limit) TO ModuleRecord;
    NullModuleIndex: ModuleIndex = LAST[ModuleIndex];

  ModuleRecord: TYPE = MACHINE DEPENDENT RECORD [
    mti: BcdDefs.MTIndex,
    unused: [0..4),
    cp: TreeIndex,         -- code pack's parse tree node
    numWordPairsInProcArray: [1..4],  -- if someProcs variant
    next: ModuleIndex,     -- next module record in code pack's chain
    fill: [0..4),
    link: ModuleIndex,     -- links module records with same id hash values
    procDescription: SELECT kind: * FROM
      allProcs  => [
	includeMAIN: BOOLEAN],
      someProcs => [       -- up to PackageSymbols.MaxEntries procedures
        unused: [0..1), 
        procIncluded: PACKED ARRAY [0..0) OF BOOLEAN], 
      ENDCASE];


 -- Determination of procedures in each code pack
  Determine, Destroy: PROC;


 -- Inquiry  
  EnumerateSegments: PROC [
    userProc: PROC [segNode: TreeIndex] RETURNS [stop: BOOLEAN]];

  SubStringForSegmentNode: PROC [
    ss: Strings.SubString, segNode: TreeIndex];

  EnumerateCodePacks: PROC [
    segNode: TreeIndex, 
    userProc: PROC [cpNode: TreeIndex] RETURNS [stop: BOOLEAN]];

  SubStringForCodePackNode: PROC [
    ss: Strings.SubString, cpNode: TreeIndex];

  IsDiscardCodePack: PROC [cpNode: TreeIndex] RETURNS [yes: BOOLEAN];

  EnumerateModules: PROC [  -- each module's symbol table is loaded
    cpNode: TreeIndex,      -- (via ModuleSymbols.Load) before userProc 
    userProc: PROC [        -- is called (and unloaded afterwards)
      mti: BcdDefs.MTIndex, module: ModuleIndex] RETURNS [stop: BOOLEAN]];

  -- return TRUE if any procedures are specified by a ModuleRecord
  AnyProcs: PROC [module: ModuleIndex] RETURNS [reply: BOOLEAN];

  EnumerateProcs: PROC [
    module: ModuleIndex, 
    userProc: PROC [opi: PackageSymbols.OPIndex] RETURNS [stop: BOOLEAN]];

  SubStringForOPIndex: PROC [
    ss: Strings.SubString, opi: PackageSymbols.OPIndex];

  END.