CDMarks.mesa (part of ChipNDale)
Copyright © 1983, 1985 by Xerox Corporation. All rights reserved.
Created by Christian Jacobi, July 12, 1983 2:11 pm
Last edited by: Christian Jacobi, September 19, 1986 11:15:32 am PDT
DIRECTORY
CD USING [Object, Design, markNum];
CDMarks: CEDAR DEFINITIONS =
BEGIN
Every object which is in the directory* has a mark, which can temporarily used to mark objects. To avoid to reinitialize all the marks before each usage of marks, a markvalue goes cyclic through the small subrange MarkRange.
For every application of marks, the client gets a new value by calling DoWithMark. This value is different from every previous value of marks remaining in the data structures. Whenever a new value for marks is requested, all the old values now just mean un-marked, nevertheless, they remain hanging around. However, when there are no more unused values for marks, all the marks must be reset; there must stay no mark with a value which could be reused for marking in the next cycle through MarkRange.
To avoid conflicts, only one client at a time is allowed to use the mark features. The rule which client is allowed to use the mark features is a convention: the client who owns the lock of the command execution queue of the design gets the exclusive right to use the marks, while he owns the lock. However, this is checked.
The value 0 is reserved for clear marks, it can be safely assigned to marks independent of which value is the current mark value. However, if you have to do this, chances are big that your algorithm may be wrong.
*Only objects which are actually part of the design and in the directory may be used. This is necessary to guaranty that the marks are properly cleared on the next cycle through MarkRange and for avoiding conflicts on mark usage on multiple designs.
The directory invariants are strictly required for usage of marks to be correct.
MarkRange: TYPE = [0..CD.markNum);
MarkProc: TYPE = PROC [mark: MarkRange];
DoWithMark: PROC [design: CD.Design, proc: MarkProc];
MarkOccupied: ERROR;
MarkUnMarkedInclusiveChildren: PROC [design: CD.Design, ob: CD.Object, mark: MarkRange];
--For all objects (whose class is inDirectory) do:
if their markvalue is different, then set it to value, and do this also recursively for
--all the children of the object.
--mark must be the current mark value.
END.