Text preview for : SymbolTable.mesa_Oct77.pdf part of xerox SymbolTable.mesa_Oct77 xerox mesa 3.0_1977 listing SymbolTable.mesa_Oct77.pdf



Back to : SymbolTable.mesa_Oct77.pd | Home

symboltable.mesa 24-0CT-77 18:44:36 Page 1


-- file SymbolTable.Mesa
-- last modified by Barbara, October 3, 1977 11:24 AM
DIRECTORY
AltoDers: FROM "altodefs",
ControlDefs: FROM "controldefs",
InlineDefs: FROM "inlinedefs",
StringDefs: FROM "stringdefs",
TableDefs: FROM "tabledefs",
SymTabDefs: FROM "symtabders",
SymDefs: FROM "symdefs";
SymbolTable: PROGRAM
IMPORTS StringDefs
EXPORTS SymTabDefs SHARES SymDefs
PUBLIC
BEGIN
OPEN SymDefs;
-- tables defining the current symbol table
hashvec: DESCRIPTOR FOR ARRAY OF HTIndex; -- hash index
ht: DESCRIPTOR FOR ARRAY --HTIndex-- OF HTRecord; -- hash table
ssb: STRING; id string
seb: TableDefs.TableBase; se table
ctxb: TableDefs.TableBase; context table
mdb: TableDefs.TableBase; module directory base
bb: TableDefs.TableBase; body table
stHandle: POINTER TO STHeader;
-- info defining the source file links
sourcefile: STRING;
fgt: DESCRIPTOR FOR ARRAY OF FGTEntry;
ignorecases: BOOLEAN;
-- the following orocedure is called if the base values change
notifier: PROCEDURE [POINTER TO FRAME[SymbolTable]];
NullNotifier: PROCEDURE [POINTER TO FRAME[SymbolTable]] =
BEGIN
RETURN
END;

SubString: TYPE = StringDefs.SubString;
hashvalue: PROCeDURE (s: SubString] RETURNS [HVIndex] =
BEGIN -- computes the hash index for string s
CharBits: MACHINe CODE (CHARACTER, WORD] RETURNS (WORD]
LOOPHOLE(InlineDefs.BITAND];
mask: WORD = 337B; -- masks out ASCII case shifts
n: CARDINAL = s. length;
b: STRING = s.base;
v: WORD;
v p CharBits(b(s.offset]. mask]*177B + CharBits(b(s.offset+(n-1)]. maSk];
RETURN (InlineDefs.BITXOR(v, n*17B] MOD LENGTH(hashvec]]
END;
FindString: PROCEDURE (s: SubString] RETURNS [found: BOOLEAN, hti: HTIndex]
BEGIN
OPEN StringDefs;
desc: SubSlringOescriptor;
ss: SubString = @desc;
hli p has~vec[hashvalue[s]];
WIITl [ ht i # IITNull
DO
SubSlringforllash[ss, hli];
round p
(Tr ignorecases TlirN EquivalentSubStrings rLS[ rqualSubStrings)[s,ss]:
Ir round TllfN RfTURN;
hti .. hl[hti].l ink;
fNOIOOP;
RfTURN [fAt Sf. IITNu 11]
rNO;
symboltable.mesa 24-0CT-77 18:44:36 Page 2


SubStringForHash: PROCEDURE [s: SubString, hti: HTlndex] =
BEGIN -- gets string for hash table entry
s.base .. ssb:
IF hti = HTNull
THEN s.offset .. s.length .. 0
ELSE
BEGIN
s.offset .. ht[hti].ssIndex:
s.length .. ht[hti+1].ssIndex - s.offset:
END:
RETURN
END:

hashforse: PROCEDURE [sei: ISEIndex] RETURNS [HTIndex]
BEGIN
RETURN [(seb+sei).htptr]
END:
searchcontext: PROCEDURE [hti: HTIndex, ctx: CTXIndex] RETURNS [BOOLEAN, ISEIndex] =
BEGIN
sei, root: ISEIndex:
IF ctx # CTXNull AND hti # HTNull
THEN
BEGIN sei" root .. (ctxb+ctx).sellst:
DO
IF sei = SENull THEN EXIT:
IF (seb+sei).htptr = hti THEN RETURN [TRUE, sei]:
WITH (seb+sei) SELECT FROM
sequential =) sei" sei + SIZE[sequential id SERecord]:
linked =) IF (sei .. link)