CoreDirectory.mesa
Copyright © 1986 by Xerox Corporation. All rights reversed.
Created by Christian Jacobi, July 14, 1986 9:50:03 am PDT
Last Edited by: Jacobi July 15, 1986 9:33:25 am PDT
Bertrand Serlet, July 14, 1986 4:18:27 pm PDT
DIRECTORY
Core USING [CellType],
HashTable USING [Table],
Rope USING [ROPE];
CoreDirectory: CEDAR DEFINITIONS = BEGIN
Purpose
Defines libraries of Core CellTypes, as well as a global name space for named libraries.
No relation between the names of CellTypes in a library and the real name of the CellType is enforced by this package.
Types
ROPE: TYPE = Rope.ROPE;
CellType: TYPE = Core.CellType;
Library: TYPE = HashTable.Table;
A Library associates a name (ROPE) to a Core CellType.
Using equal: HashTable.RopeEqual, hash: HashTable.HashRope.
LibraryNotFound: SIGNAL [name: ROPE];
Global name space of libraries
RegisterLibrary: PROC [library: Library, name: ROPE] RETURNS [sameLibrary: Library];
Registers library in the global name space.
Forgets previous registrations of name.
Procedure returns same library again for convenience.
ForgetLibrary: PROC [name: ROPE];
Forgets named library.
Does not change actual library [but the library can be garbage collected]
FetchLibrary: PROC [name: ROPE] RETURNS [library: Library];
Fetches a library from the global name space.
May raise LibraryNotFound, resume is ok, and in that case returns NIL.
Short cuts
CreateLibrary: PROC [] RETURNS [library: Library];
Creates a new, empty library.
Insert: PROC [library: Library, key: ROPE, ct: CellType, overWrite: BOOL FALSE] RETURNS [first: BOOL];
Inserts new key-CellType pair into library.
overWrite: may overwrite previous association in library
Returns first: key was not defined in library before.
May raise LibraryNotFound, resume is ok, and in that case no action is taken.
Fetch: PROC [library: REF, key: ROPE] RETURNS [ct: CellType ← NIL];
Looks up key in library, returns associated CellType (if any).
Returns NIL if CellType not found.
library: Union of Library & ROPE
May raise libraryNotFound, resume is ok, and in that case returns NIL.
END.