-- file SymbolSegment.Mesa
-- last modified by Satterthwaite,  5-Oct-81  9:30:55

DIRECTORY
  Literals: TYPE USING [ltType, stType],
  Symbols: TYPE USING [
    ISEIndex, CTXIndex, ExtensionType,
    seType, htType, ssType, ctxType, mdType, bodyType],
  Table: TYPE USING [Base, Selector, Limit],
  TimeStamp: TYPE USING [Stamp],
  Tree: TYPE USING [Link, treeType];

SymbolSegment: DEFINITIONS = {

  VersionID: CARDINAL = 08140;

  Base: TYPE = Table.Base;
  Limit: CARDINAL = Table.Limit;
  
 -- symbol table extensions

  ExtRecord: TYPE = RECORD [
    type: Symbols.ExtensionType[value..default],
    sei: Symbols.ISEIndex,	-- the key
    tree: Tree.Link];

  ExtIndex: TYPE = Base RELATIVE POINTER [0..Limit) TO ExtRecord;
  ExtNull: ExtIndex = LAST[ExtIndex];


 -- allocation codes

  treeType: Table.Selector = Tree.treeType;
  seType: Table.Selector = Symbols.seType;
  htType: Table.Selector = Symbols.htType;
  ssType: Table.Selector = Symbols.ssType;
  ctxType: Table.Selector = Symbols.ctxType;
  mdType: Table.Selector = Symbols.mdType;
  bodyType: Table.Selector = Symbols.bodyType;
  ltType: Table.Selector = Literals.ltType;
  stType: Table.Selector = Literals.stType;
  extType: Table.Selector = 9;
  atType: Table.Selector = 10;		-- atom and typeId table
  constType: Table.Selector = 11;
  
  Tables: TYPE = Table.Selector [treeType .. constType];

 -- symbol segment headers

  WordOffset: TYPE = CARDINAL;
  BlockDescriptor: TYPE = RECORD [offset: WordOffset, size: CARDINAL];

  STHeader: TYPE = RECORD [
    versionIdent: CARDINAL,
    version: TimeStamp.Stamp,
    creator: TimeStamp.Stamp,
    sourceVersion: TimeStamp.Stamp,
    definitionsFile: BOOLEAN,
    extended: BOOLEAN,
    directoryCtx, importCtx, outerCtx: Symbols.CTXIndex,
    hvBlock: BlockDescriptor,
    htBlock: BlockDescriptor,
    ssBlock: BlockDescriptor,
    outerPackBlock: BlockDescriptor,
    innerPackBlock: BlockDescriptor,
    constBlock: BlockDescriptor,
    seBlock: BlockDescriptor,
    ctxBlock: BlockDescriptor,
    mdBlock: BlockDescriptor,
    bodyBlock: BlockDescriptor,
    extBlock: BlockDescriptor,
    treeBlock: BlockDescriptor,
    litBlock: BlockDescriptor,
    sLitBlock: BlockDescriptor,
    epMapBlock: BlockDescriptor,
    spareBlock: BlockDescriptor,
    fgRelPgBase: CARDINAL,
    fgPgCount: [0..256]];

 -- fine grain table header

  FGHeader: TYPE = RECORD [
    offset: WordOffset,
    length: CARDINAL,
    sourceFile: StringBody -- text follows --];

 -- fine grain table declarations

  SourceStep: CARDINAL = 377B;
  ObjectStep: CARDINAL = 177B;
  Stride: CARDINAL = 37777B;

  FGTEntry: TYPE = RECORD [SELECT tag: * FROM
    normal => [deltaObject: [0..ObjectStep], deltaSource: [0..SourceStep]],
    step => [which: {source, object}, delta: [0..Stride]]
    ENDCASE];

  }.