-- RTSymbols.mesa
-- An interface to operations that acquire and release SymbolTableBases and SymbolTableHandles.
-- Bifurcation for symbol table bootstrapping occurs below this (and the RTSymbolOps) level of
    -- abstraction.
-- Last Modified By Paul Rovner On December 21, 1982 2:12 pm
DIRECTORY
        BcdDefs USING[SGIndex, VersionStamp, NullVersion],
        BcdOps USING[BcdBase],
        PrincOps USING[GlobalFrameHandle],
        Rope USING[ROPE],
        RTBasic USING[Type],
        RTSymbolDefs USING[SymbolTableHandle, SymbolTableBase, SymbolModuleIndex,
                                 SymbolIndex];
RTSymbols: DEFINITIONS
= BEGIN OPEN Rope, RTBasic, RTSymbolDefs;
  -- STB's
AcquireSTB: PROC[sth: SymbolTableHandle, mesaSymbolsOK: BOOLEAN ← FALSE] 
      RETURNS[SymbolTableBase];
  
ReleaseSTB: PROC[stb: SymbolTableBase];
  -- BEWARE. The client is responsible for matching each AcquireSTB with exactly
  -- one ReleaseSTB. In particular, one should be very careful to catch UNWIND
  -- in appropriate places and ReleaseSTB. All the awfulness of dangling
  -- reference problems obtain at this level in the system.
AcquireSTBFromGFH: PROC[gfh: PrincOps.GlobalFrameHandle,
                                    mesaSymbolsOK: BOOLEAN ← FALSE]
      RETURNS[SymbolTableBase];
  
AcquireSTBFromMDI: PROC[stb: SymbolTableBase, mdi: SymbolModuleIndex,
                                    mesaSymbolsOK: BOOLEAN ← FALSE]
      RETURNS[SymbolTableBase];
AcquireSTBFromSGI: PROC[bcd: BcdOps.BcdBase,
                                   sgi: BcdDefs.SGIndex,
                                   mesaSymbolsOK: BOOLEAN ← FALSE] 
      RETURNS[SymbolTableBase];
AcquireSTBForDefs: PROC[fileName: ROPE--assumed to end with .bcd--]
     RETURNS[SymbolTableBase];
  -- AcquireSTBForDefs finds a file with the specified name, assumes it to be a
  -- DEFS BCD, and acquires the symbol table therein.
  
Outer: PROC[stb: SymbolTableBase,
                mdi: SymbolModuleIndex,
                inner: PROC[base: SymbolTableBase],
                mesaSymbolsOK: BOOLEAN ← FALSE];
  -- Outer uses AcquireSTBFromMDI to find the stb referenced by (stb, mdi).
  -- It will then pass this stb to inner. Outer is useful when the caller
  -- is unable or unwilling to make sure that the stb gets released properly.
  -- mesaSymbolsOK = TRUE is an feature used only by the RPC stub generator.
  -- It enables acquisition of pre-Cedar symbol tables. 
  
  -- STH's
NewSymbolHandle: PROC[fileName: ROPE,
                                 base: CARDINAL,
                                 pages: CARDINAL,
                                 version: BcdDefs.VersionStamp ← BcdDefs.NullVersion]
      RETURNS[SymbolTableHandle];
  -- If version # AnyVersion, NewSymbolHandle may
  -- return a SymbolTableHandle that identifies a different
  -- file and span.
  
STPages: PROC[sth: SymbolTableHandle] RETURNS[CARDINAL];
  -- STPages returns the number of pages in the specified symbol table
  
  -- Types
GetTypeSymbols: PROC[type: Type] RETURNS[stb: SymbolTableBase, sei: SymbolIndex];
GetOriginalTypeSymbols: PROC[type: Type] RETURNS[stb: SymbolTableBase, sei: SymbolIndex];
END.