DIRECTORY Rope USING [ROPE], SafeStorage USING [nullType, Type]; RTTCache: CEDAR DEFINITIONS = BEGIN OPEN Rope, SafeStorage; ProcKey: TYPE = PROC ANY RETURNS ANY; InvalidIndex: ERROR; IntEntry: TYPE = REF IntEntryRep; IntEntryRep: TYPE = RECORD [ next: IntEntry _ NIL, valid: BOOL _ FALSE, type: Type _ nullType, proc: ProcKey _ NIL, int: INT _ -1]; RefEntry: TYPE = REF RefEntryRep; RefEntryRep: TYPE = RECORD [ next: RefEntry _ NIL, valid: BOOL _ FALSE, type: Type _ nullType, proc: ProcKey _ NIL, ref: REF _ NIL]; ComponentMap: TYPE = REF ComponentMapRep; ComponentMapRep: TYPE = RECORD [ filledTypes, filledNames: CARDINAL _ 0, comps: SEQUENCE len: CARDINAL OF ComponentEntry]; ComponentEntry: TYPE = RECORD [ validType, validName: BOOL _ FALSE, type: Type _ nullType, name: ROPE _ NIL]; NullComponentEntry: ComponentEntry = [FALSE, FALSE, nullType, NIL]; LookupInt: PROC [type: Type, proc: ProcKey] RETURNS [entry: IntEntry]; FillIntEntry: PROC [entry: IntEntry, value: INT] RETURNS [alreadyFull: BOOL]; ClearIntEntry: PROC [entry: IntEntry]; GetInt: PROC [entry: IntEntry] RETURNS [value: INT, valid: BOOL]; LookupRef: PROC [type: Type, proc: ProcKey] RETURNS [entry: RefEntry]; FillRefEntry: PROC [entry: RefEntry, value: REF] RETURNS [alreadyFull: BOOL]; ClearRefEntry: PROC [entry: RefEntry]; GetRef: PROC [entry: RefEntry] RETURNS [value: REF, valid: BOOL]; GetStats: PROC RETURNS [intProbes, intMisses, intFilled, refProbes, refMisses, refFilled: INT]; NewComponentMap: PROC [len: NAT] RETURNS [map: ComponentMap]; FillNameComponent: PROC [map: ComponentMap, index: INT, name: ROPE] RETURNS [alreadyFull: BOOL]; FillTypeComponent: PROC [map: ComponentMap, index: INT, type: Type] RETURNS [alreadyFull: BOOL]; GetComponentAtIndex: PROC [map: ComponentMap, index: INT] RETURNS [comp: ComponentEntry]; GetComponentForName: PROC [map: ComponentMap, name: ROPE, case: BOOL _ TRUE] RETURNS [index: INT, comp: ComponentEntry]; END. RTTCache.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Paul Rovner, May 31, 1983 12:32 pm Russ Atkinson (RRA) February 11, 1985 12:04:58 pm PST This interface provides for caching information about types so we don't have to access symbols tables for the information (an expensive and nasty proposition). There is no provision for flushing entries once they are made, and no flushing should be added without changing implementations that depend on this fact! Also, the cache is fully protected against parallel access. looks up the entry corresponding to the type and proc; entry.valid => entry.int is OK fills the entry acquired by LookupInt will not overwrite an already full entry atomically invalidates the value in the entry an invalid entry always has entry.valid = -1 atomically retrieves the value in the entry looks up the entry corresponding to the type and proc entry.valid => entry.ref is OK fills the entry acquired by LookupRef will not overwrite an already full entry atomically invalidates the value in the entry an invalid entry always has entry.ref = NIL atomically retrieves the value in the entry Gets the statistics for this cache usage. generates a new (empty) component map of the given size fills in a name component in the component map will not overwrite an already full component will ERROR InvalidIndex if index NOT IN [0..map.len) fills in a type component in the component map will not overwrite an already full component will ERROR InvalidIndex if index NOT IN [0..map.len) atomically returns the given component entry will ERROR InvalidIndex if index NOT IN [0..map.len) atomically returns the given component entry for the given name IF case = TRUE, then name search is case-sensitive (Rope convention) will return [-1, NullComponentEntry] if no such name Κ˜codešœ ™ Kšœ Οmœ1™