-- RTSymbolAccessImpl.mesa
-- Last Modified By Paul Rovner On February 16, 1983 10:14 am
DIRECTORY
RTBasic USING[TypeIndex],
RTOS USING[PrivateHeapZone, PermanentPageZone],
RTSD USING[SD, sMapStiStd],
RTSymbolDefs USING[nullHandle],
RTTypesBasicPrivate USING[TMapStiStd, RMapStiStd, STDesc, SymbolTableIndex];
RTSymbolAccessImpl: MONITOR -- protects MapStiStd
IMPORTS RTOS
EXPORTS RTTypesBasicPrivate
= BEGIN OPEN RTBasic, RTTypesBasicPrivate;
InitialSTIRangeSize: CARDINAL = 1000B;
lastSTIndex: TypeIndex ← 0;
MapStiStd: PUBLIC TMapStiStd;
TooManyTypes: ERROR = CODE;
FindSTI: PUBLIC ENTRY PROC[std: STDesc] RETURNS[i: SymbolTableIndex] =
{ENABLE UNWIND => NULL; RETURN[DoFindSTI[std]]};
DoFindSTI: INTERNAL PROC[std: STDesc] RETURNS[i: SymbolTableIndex] =
INLINE
{ FOR i IN [1..lastSTIndex]
DO IF MapStiStd[i].symbolsStamp = std.symbolsStamp
THEN {IF std.bcd = NIL
OR std.sgi = MapStiStd[i].sgi
THEN {IF MapStiStd[i].sth = RTSymbolDefs.nullHandle
THEN MapStiStd[i].sth ← std.sth;
RETURN[i]}
};
ENDLOOP;
IF lastSTIndex = InitialSTIRangeSize - 1 THEN ERROR TooManyTypes;
i ← lastSTIndex ← lastSTIndex + 1;
MapStiStd[i] ← RTOS.PrivateHeapZone.NEW[STDesc ← std];
};
-- START HERE
MapStiStd ← LOOPHOLE[RTOS.PermanentPageZone.NEW[RMapStiStd[InitialSTIRangeSize]]];
FOR i: CARDINAL IN [0..InitialSTIRangeSize) DO MapStiStd[i] ← NIL ENDLOOP;
LOOPHOLE[LONG[RTSD.SD + RTSD.sMapStiStd],
LONG POINTER TO LONG POINTER]^ ← MapStiStd;
END.