SXCount.mesa
Written by: Shand, July 2, 1984 1:23:16 pm PDT
Last Edited by: Shand, July 28, 1984 10:57:05 pm PDT
Last Edited by: Jacobi, April 8, 1985 12:18:15 pm PST
Last edited by: gbb July 15, 1985 5:40:41 pm PDT
DIRECTORY
CD USING [InstanceRep, Instance],
Commander USING [CommandProc, Handle, Register],
CornerStitching USING [NewTesselation, Tesselation, TileAt],
IO USING [int, PutF],
SafeStorage USING [GetCanonicalReferentType, Type],
SweepCollectableStorage USING [EnumerateCollectableStorage, InfoProc],
SX USING [AreaPerimRec, AttachedNode, Circuit, CircuitNode, MergeRec, NodeLinkage],
SXQuadTree USING [QuadTree, Rectangle]
;
SXCount: CEDAR PROGRAM
IMPORTS Commander, CornerStitching, IO, SafeStorage, SweepCollectableStorage =
BEGIN
Count: Commander.CommandProc -- [cmd: Commander.Handle] RETURNS [result: REF ANY ← NIL, msg: ROPE ← NIL] -- ~ {
perObject: SweepCollectableStorage.InfoProc -- [type: SafeStorage.Type, size: INT, object: LONG CARDINAL] RETURNS [continue: BOOLEAN] -- = {
IF type = CODE[SX.Circuit] THEN
CircuitCount ← CircuitCount + 1
ELSE IF type = CODE[SXQuadTree.QuadTree] THEN
QuadTreeCount ← QuadTreeCount + 1
ELSE IF type = CODE[SXQuadTree.Rectangle] THEN
RectangleCount ← RectangleCount + 1
ELSE IF type = CODE[SX.CircuitNode] THEN
CircuitNodeCount ← CircuitNodeCount + 1
ELSE IF type = APList THEN
AreaPerimRecCount ← AreaPerimRecCount + 1
ELSE IF type = CODE[SX.NodeLinkage] THEN
NodeLinkageCount ← NodeLinkageCount + 1
ELSE IF type = CODE[SX.AttachedNode] THEN
AttachedNodeCount ← AttachedNodeCount + 1
ELSE IF type = MRList THEN
MergeRecCount ← MergeRecCount + 1
ELSE IF type = CODE[CornerStitching.Tesselation] THEN
TessCount ← TessCount + 1
ELSE IF type = CSTile THEN
TileCount ← TileCount + 1
ELSE IF type = CODE[CD.InstanceRep] THEN
ApplRecCount ← ApplRecCount + 1
ELSE IF type = ApplList THEN
ApplListCount ← ApplListCount + 1;
RETURN[TRUE];
};
CircuitCount: INT ← 0;
QuadTreeCount: INT ← 0;
RectangleCount: INT ← 0;
CircuitNodeCount: INT ← 0;
AreaPerimRecCount: INT ← 0;
NodeLinkageCount: INT ← 0;
AttachedNodeCount: INT ← 0;
MergeRecCount: INT ← 0;
TessCount: INT ← 0;
TileCount: INT ← 0;
ApplRecCount: INT ← 0;
ApplListCount: INT ← 0;
TRUSTED { SweepCollectableStorage.EnumerateCollectableStorage[perObject] };
cmd.out.PutF["CircuitCount = %g\n", IO.int[CircuitCount]];
cmd.out.PutF["QuadTreeCount = %g\n", IO.int[QuadTreeCount]];
cmd.out.PutF["RectangleCount = %g\n", IO.int[RectangleCount]];
cmd.out.PutF["CircuitNodeCount = %g\n", IO.int[CircuitNodeCount]];
cmd.out.PutF["AreaPerimRecCount = %g\n", IO.int[AreaPerimRecCount]];
cmd.out.PutF["NodeLinkageCount = %g\n", IO.int[NodeLinkageCount]];
cmd.out.PutF["AttachedNodeCount = %g\n", IO.int[AttachedNodeCount]];
cmd.out.PutF["MergeRecCount = %g\n", IO.int[MergeRecCount]];
cmd.out.PutF["TessCount = %g\n", IO.int[TessCount]];
cmd.out.PutF["TileCount = %g\n", IO.int[TileCount]];
cmd.out.PutF["ApplRecCount = %g\n", IO.int[ApplRecCount]];
cmd.out.PutF["ApplListCount = %g\n", IO.int[ApplListCount]];
};
Init: PROCEDURE ~ {
appl: CD.Instance ← NEW[CD.InstanceRep];
APList ← SafeStorage.GetCanonicalReferentType[ NARROW[ LIST[ SX.AreaPerimRec[0,0,0]], LIST OF SX.AreaPerimRec]];
MRList ← SafeStorage.GetCanonicalReferentType[ NARROW[ LIST[ SX.MergeRec[]], LIST OF SX.MergeRec]];
CSTile ← SafeStorage.GetCanonicalReferentType[ CornerStitching.NewTesselation[].TileAt[[0,0]] ];
ApplList ← SafeStorage.GetCanonicalReferentType[ NARROW[ LIST[ appl], LIST OF CD.Instance] ];
};
APList: SafeStorage.Type;
MRList: SafeStorage.Type;
CSTile: SafeStorage.Type;
ApplList: SafeStorage.Type;
Init[];
Commander.Register[key: "SpinifexCount", proc: Count,
doc: "SpinifexCount"];
END.