-- file SymbolOps.mesa
-- last modified by Satterthwaite, February 24, 1983 1:55 pm

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

SymbolOps: DEFINITIONS = {
  OPEN Symbols;

-- implemented by SymbolPack

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

 -- 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 [TimeStamp.Stamp] RETURNS [MDIndex];

 -- type manipulation
  ArgCtx: PROC [CSEIndex] RETURNS [CTXIndex];
  ArgRecord: PROC [CSEIndex] RETURNS [RecordSEIndex];
  ClusterSe: PROC [Type] RETURNS [Type];
  NormalType: PROC [Type] RETURNS [CSEIndex];
  RecordLink: PROC [RecordSEIndex] RETURNS [RecordSEIndex];
  RecordRoot: PROC [RecordSEIndex] RETURNS [RecordSEIndex];
  ReferentType: PROC [Type] RETURNS [Type];
  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 [Type] 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 [Strings.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];

  }.