MakeDoFinders.Mesa
Copyright Ó 1991 by Xerox Corporation. All rights reserved.
Last tweaked by Mike Spreitzer on September 8, 1987 3:26:43 pm PDT
Eduardo Pelegri-Llopart October 21, 1988 1:22:01 pm PDT
JKF January 11, 1989 9:57:02 am PST
DIRECTORY
MakeDo USING [End, Finder, NodeRep],
MakeDoPrivate USING [ActionRep, NodeRep];
MakeDoFinders:
CEDAR
MONITOR
EXPORTS MakeDo, MakeDoPrivate
=
INVARIANT
finders lists Finders.
BEGIN OPEN MakeDo, MakeDoPrivate;
NodeRep: PUBLIC TYPE = MakeDoPrivate.NodeRep;
ActionRep: PUBLIC TYPE = MakeDoPrivate.ActionRep;
finders: LIST OF Finder ¬ NIL;
AddFinder:
PUBLIC
ENTRY
PROC [finder: Finder, end: End] =
BEGIN ENABLE UNWIND => {};
SELECT end
FROM
front => finders ¬ CONS[finder, finders];
back => {fl:
LIST
OF Finder;
IF finders = NIL THEN {finders ¬ LIST[finder]; RETURN};
FOR fl ¬ finders, fl.rest WHILE fl.rest # NIL DO NULL ENDLOOP;
fl.rest ¬ LIST[finder]};
ENDCASE => ERROR;
END;
EnumerateFinders:
PUBLIC
ENTRY
PROC [to:
PROC [Finder]
RETURNS [stop:
BOOL]] = {
ENABLE UNWIND => {};
FOR fl:
LIST
OF Finder ¬ finders, fl.rest
WHILE fl #
NIL
DO
IF to[fl.first] THEN EXIT;
ENDLOOP;
RETURN};
END.