-- file SymbolOps.mesa
-- last modified by Satterthwaite, February 17, 1983 4:05 pm
-- last modified by Paul Rovner, July 6, 1983 1:36 pm

DIRECTORY
  Alloc: TYPE USING [Handle],
  BcdDefs: TYPE USING [VersionStamp],
  ConvertUnsafe: TYPE USING [SubString],
  Symbols: TYPE,
  Tree: TYPE USING [Link, Map];

SymbolOps: DEFINITIONS = {
  OPEN Symbols;

-- implemented by SymbolPack

 -- hash manipulation
  FindString: PROC [ConvertUnsafe.SubString] RETURNS [Name];
  HashValue: PROC [ConvertUnsafe.SubString] RETURNS [HVIndex];
  SubStringForName: PROC [Name] RETURNS[ConvertUnsafe.SubString];

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

 -- module management
  FindMdi: PROC [BcdDefs.VersionStamp] RETURNS [MDIndex];

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

 -- information returning procedures
  BitsForRange: PROC [CARDINAL] RETURNS [CARDINAL];
  BitsForType: PROC [Type] RETURNS [BitCount];
  BitsPerElement: PROC [type: Type, packed: BOOL] RETURNS [BitCount];
  Cardinality: PROC [Type] RETURNS [LONG CARDINAL];
  FindExtension: PROC [sei: ISEIndex] RETURNS [type: ExtensionType, tree: Tree.Link];
  FnField: PROC [ISEIndex] RETURNS [offset: BitAddress, size: FieldBitCount];
  LinkMode: PROC [sei: ISEIndex] RETURNS [Linkage];
  NameForSe: PROC [ISEIndex] RETURNS [Name];
  PackedSize: ARRAY PackedBitCount OF CARDINAL = [1, 2, 4, 4, 8, 8, 8, 8];
  RecField: PROC [ISEIndex] RETURNS [offset: BitAddress, size: FieldBitCount];
  RCType: PROC [CSEIndex] RETURNS [RefClass];
  VariantField: PROC [CSEIndex] RETURNS [ISEIndex];
  WordsForType: PROC [Type] RETURNS [WordCount];

 -- body table management
  EnumerateBodies: PROC [root: BTIndex, proc: PROC [BTIndex] RETURNS [stop: BOOL]]
    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 [ConvertUnsafe.SubString] RETURNS [Name];
  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 [name: Name, ctx: CTXIndex] RETURNS [ISEIndex];
  MakeNonCtxSe: PROC [CARDINAL] RETURNS [CSEIndex];

  MakeSeChain: PROC [CTXIndex, CARDINAL, BOOL] RETURNS [ISEIndex];
  FillCtxSe: PROC [ISEIndex, Name, BOOL];
  NameClash: SIGNAL [name: Name];
  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, Tree.Map] RETURNS [CSEIndex];

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

  }.