MobListerUtils.mesa
Copyright Ó 1985, 1991 by Xerox Corporation. All rights reserved.
Russ Atkinson, March 7, 1985 4:08:25 am PST
Satterthwaite March 10, 1986 5:30:25 pm PST
Andy Litman March 3, 1988 3:35:27 pm PST
JKF January 11, 1989 8:20:38 am PST
DIRECTORY
ConvertUnsafe USING [SubString],
IO USING [STREAM],
Literals USING [Base, LitDescriptor, LTIndex, LTNull, LTRecord, MSTIndex, STIndex, STNull],
MobDefs USING [Base, Link, Mob, MobBase, MTIndex, MTRecord, SGIndex, SGRecord, VersionStamp],
Rope USING [ROPE],
Symbols USING [Base, BitAddress, BodyRecord, BTIndex, ContextLevel, CSEIndex, CTXIndex, CTXNull, CTXRecord, ISEIndex, ISENull, lG, lL, lZ, MDIndex, Name, nullName, RootBti, SEIndex, SENull, SERecord, TransferMode, TypeClass, typeTYPE],
SymbolTable USING [Base],
Tree USING [Link, NodeName];
MobListerUtils: DEFINITIONS = BEGIN
T Y P E S & C O N S T A N T S
BitAddress: TYPE = Symbols.BitAddress;
BTIndex: TYPE = Symbols.BTIndex;
BTRecord: TYPE = Symbols.BodyRecord;
CSEIndex: TYPE = Symbols.CSEIndex;
typeTYPE: CSEIndex = Symbols.typeTYPE;
ContextLevel: TYPE = Symbols.ContextLevel;
lZ: ContextLevel = Symbols.lZ;
lG: ContextLevel = Symbols.lG;
lL: ContextLevel = Symbols.lL;
CTXIndex: TYPE = Symbols.CTXIndex;
CTXNull: CTXIndex = Symbols.CTXNull;
CTXRecord: TYPE = Symbols.CTXRecord;
ISEIndex: TYPE = Symbols.ISEIndex;
ISENull: ISEIndex = Symbols.ISENull;
ISERecord: TYPE = SERecord.id;
LTIndex: TYPE = Literals.LTIndex;
LTNull: LTIndex = Literals.LTNull;
LTRecord: TYPE = Literals.LTRecord;
LitDescriptor: TYPE = Literals.LitDescriptor;
MDIndex: TYPE = Symbols.MDIndex;
MSTIndex: TYPE = Literals.MSTIndex;
MSTNull: MSTIndex = LOOPHOLE[Literals.STNull];
MTIndex: TYPE = MobDefs.MTIndex;
MTRecord: TYPE = MobDefs.MTRecord;
Name: TYPE = Symbols.Name;
nullName: Name = Symbols.nullName;
NodeName: TYPE = Tree.NodeName;
RefMob: TYPE = REF MobDefs.Mob;
RefMTRecord: TYPE = REF MTRecord;
RefSGRecord: TYPE = REF SGRecord;
RootBti: BTIndex = Symbols.RootBti;
ROPE: TYPE = Rope.ROPE;
SEIndex: TYPE = Symbols.SEIndex;
SENull: SEIndex = Symbols.SENull;
SERecord: TYPE = Symbols.SERecord;
SGIndex: TYPE = MobDefs.SGIndex;
SGRecord: TYPE = MobDefs.SGRecord;
STIndex: TYPE = Literals.STIndex;
STREAM: TYPE = IO.STREAM;
SubString: TYPE = ConvertUnsafe.SubString;
SymbolTableBase: TYPE = SymbolTable.Base;
TransferMode: TYPE = Symbols.TransferMode;
TypeClass: TYPE = Symbols.TypeClass;
VersionStamp: TYPE = MobDefs.VersionStamp;
Utility procedures
Some of these utility routines were cloned from various places to allow stream: STREAM and stb: SymbolTableBase as arguments, so we don't have to use global variables.
MobErr: ERROR [err: Rope.ROPE];
InitMobTab: PROC;
must call Init to before calling ReadMob.
ReadMob: PROC [name: Rope.ROPE] RETURNS [mob: MobDefs.MobBase];
can raise MobErr
FreeMob: PROC [mob: MobDefs.MobBase];
can raise MobErr
PrintSE: PROC[sei: ISEIndex, nBlanks: CARDINAL, definitionsOnly: BOOL, stream: STREAM, stb: SymbolTableBase];
Prints out the information for the given sei. The indentation level is given by nBlanks. For a definitions file, definitionsOnly = TRUE.
PrintSei: PROC[sei: ISEIndex, stream: STREAM, stb: SymbolTableBase];
Just prints out the name for the given ISEIndex.
PrintType: PROC[sei: SEIndex, stream: STREAM, stb: SymbolTableBase];
Prints out the short form of the type, including its base ISEIndex.
PrintTypeInfo: PROC[sei: SEIndex, nBlanks: CARDINAL, stream: STREAM, stb: SymbolTableBase];
Prints out the long form of the type. The indentation level is given by nBlanks.
PrintTree: PROC[tree: Tree.Link, nBlanks: NAT, stream: STREAM, stb: SymbolTableBase];
Prints out the tree. The indentation level is given by nBlanks.
PrintLiteral: PROC[lti: Literals.LTIndex, stream: STREAM, stb: SymbolTableBase];
Prints out the literal.
PrintStringLiteral: PROC[sti: Literals.STIndex, stream: STREAM, stb: SymbolTableBase];
Prints out the literal.
PrintMobLink: PROC[link: MobDefs.Link, stream: STREAM];
Prints the link, distinguishing between proc, type, and var varieties.
PrintTreeLink: PROC[link: Tree.Link, stream: STREAM];
Prints the link in short form, distinguishing between subtree (default), hash, symbol, and literal varieties.
PrintName: PROC[name: Name, stream: STREAM, stb: SymbolTableBase];
Prints the name.
WriteNodeName: PROC[n: NodeName, stream: STREAM];
Prints the NodeName in its readable form.
WriteTypeName: PROC[n: TypeClass, stream: STREAM];
Prints the TypeClass in its readable form.
WriteModeName: PROC[n: TransferMode, stream: STREAM];
Prints the TransferMode in its readable form.
OutCtx: PROC[message: Rope.ROPE, ctx: CTXIndex, stream: STREAM];
Prints the ctx in short form (" ctx: %g").
OutArgType: PROC[message: ROPE, sei: CSEIndex, stream: STREAM, stb: SymbolTableBase];
Prints the message and sei in short form ("%g: %g"). Special consideration for NIL and ANY.
PrintVersion: PROC[stamp: VersionStamp, stream: STREAM, useTime: BOOL ¬ FALSE];
Prints the version stamp. If useTime, then the time associated with the stamp is also printed (useful only for source files).
PrintStringFromTable: PROC[index: CARDINAL, stream: STREAM, stb: SymbolTableBase];
Prints the string at the given index.
PrintString: PROC[str: LONG STRING, stream: STREAM];
Prints the given long string.
PrintSubString: PROC[ss: SubString, stream: STREAM];
Prints the given substring.
PrintIndex: PROC[index: UNSPECIFIED, stream: STREAM];
Prints the given index as a decimal unsigned number.
PrintLongIndex: PROC[index: Symbols.Base RELATIVE LONG POINTER, stream: STREAM];
Prints the given index as a decimal unsigned number.
Indent: PROC[stream: STREAM, nBlanks: NAT];
Prints a '\n, followed by nBlanks blanks.
DescriptorValue: PROC[stb: SymbolTableBase, lti: LTIndex] RETURNS[LitDescriptor];
Gets the literal descriptor associated with the given LTIndex.
MasterString: PROC[stb: SymbolTableBase, sti: STIndex] RETURNS[MSTIndex ¬ MSTNull];
Gets the master string for the given STIndex.
ShortName: PROC[rope: ROPE] RETURNS[ROPE];
Strips off version and directory information from the given file name.
END.