-- SpinifexCount.mesa
-- Written by: Shand, July 2, 1984 1:23:16 pm PDT
-- Last Edited by: Shand, July 28, 1984 10:57:05 pm PDT
DIRECTORY
CD USING [ApplicationPtr, Application],
Commander USING [CommandProc, Handle, Register],
IO USING [PutF, int],
SweepCollectableStorage USING [InfoProc, EnumerateCollectableStorage],
SafeStorage USING [Type, GetCanonicalReferentType],
SpinifexCircuit USING [Circuit, QuadTree, Rectangle, CircuitNode, AreaPerimRec, NodeLinkage, AttachedNode, MergeRec],
CornerStitching USING [Tesselation, NewTesselation, TileAt]
;
SpinifexCount: CEDAR PROGRAM
IMPORTS Commander, IO, SweepCollectableStorage, SafeStorage, CornerStitching
~ 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[SpinifexCircuit.Circuit]
THEN
CircuitCount ← CircuitCount + 1
ELSE
IF type =
CODE[SpinifexCircuit.QuadTree]
THEN
QuadTreeCount ← QuadTreeCount + 1
ELSE
IF type =
CODE[SpinifexCircuit.Rectangle]
THEN
RectangleCount ← RectangleCount + 1
ELSE
IF type =
CODE[SpinifexCircuit.CircuitNode]
THEN
CircuitNodeCount ← CircuitNodeCount + 1
ELSE
IF type = APList
THEN
AreaPerimRecCount ← AreaPerimRecCount + 1
ELSE
IF type =
CODE[SpinifexCircuit.NodeLinkage]
THEN
NodeLinkageCount ← NodeLinkageCount + 1
ELSE
IF type =
CODE[SpinifexCircuit.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.Application]
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.ApplicationPtr ← NEW[CD.Application];
APList ← SafeStorage.GetCanonicalReferentType[ NARROW[ LIST[ SpinifexCircuit.AreaPerimRec[0,0,0]], LIST OF SpinifexCircuit.AreaPerimRec]];
MRList ← SafeStorage.GetCanonicalReferentType[ NARROW[ LIST[ SpinifexCircuit.MergeRec[]], LIST OF SpinifexCircuit.MergeRec]];
CSTile ← SafeStorage.GetCanonicalReferentType[ CornerStitching.NewTesselation[].TileAt[[0,0]] ];
ApplList ← SafeStorage.GetCanonicalReferentType[ NARROW[ LIST[ appl], LIST OF CD.ApplicationPtr] ];
};
APList: SafeStorage.Type;
MRList: SafeStorage.Type;
CSTile: SafeStorage.Type;
ApplList: SafeStorage.Type;
Init[];
Commander.Register[key: "SpinifexCount", proc: Count,
doc: "SpinifexCount"];
END.