DIRECTORY PropertyLists; PropertyListsImpl: CEDAR MONITOR EXPORTS PropertyLists = BEGIN PropList: TYPE = PropertyLists.PropList; GetProp: PUBLIC ENTRY PROC [propList: PropList, prop: REF] RETURNS [REF _ NIL] = { ENABLE UNWIND => NULL; WHILE propList # NIL DO IF propList.first.key = prop THEN RETURN [propList.first.val]; propList _ propList.rest; ENDLOOP; }; PutProp: PUBLIC ENTRY PROC [propList: PropList, prop: REF, val: REF _ NIL] RETURNS [PropList] = { ENABLE UNWIND => NULL; IF val=NIL THEN RETURN [RemPropInternal[propList, prop]] ELSE RETURN [PutPropInternal[propList, prop, val]] }; RemPropInternal: INTERNAL PROC [propList: PropList, prop: REF] RETURNS [PropList] = INLINE { lst: PropList _ propList; lag: PropList _ NIL; UNTIL lst = NIL DO rest: PropList _ lst.rest; IF lst.first.key = prop THEN { IF lag = NIL THEN RETURN [rest]; lag.rest _ rest; RETURN [propList]; }; lag _ lst; lst _ rest; ENDLOOP; RETURN [propList]; }; PutPropInternal: INTERNAL PROC [propList: PropList, prop: REF, val: REF] RETURNS [PropList] = INLINE { lst: PropList _ propList; lag: PropList _ NIL; WHILE lst # NIL DO IF lst.first.key = prop THEN { lst.first.val _ val; RETURN [propList]; }; lag _ lst; lst _ lst.rest; ENDLOOP; lst _ LIST[[key: prop, val: val]]; IF lag = NIL THEN RETURN [lst]; lag.rest _ lst; RETURN [propList]; }; Enumerate: PUBLIC PROC [propList: PropList, proc: PropertyLists.EachProp] RETURNS [quit: BOOL_FALSE] = { FOR l: PropList _ propList, l.rest WHILE l#NIL AND ~quit DO quit _ proc[l.first.key, l.first.val]; ENDLOOP; }; END. ΪPropertyListsImpl.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Christian Jacobi, September 19, 1985 3:33:07 pm PDT 4:15 pm Christian Jacobi, March 12, 1986 8:13:23 pm PST Bertrand Serlet July 10, 1986 6:32:23 pm PDT --Update list element in place --prop not found on property list --yes, this needs no special monitoring... --but I don't want each user to have to prove again --that this module never creates a state where Enumerate would fail Κ˜codešœ™Kšœ Οmœ1™Kšœ˜Kšžœ˜—K˜—K˜šŸœžœžœžœžœžœžœžœ˜aKšžœžœžœ˜Kšžœžœžœžœ"˜8Kšžœžœ(˜3K˜—K˜š Ÿœžœžœžœžœžœ˜\Kšœ˜Kšœžœ˜šžœžœž˜Kšœ˜šžœžœ˜Kšžœžœžœžœ˜ Kšœ˜Kšžœ ˜K˜—K˜ K˜ Kšžœ˜—Kšžœ ˜Kšœ˜—K˜šŸœžœžœžœžœžœžœ˜gKšœ˜Kšœžœ˜šžœžœž˜šžœžœ˜Kšœ™K˜Kšžœ ˜Kšœ˜—K˜ K˜Kšžœ˜—KšΟc!™!Kšœžœ˜"Kšžœžœžœžœ˜Kšœ˜Kšžœ ˜Kšœ˜K˜—š Ÿ œž œ4žœžœžœ˜hK™+K™3KšœC™Cš žœ žœžœžœž˜;Kšœ&˜&Kšžœ˜—K˜—K˜Kšžœ˜K˜—…—