CoreDirectory.mesa
Copyright Ó 1986, 1987 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
Mike Spreitzer February 27, 1987 2:34:46 pm PST
Bertrand Serlet, June 4, 1987 12:40:09 pm PDT
DIRECTORY
Core USING [CellType],
SymTab USING [Ref],
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 = SymTab.Ref;
A Library associates a name (ROPE, case matters) to a Core CellType.
Access by primitives
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 ← NIL];
Fetches a library from the global name space.
Returns NIL if not found.
Access with sugared version
LibraryNotFound: SIGNAL [name: ROPE];
CreateLibrary: PROC [] RETURNS [library: Library];
Creates a new, empty library.
Insert: PROC [library: Library, key: ROPE, ct: CellType, overWrite: BOOLFALSE] 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.