MakeDoNodeProps.Mesa
Last Edited by: Spreitzer, February 18, 1986 5:33:48 pm PST
Last tweaked by Mike Spreitzer on October 5, 1992 12:41 pm PDT
JKF January 11, 1989 10:19:32 am PST
Eduardo Pelegri-Llopart October 21, 1988 8:15:20 am PDT
Carl Hauser, April 11, 1985 3:43:34 pm PST
DIRECTORY
List USING [Assoc, PutAssoc],
MakeDo USING [GetInfoProc, NodeRep],
MakeDoPrivate USING [ActionRep, Node, NodeClass, NodeClassRep, NodeRep],
Rope,
SymTab;
MakeDoNodeProps: CEDAR MONITOR
IMPORTS List, SymTab
EXPORTS MakeDo
INVARIANT
node properties
node classes
=
BEGIN OPEN MakeDo, MakeDoPrivate;
ROPE: TYPE = Rope.ROPE;
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],
GetInfo: GetInfoProc
]
RETURNS [nodeClass: NodeClass]
= {
nodeClass ← NEW [NodeClassRep ← [name, CanonizeName, GetInfo]];
[] ← nodeClasses.Store[name, nodeClass];
};
PublicPartsOfNodeClass: PUBLIC PROC [nc: NodeClass]
RETURNS [
name: ROPE,
CanonizeName: PROC [ROPE] RETURNS [ROPE],
GetInfo: GetInfoProc
]
= {
RETURN [nc.name, nc.CanonizeName, nc.GetInfo];
};
LookupNodeClass: PUBLIC PROC [className: ROPE] RETURNS [class: NodeClass] = {
class ← NARROW[nodeClasses.Fetch[className].val];
};
nodeClasses: SymTab.Ref ← SymTab.Create[case: TRUE];
END.