-- RTSymbolOps.mesa
-- An interface to operations that actually deal with the actual bits in an actual symbol table.
-- Bifurcation for symbol table bootstrapping occurs below this (and the RTSymbols and
-- RTSymbolDefs) level of abstraction.
-- Last Modified By Paul Rovner On December 21, 1982 4:25 pm

DIRECTORY
RCMap USING[Index],
Rope USING[ROPE],
RTBasic USING[Type],
RTSymbolDefs USING[SymbolTableBase, SymbolRecordIndex, SymbolIdIndex,
SymbolContextIndex, SymbolIndex, SymbolNameIndex];

RTSymbolOps: DEFINITIONS
= BEGIN OPEN Rope, RTBasic, RTSymbolDefs;


-- For walking symbol table entries
EnumerateRecordIseis: PROC
[ stb: SymbolTableBase,
rsei: SymbolRecordIndex,
p: PROC[stb: SymbolTableBase, isei: SymbolIdIndex]
RETURNS[stop: BOOLEAN],
level: CARDINAL ← 0,
mesaSymbolsOK: BOOLEANFALSE]
RETURNS [stopped: BOOLEAN];
-- EnumerateRecordIseis invokes p once for each record field of (stb, rsei).
-- It deals with incomplete contexts (opening other symbol tables if necesary)
-- and with the linked nature of the symbol table's representation of bound
-- variant records (it enumerates common parts in addition to the variant part).
-- EnumerateRecordIseis uses EnumerateCtxIseis
-- If rsei identifies a variant record
-- then if level = 0
-- then the union or sequence isei will be included in the enumeration
-- else the union or sequence isei will not be included in the enumeration

EnumerateCtxIseis: PROC
[ stb: SymbolTableBase,
ctx: SymbolContextIndex,
proc: PROC[stb: SymbolTableBase, isei: SymbolIdIndex]
RETURNS[stop: BOOLEAN],
reallyComplete: BOOLEANFALSE,
mesaSymbolsOK: BOOLEANFALSE]
RETURNS[stopped: BOOLEAN];
-- EnumerateCtxIseis invokes proc once for each entry in the specified context.
-- It deals with incomplete contexts (opening other symbol tables if necesary).
-- It is called by EnumerateRecordIseis. It uses Outer.
-- "reallyComplete" is used to circumvent an inadequacy in the symbol table's
-- knowledge about the completeness of a context (i.e. whether it has been
-- completely copied from the original symbol table), thus avoiding unneccessary
-- access to the original symbol table via Outer.

CountComponents: PROC [stb: SymbolTableBase, rsei: SymbolRecordIndex] RETURNS [n: NAT];

IsRC: PROC [stb: SymbolTableBase, seIndex: SymbolIndex, checkCommon: BOOLEANTRUE]
RETURNS[BOOLEAN];

IsUnion: PROC [stb: SymbolTableBase, seIndex: SymbolIndex] RETURNS[BOOLEAN];

IsSequence: PROC [stb: SymbolTableBase, seIndex: SymbolIndex] RETURNS[BOOLEAN];

PeelAllButLast: PROC [stb: SymbolTableBase, isei: SymbolIdIndex] RETURNS[SymbolIdIndex];
-- remove layers of type identifier re-definition until either a name
-- change or default initialization is specified

-- Types
AcquireType: PROC[stb: SymbolTableBase,
seIndex: SymbolIndex,
canonicalize: BOOLEANFALSE,
rcmi: RCMap.Index ← LAST[RCMap.Index]]
RETURNS[type: Type];
-- If rcmi = LAST[RCMap.Index] THEN compute the rcmap.

AcquireSequenceType: PROC[stb: SymbolTableBase,
sei: SymbolIndex, -- of sequence part
recordSTB: SymbolTableBase, -- for the containing record
recordSEIndex: SymbolRecordIndex --ditto--]
RETURNS[type: Type];

-- ROPEs, ATOMs
AcquireRope: PROC[stb: SymbolTableBase, hti: SymbolNameIndex]
RETURNS[ROPE];

AcquireAtom: PROC[stb: SymbolTableBase, hti: SymbolNameIndex]
RETURNS[atom: ATOM];

STBToModuleName: PROC[stb: SymbolTableBase] RETURNS[ROPE];

END.