LupineSymbolTableUtilsImpl.mesa.
Copyright © 1985 by Xerox Corporation. All rights reserved.
Last edited by BZM on 11-May-82 14:12:53.
Last edited by Andrew Birrell October 24, 1983 4:50 pm (changes for 3.4)
Last edited by Paul Rovner January 28, 1983 1:37 pm (changes for 4.0)
Last Edited by: Swinehart, July 11, 1984 11:49:45 pm PDT
Last Edited by: Bob Hagmann, February 8, 1985 5:25:29 pm PST
This should be part of LupineSymbolTableImpl, but the compiler overflows if I put it there. Some utility procedures are duplicated.
DIRECTORY
ConvertUnsafe USING [SubString, SubStringToRope],
LupineSymbolTable USING [
STBase, String, SymbolHandle, SymbolID, TypeHandle, TypeID ],
Symbols USING [Base, CTXIndex, CTXRecord,
HTIndex, HTNull, ISEIndex, ISENull, MDIndex, SEIndex, SENull];
LupineSymbolTableUtilsImpl: PROGRAM
IMPORTS ConvertUnsafe
EXPORTS LupineSymbolTable
SHARES LupineSymbolTable
= BEGIN OPEN Symbols, ST: LupineSymbolTable;
STBase: TYPE = ST.STBase;
String: TYPE = ST.String;
General operations for types and symbols.
SymbolName: PUBLIC PROCEDURE [symbol: ST.SymbolHandle]
RETURNS [String] =
BEGIN
stb: STBase = symbol.base;
IF IsAnonymous[symbol]
THEN RETURN[NIL]
ELSE RETURN[IseiString[stb, symbol.symbol]]
END;
IsAnonymous: PUBLIC PROCEDURE [symbol: ST.SymbolHandle]
RETURNS [yes: BOOLEAN] =
{RETURN[symbol.base.seb[symbol.symbol].hash = HTNull]};
SymbolType: PUBLIC PROCEDURE [symbol: ST.SymbolHandle]
RETURNS [type: ST.TypeHandle] = {
RETURN[ST.TypeHandle[symbol.base, SymType[symbol.base, symbol.symbol]]]};
SymType: PUBLIC PROCEDURE [stb: STBase, isei: ISEIndex] RETURNS [SEIndex] =
INLINE BEGIN
RETURN[ IF stb.seb[isei].idType = SENull
THEN ERROR ELSE stb.seb[isei].idType];
END;
SymbolUniqueID: PUBLIC PROCEDURE [symbol: ST.SymbolHandle]
RETURNS [uniqueID: ST.SymbolID] = {
RETURN[LOOPHOLE[@symbol.base.seb[symbol.symbol]]]};
MakeTypeID: PUBLIC PROC [t: ST.TypeHandle] RETURNS [id: ST.TypeID] = {
sei: Symbols.SEIndex ← t.type;
lastISei: Symbols.ISEIndex ← Symbols.ISENull;
defCtx: Symbols.CTXIndex;
seb: Symbols.Base = t.base.seb;
ctxb: Symbols.Base = t.base.ctxb;
mdb: Symbols.Base = t.base.mdb;
id.stamp.time𡤀 -- Denote failure, just in case
DO
WITH eb: seb[sei] SELECT FROM
id => {lastISei ← LOOPHOLE[sei]; sei ← eb.idInfo};
cons => EXIT;
ENDCASE;
ENDLOOP;
IF lastISei = Symbols.ISENull THEN RETURN;
id.sei ← seb[lastISei].idValue;
IF id.sei = Symbols.ISENull THEN id.sei ← lastISei;
defCtx ← seb[lastISei].idCtx;
WITH cc: ctxb[defCtx] SELECT FROM
simple => id.stamp ← t.base.stHandle.version;
included => id.stamp ← mdb[cc.module].stamp;
ENDCASE => ERROR;
};
IseiString: PROCEDURE [stb: STBase, isei: ISEIndex]
RETURNS[ String] =
INLINE BEGIN
RETURN[HtiString[stb,
(IF isei=ISENull THEN HTNull ELSE stb.seb[isei].hash)]]
END;
HtiSubString: PROCEDURE [stb: STBase, hti: HTIndex]
RETURNS[ConvertUnsafe.SubString] =
INLINE BEGIN -- hti=HTNull is OK; returns null substring.
RETURN[stb.SubStringForName[hti]];
END;
HtiString: PROCEDURE [stb: STBase, hti: HTIndex] RETURNS[String] =
BEGIN
RETURN[ConvertUnsafe.SubStringToRope[HtiSubString[stb, hti]]]
END;
END. -- LupineSymbolTableImpl.