-- RCT.Mesa
-- Last Edited by: Willie-Sue, December 10, 1982 11:48 am
-- Last Edited by: Paul Rovner, December 10, 1982 3:02 pm


DIRECTORY
RefCounts,
RTRefCounts USING[RefCt];

RCT: PROGRAM
 IMPORTS RefCounts
= BEGIN

totalEntries: INT ← 0;
entriesMarked: INT ← 0;
overMax: INT ← 0;
pinned: INT ← 0;
maxCount: NAT = 100;
entryCountArray: ARRAY[0..maxCount] OF NAT ← ALL[0];

proc: PROC[ref: REF ANY, count: NAT, markedAsOnStack: BOOL]
RETURNS[stop: BOOL ← FALSE] =
{totalEntries ← totalEntries + 1;
IF count < 0 THEN ERROR;
IF markedAsOnStack THEN entriesMarked ← entriesMarked + 1;
IF count <= maxCount
THEN entryCountArray[count] ← entryCountArray[count] + 1
ELSE {overMax ← overMax + 1;
IF count = LAST[RTRefCounts.RefCt] THEN pinned ← pinned + 1};
};

DoIt: PROC =
{totalEntries ← 0;
entriesMarked ← 0;
overMax ← 0;
pinned ← 0;

FOR i: NAT IN [0..maxCount] DO entryCountArray[i] ← 0; ENDLOOP;

[] ← RefCounts.Enumerate[proc];
};

END.