-- file SymbolOps.mesa
-- last modified by Satterthwaite,  9-Feb-82 10:09:27

DIRECTORY
  Alloc: TYPE USING [Handle],
  Strings: TYPE USING [SubString],
  Symbols: TYPE,
  TimeStamp: TYPE USING [Stamp],
  Tree: TYPE USING [Link];

SymbolOps: DEFINITIONS = {
  OPEN Symbols;

-- implemented by SymbolPack

 -- hash manipulation
  FindString: PROC [Strings.SubString] RETURNS [HTIndex];
  HashValue: PROC [Strings.SubString] RETURNS [HVIndex];
  SubStringForHash: PROC [Strings.SubString, HTIndex];

 -- context management
  CtxEntries: PROC [CTXIndex] RETURNS [CARDINAL];
  FirstCtxSe: PROC [CTXIndex] RETURNS [ISEIndex];
  NextSe: PROC [ISEIndex] RETURNS [ISEIndex];
  SearchContext: PROC [hti: HTIndex, ctx: CTXIndex] RETURNS [ISEIndex];
  SeiForValue: PROC [value: CARDINAL, ctx: CTXIndex] RETURNS [ISEIndex];

 -- module management
  FindMdi: PROC [TimeStamp.Stamp] RETURNS [MDIndex];

 -- type manipulation
  ArgCtx: PROC [CSEIndex] RETURNS [CTXIndex];
  ArgRecord: PROC [CSEIndex] RETURNS [RecordSEIndex];
  ClusterSe: PROC [SEIndex] RETURNS [SEIndex];
  NormalType: PROC [CSEIndex] RETURNS [CSEIndex];
  RecordLink: PROC [RecordSEIndex] RETURNS [RecordSEIndex];
  RecordRoot: PROC [RecordSEIndex] RETURNS [RecordSEIndex];
  ReferentType: PROC [CSEIndex] RETURNS [CSEIndex];
  TransferTypes: PROC [SEIndex] RETURNS [typeIn, typeOut: RecordSEIndex];
  TypeForm: PROC [SEIndex] RETURNS [TypeClass];
  TypeLink: PROC [SEIndex] RETURNS [SEIndex];
  TypeRoot: PROC [SEIndex] RETURNS [SEIndex];
  UnderType: PROC [SEIndex] RETURNS [CSEIndex];
  XferMode: PROC [SEIndex] RETURNS [TransferMode];

 -- information returning procedures
  BitsForRange: PROC [CARDINAL] RETURNS [CARDINAL];
  BitsForType: PROC [SEIndex] RETURNS [CARDINAL];
  BitsPerElement: PROC [type: SEIndex, packed: BOOLEAN] RETURNS [CARDINAL];
  Cardinality: PROC [SEIndex] RETURNS [CARDINAL];
  FindExtension: PROC [sei: ISEIndex] RETURNS [type: ExtensionType, tree: Tree.Link];
  FnField: PROC [ISEIndex] RETURNS [offset: BitAddress, size: CARDINAL];
  HashForSe: PROC [ISEIndex] RETURNS [HTIndex];
  LinkMode: PROC [sei: ISEIndex] RETURNS [Linkage];
  PackedSize: ARRAY [0..ByteLength] OF CARDINAL = [0, 1, 2, 4, 4, 8, 8, 8, 8];
  RCType: PROC [CSEIndex] RETURNS [RefClass];
  VariantField: PROC [CSEIndex] RETURNS [ISEIndex];
  WordsForType: PROC [SEIndex] RETURNS [CARDINAL];

 -- body table management
  EnumerateBodies: PROC [root: BTIndex, proc: PROC [BTIndex] RETURNS [stop: BOOLEAN]]
    RETURNS [BTIndex];
  ParentBti: PROC [BTIndex] RETURNS [BTIndex];
  SiblingBti: PROC [BTIndex] RETURNS [BTIndex];
  SonBti: PROC [BTIndex] RETURNS [BTIndex];


-- implemented by SymbolPackExt (extensions for building tables)

  Initialize: PROC [Alloc.Handle, UNCOUNTED ZONE];
  Reset, Finalize: PROC; 

 -- hash manipulation
  EnterString: PROC [Strings.SubString] RETURNS [HTIndex];
  HashBlock: PROC RETURNS [LONG POINTER TO HashVector];

 -- context management
  NextLevel: PROC [ContextLevel] RETURNS [ContextLevel];
  BlockLevel: PROC [ContextLevel] RETURNS [ContextLevel];
  NewCtx: PROC [ContextLevel] RETURNS [CTXIndex];
  SetMainCtx: PROC [CTXIndex];
  ResetCtxList: PROC [CTXIndex];
  FirstVisibleSe: PROC [CTXIndex] RETURNS [ISEIndex];
  NextVisibleSe: PROC [ISEIndex] RETURNS [ISEIndex];
  VisibleCtxEntries: PROC [CTXIndex] RETURNS [CARDINAL];
  ContextVariant: PROC [CTXIndex] RETURNS [ISEIndex];

  StaticNestError: SIGNAL;

  MakeCtxSe: PROC [hti: HTIndex, ctx: CTXIndex] RETURNS [ISEIndex];
  MakeNonCtxSe: PROC [CARDINAL] RETURNS [CSEIndex];

  MakeSeChain: PROC [CTXIndex, CARDINAL, BOOLEAN] RETURNS [ISEIndex];
  FillCtxSe: PROC [ISEIndex, HTIndex, BOOLEAN];
  NameClash: SIGNAL [hti: HTIndex];
  EnterExtension: PROC [sei: ISEIndex, type: ExtensionType, tree: Tree.Link];
  SetSeLink: PROC [sei, next: ISEIndex];

 -- body table utilities
  LinkBti: PROC [bti, parent: BTIndex];
  DelinkBti: PROC [BTIndex];

 -- copying within current table
  CopyArgSe: PROC [copy, master: ISEIndex];
  CopyBasicType: PROC [CSEIndex] RETURNS [CSEIndex];
  CopyXferType: PROC [CSEIndex] RETURNS [CSEIndex];

 -- attribute extraction
  ConstantId: PROC [ISEIndex] RETURNS [BOOLEAN];

  }.