MakeDoNodeProps.Mesa
Last Edited by: Spreitzer, February 18, 1986 5:33:48 pm PST
Carl Hauser, April 11, 1985 3:43:34 pm PST
DIRECTORY Basics, BasicTime, CedarProcess, FS, IO, List, MakeDo, MakeDoPrivate, RedBlackTree, Rope;
MakeDoNodeProps: CEDAR MONITOR
IMPORTS List, RedBlackTree, Rope
EXPORTS MakeDo
INVARIANT
node properties
node classes
=
BEGIN OPEN MakeDo, MakeDoPrivate;
NodeRep: PUBLIC TYPE = MakeDoPrivate.NodeRep;
ActionRep: PUBLIC TYPE = MakeDoPrivate.ActionRep;
NodeClassRep: PUBLIC TYPE = MakeDoPrivate.NodeClassRep;
GetProp: PUBLIC ENTRY PROC [n: Node, prop: REF ANY] RETURNS [val: REF ANY] = {
ENABLE UNWIND => {};
val ← List.Assoc[prop, n.props];
};
SetProp: PUBLIC ENTRY PROC [n: Node, prop, val: REF ANY] = {
ENABLE UNWIND => {};
n.props ← List.PutAssoc[prop, val, n.props];
};
DeclareNodeClass
: PUBLIC ENTRY
PROC [
name: ROPE,
CanonizeName: PROC [ROPE] RETURNS [ROPE],
GetTime: GetTimeProc
]
RETURNS [nodeClass: NodeClass]
= {
nodeClass ← NEW [NodeClassRep ← [name, CanonizeName, GetTime]];
[] ← nodeClasses.Delete[name];
nodeClasses.Insert[nodeClass, name];
};
PublicPartsOfNodeClass: PUBLIC PROC [nc: NodeClass]
RETURNS [
name: ROPE,
CanonizeName: PROC [ROPE] RETURNS [ROPE],
GetTime: GetTimeProc
]
= {
RETURN [nc.name, nc.CanonizeName, nc.GetTime];
};
LookupNodeClass: PUBLIC PROC [className: ROPE] RETURNS [class: NodeClass] = {
class ← NARROW[nodeClasses.Lookup[className]];
};
nodeClasses: RedBlackTree.Table ← RedBlackTree.Create[GetNCKey, CompareNCs];
GetNCKey: PROC [data: REF ANY] RETURNS [key: ROPE] = {
nc: NodeClass = NARROW[data];
key ← nc.name;
};
CompareNCs: PROC [k, data: REF ANY] RETURNS [c: Basics.Comparison] --RedBlackTree.Compare-- = {
k1: ROPE = NARROW[k];
k2: ROPE = GetNCKey[data];
c ← k1.Compare[k2];
};
END.