DirectedModuleGraphs.Mesa
Mike Spreitzer September 27, 1986 3:20:11 pm PDT
DIRECTORY AMModel, Atom, Graphs, Rope, VM, WorldVM;
DirectedModuleGraphs:
CEDAR
PROGRAM
IMPORTS AMModel, Atom, Graphs, Rope, VM, WorldVM
=
BEGIN
ROPE: TYPE = Rope.ROPE;
vertexKey: ATOM ← Atom.MakeAtom["Spreitzer January 5, 1984 6:48 pm"];
worldContext: AMModel.Context;
NewModuleVertex:
PROC [moduleName:
ROPE]
RETURNS [vertex: Graphs.Vertex] = {
vertex ← [moduleName, moduleVertexClass];
};
GetLabel:
PROC [vertex: Graphs.Vertex]
RETURNS [label:
ROPE]
--Graphs.GetLabelProc-- = {
label ← NARROW[vertex.rep]};
ExpandModule:
PROC [vertex: Graphs.Vertex,
Consume: Graphs.EdgeConsumer, filter: Graphs.DirectionFilter ← Graphs.allDirections]
--Graphs.ExpandProc-- = {
moduleName: ROPE = NARROW[vertex.rep];
IF filter[Incoming]
THEN {
context: AMModel.Context;
imports: LIST OF AMModel.PartialInterfaceInstance;
TRUSTED {context ← AMModel.MostRecentNamedContext[name: moduleName, context: worldContext]};
IF context = NIL THEN RETURN;
TRUSTED {imports ← AMModel.Imports[context !VM.AddressFault => CONTINUE]};
FOR imports ← imports, imports.rest
WHILE imports #
NIL
DO
name: ROPE;
TRUSTED {name ← AMModel.ContextName[imports.first.ir]};
Consume[Graphs.dullEdge, Incoming, NewInterfaceVertex[name]];
ENDLOOP;
};
IF filter[Outgoing]
THEN {
context: AMModel.Context;
exports: LIST OF AMModel.PartialInterfaceInstance;
TRUSTED {context ← AMModel.MostRecentNamedContext[name: moduleName, context: worldContext]};
IF context = NIL THEN RETURN;
TRUSTED {exports ← AMModel.Exports[context !VM.AddressFault => CONTINUE]};
FOR exports ← exports, exports.rest
WHILE exports #
NIL
DO
name: ROPE;
TRUSTED {name ← AMModel.ContextName[exports.first.ir]};
Consume[Graphs.dullEdge, Outgoing, NewInterfaceVertex[name]];
ENDLOOP;
};
};
NewInterfaceVertex:
PROC [moduleName:
ROPE]
RETURNS [vertex: Graphs.Vertex] = {
vertex ← [moduleName, interfaceVertexClass]};
ExpandInterface:
PROC [vertex: Graphs.Vertex,
Consume: Graphs.EdgeConsumer, filter: Graphs.DirectionFilter ← Graphs.allDirections]
--Graphs.ExpandProc-- = {
interfaceName: ROPE = NARROW[vertex.rep];
FindInterface:
PROC [prog: AMModel.Context]
RETURNS [stop:
BOOLEAN] =
BEGIN
progName: ROPE;
imports, exports: LIST OF AMModel.PartialInterfaceInstance ← NIL;
stop ← FALSE;
IF filter[Incoming]
THEN {
TRUSTED {exports ← AMModel.Exports[prog !VM.AddressFault => CONTINUE]};
FOR exports ← exports, exports.rest
WHILE exports #
NIL
DO
name: ROPE;
TRUSTED {name ← AMModel.ContextName[exports.first.ir]};
IF name.Equal[interfaceName]
THEN {
TRUSTED {progName ← AMModel.ContextName[prog]};
Consume[Graphs.dullEdge, Incoming, NewModuleVertex[progName]];
EXIT};
ENDLOOP;
};
IF filter[Outgoing]
THEN {
TRUSTED {imports ← AMModel.Imports[prog !VM.AddressFault => CONTINUE]};
FOR imports ← imports, imports.rest
WHILE imports #
NIL
DO
name: ROPE;
TRUSTED {name ← AMModel.ContextName[imports.first.ir]};
IF name.Equal[interfaceName]
THEN {
IF progName = NIL THEN TRUSTED {progName ← AMModel.ContextName[prog]};
Consume[Graphs.dullEdge, Outgoing, NewModuleVertex[progName]];
EXIT};
ENDLOOP;
};
END;
TRUSTED {[] ← AMModel.ContextChildren[context: worldContext, proc: FindInterface]};
};
moduleVertexClass: Graphs.VertexClass ← Graphs.NewVertexClass[[
Expand: ExpandModule,
GetLabel: GetLabel
]];
interfaceVertexClass: Graphs.VertexClass ← Graphs.NewVertexClass[[
Expand: ExpandInterface,
GetLabel: GetLabel
]];
TRUSTED {worldContext ← AMModel.RootContext[WorldVM.LocalWorld[]]};
END.
← &b ← GraphBrowsers.Browse[vertex: &dmg ← DirectedModuleGraphs.NewModuleVertex["DirectedModuleGraphs"], browserClass: GraphBrowsers.basicBrowserClass, viewerInit: [name: "DirectedModuleGraphs", iconic: FALSE]]