mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-17 01:34:21 +00:00
Turning segment describe methods the right way in, so that they call next-method. deleting duplicate implementation of basic segment describe!
Copied from Perforce Change: 191588 ServerID: perforce.ravenbrook.com
This commit is contained in:
parent
b765128003
commit
0ea36ccf02
4 changed files with 59 additions and 112 deletions
|
|
@ -669,6 +669,7 @@ extern void SegSetRankSet(Seg seg, RankSet rankSet);
|
|||
extern void SegSetRankAndSummary(Seg seg, RankSet rankSet, RefSet summary);
|
||||
extern Res SegMerge(Seg *mergedSegReturn, Seg segLo, Seg segHi);
|
||||
extern Res SegSplit(Seg *segLoReturn, Seg *segHiReturn, Seg seg, Addr at);
|
||||
extern Res SegAbsDescribe(Seg seg, mps_lib_FILE *stream, Count depth);
|
||||
extern Res SegDescribe(Seg seg, mps_lib_FILE *stream, Count depth);
|
||||
extern void SegSetSummary(Seg seg, RefSet summary);
|
||||
extern Buffer SegBuffer(Seg seg);
|
||||
|
|
|
|||
|
|
@ -236,22 +236,22 @@ static void AMCSegSketch(Seg seg, char *pbSketch, size_t cbSketch)
|
|||
*/
|
||||
static Res AMCSegDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
amcSeg amcseg = CouldBeA(amcSeg, seg);
|
||||
Res res;
|
||||
Pool pool;
|
||||
Addr i, p, base, limit, init;
|
||||
Align step;
|
||||
Size row;
|
||||
char abzSketch[5];
|
||||
|
||||
if(!TESTC(amcSeg, amcseg))
|
||||
if (!TESTC(amcSeg, amcseg))
|
||||
return ResPARAM;
|
||||
if(stream == NULL)
|
||||
if (stream == NULL)
|
||||
return ResPARAM;
|
||||
|
||||
/* Describe the superclass fields first via next-method call */
|
||||
res = NextMethod(Seg, amcSeg, describe)(seg, stream, depth);
|
||||
if(res != ResOK)
|
||||
if (res != ResOK)
|
||||
return res;
|
||||
|
||||
pool = SegPool(seg);
|
||||
|
|
@ -262,16 +262,9 @@ static Res AMCSegDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
|
|||
p = AddrAdd(base, pool->format->headerSize);
|
||||
limit = SegLimit(seg);
|
||||
|
||||
res = WriteF(stream, depth,
|
||||
"AMC seg $P [$A,$A){\n",
|
||||
(WriteFP)seg, (WriteFA)base, (WriteFA)limit,
|
||||
NULL);
|
||||
if(res != ResOK)
|
||||
return res;
|
||||
|
||||
if(amcSegHasNailboard(seg)) {
|
||||
if (amcSegHasNailboard(seg)) {
|
||||
res = WriteF(stream, depth + 2, "Boarded\n", NULL);
|
||||
} else if(SegNailed(seg) == TraceSetEMPTY) {
|
||||
} else if (SegNailed(seg) == TraceSetEMPTY) {
|
||||
res = WriteF(stream, depth + 2, "Mobile\n", NULL);
|
||||
} else {
|
||||
res = WriteF(stream, depth + 2, "Stuck\n", NULL);
|
||||
|
|
@ -281,32 +274,32 @@ static Res AMCSegDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
|
|||
|
||||
res = WriteF(stream, depth + 2,
|
||||
"Map: *===:object @+++:nails bbbb:buffer\n", NULL);
|
||||
if(res != ResOK)
|
||||
if (res != ResOK)
|
||||
return res;
|
||||
|
||||
if(SegBuffer(seg) != NULL)
|
||||
if (SegBuffer(seg) != NULL)
|
||||
init = BufferGetInit(SegBuffer(seg));
|
||||
else
|
||||
init = limit;
|
||||
|
||||
for(i = base; i < limit; i = AddrAdd(i, row)) {
|
||||
for (i = base; i < limit; i = AddrAdd(i, row)) {
|
||||
Addr j;
|
||||
char c;
|
||||
|
||||
res = WriteF(stream, depth + 2, "$A ", (WriteFA)i, NULL);
|
||||
if(res != ResOK)
|
||||
if (res != ResOK)
|
||||
return res;
|
||||
|
||||
/* @@@@ This misses a header-sized pad at the end. */
|
||||
for(j = i; j < AddrAdd(i, row); j = AddrAdd(j, step)) {
|
||||
if(j >= limit)
|
||||
for (j = i; j < AddrAdd(i, row); j = AddrAdd(j, step)) {
|
||||
if (j >= limit)
|
||||
c = ' '; /* if seg is not a whole number of print rows */
|
||||
else if(j >= init)
|
||||
else if (j >= init)
|
||||
c = 'b';
|
||||
else {
|
||||
Bool nailed = amcSegHasNailboard(seg)
|
||||
&& NailboardGet(amcSegNailboard(seg), j);
|
||||
if(j == p) {
|
||||
if (j == p) {
|
||||
c = (nailed ? '@' : '*');
|
||||
p = (pool->format->skip)(p);
|
||||
} else {
|
||||
|
|
@ -314,12 +307,12 @@ static Res AMCSegDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
|
|||
}
|
||||
}
|
||||
res = WriteF(stream, 0, "$C", (WriteFC)c, NULL);
|
||||
if(res != ResOK)
|
||||
if (res != ResOK)
|
||||
return res;
|
||||
}
|
||||
|
||||
res = WriteF(stream, 0, "\n", NULL);
|
||||
if(res != ResOK)
|
||||
if (res != ResOK)
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
@ -328,10 +321,6 @@ static Res AMCSegDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
|
|||
if(res != ResOK)
|
||||
return res;
|
||||
|
||||
res = WriteF(stream, depth, "} AMC Seg $P\n", (WriteFP)seg, NULL);
|
||||
if(res != ResOK)
|
||||
return res;
|
||||
|
||||
return ResOK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -525,18 +525,15 @@ static Res AMSSegSplit(Seg seg, Seg segHi,
|
|||
|
||||
static Res AMSSegDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
AMSSeg amsseg = CouldBeA(AMSSeg, seg);
|
||||
Res res;
|
||||
AMSSeg amsseg;
|
||||
Buffer buffer; /* the segment's buffer, if it has one */
|
||||
Index i;
|
||||
|
||||
if (!TESTT(Seg, seg))
|
||||
return ResFAIL;
|
||||
if (!TESTC(AMSSeg, amsseg))
|
||||
return ResPARAM;
|
||||
if (stream == NULL)
|
||||
return ResFAIL;
|
||||
amsseg = Seg2AMSSeg(seg);
|
||||
if (!TESTT(AMSSeg, amsseg))
|
||||
return ResFAIL;
|
||||
return ResPARAM;
|
||||
|
||||
/* Describe the superclass fields first via next-method call */
|
||||
res = NextMethod(Seg, AMSSeg, describe)(seg, stream, depth);
|
||||
|
|
@ -545,13 +542,13 @@ static Res AMSSegDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
|
|||
|
||||
buffer = SegBuffer(seg);
|
||||
|
||||
res = WriteF(stream, depth,
|
||||
" AMS $P\n", (WriteFP)amsseg->ams,
|
||||
" grains $W\n", (WriteFW)amsseg->grains,
|
||||
" freeGrains $W\n", (WriteFW)amsseg->freeGrains,
|
||||
" buffferedGrains $W\n", (WriteFW)amsseg->bufferedGrains,
|
||||
" newGrains $W\n", (WriteFW)amsseg->newGrains,
|
||||
" oldGrains $W\n", (WriteFW)amsseg->oldGrains,
|
||||
res = WriteF(stream, depth + 2,
|
||||
"AMS $P\n", (WriteFP)amsseg->ams,
|
||||
"grains $W\n", (WriteFW)amsseg->grains,
|
||||
"freeGrains $W\n", (WriteFW)amsseg->freeGrains,
|
||||
"buffferedGrains $W\n", (WriteFW)amsseg->bufferedGrains,
|
||||
"newGrains $W\n", (WriteFW)amsseg->newGrains,
|
||||
"oldGrains $W\n", (WriteFW)amsseg->oldGrains,
|
||||
NULL);
|
||||
if (res != ResOK)
|
||||
return res;
|
||||
|
|
|
|||
102
mps/code/seg.c
102
mps/code/seg.c
|
|
@ -375,61 +375,57 @@ Addr SegBufferScanLimit(Seg seg)
|
|||
|
||||
/* SegDescribe -- describe a segment */
|
||||
|
||||
Res SegDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
|
||||
Res SegAbsDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
Pool pool;
|
||||
SegClass klass;
|
||||
|
||||
if (!TESTC(Seg, seg))
|
||||
return ResPARAM;
|
||||
if (stream == NULL)
|
||||
return ResPARAM;
|
||||
|
||||
pool = SegPool(seg);
|
||||
klass = ClassOfPoly(Seg, seg);
|
||||
res = InstDescribe(CouldBeA(Inst, seg), stream, depth);
|
||||
if (res != ResOK)
|
||||
return res;
|
||||
|
||||
res = WriteF(stream, depth,
|
||||
"Segment $P [$A,$A) {\n", (WriteFP)seg,
|
||||
(WriteFA)SegBase(seg), (WriteFA)SegLimit(seg),
|
||||
" class $P (\"$S\")\n",
|
||||
(WriteFP)klass, (WriteFS)ClassName(klass),
|
||||
" pool $P ($U)\n",
|
||||
(WriteFP)pool, (WriteFU)pool->serial,
|
||||
" depth $U\n", seg->depth,
|
||||
" pm",
|
||||
pool = SegPool(seg);
|
||||
|
||||
res = WriteF(stream, depth + 2,
|
||||
"base $A\n", (WriteFA)SegBase(seg),
|
||||
"limit $A\n", (WriteFA)SegLimit(seg),
|
||||
"pool $P ($U)\n", (WriteFP)pool, (WriteFU)pool->serial,
|
||||
"depth $U\n", seg->depth,
|
||||
"pm",
|
||||
seg->pm == AccessSetEMPTY ? " EMPTY" : "",
|
||||
seg->pm & AccessREAD ? " READ" : "",
|
||||
seg->pm & AccessWRITE ? " WRITE" : "",
|
||||
"\n",
|
||||
" sm",
|
||||
"sm",
|
||||
seg->sm == AccessSetEMPTY ? " EMPTY" : "",
|
||||
seg->sm & AccessREAD ? " READ" : "",
|
||||
seg->sm & AccessWRITE ? " WRITE" : "",
|
||||
"\n",
|
||||
" grey $B\n", (WriteFB)seg->grey,
|
||||
" white $B\n", (WriteFB)seg->white,
|
||||
" nailed $B\n", (WriteFB)seg->nailed,
|
||||
" rankSet",
|
||||
"grey $B\n", (WriteFB)seg->grey,
|
||||
"white $B\n", (WriteFB)seg->white,
|
||||
"nailed $B\n", (WriteFB)seg->nailed,
|
||||
"rankSet",
|
||||
seg->rankSet == RankSetEMPTY ? " EMPTY" : "",
|
||||
BS_IS_MEMBER(seg->rankSet, RankAMBIG) ? " AMBIG" : "",
|
||||
BS_IS_MEMBER(seg->rankSet, RankEXACT) ? " EXACT" : "",
|
||||
BS_IS_MEMBER(seg->rankSet, RankFINAL) ? " FINAL" : "",
|
||||
BS_IS_MEMBER(seg->rankSet, RankWEAK) ? " WEAK" : "",
|
||||
"\n",
|
||||
NULL);
|
||||
if (res != ResOK)
|
||||
return res;
|
||||
|
||||
res = Method(Seg, seg, describe)(seg, stream, depth + 2);
|
||||
if (res != ResOK)
|
||||
return res;
|
||||
return ResOK;
|
||||
}
|
||||
|
||||
res = WriteF(stream, 0, "\n", NULL);
|
||||
if (res != ResOK)
|
||||
return res;
|
||||
|
||||
res = WriteF(stream, depth, "} Segment $P\n", (WriteFP)seg, NULL);
|
||||
return res;
|
||||
Res SegDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
return Method(Seg, seg, describe)(seg, stream, depth);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1011,39 +1007,6 @@ static Res segTrivSplit(Seg seg, Seg segHi,
|
|||
}
|
||||
|
||||
|
||||
/* segTrivDescribe -- Basic Seg description method */
|
||||
|
||||
static Res segTrivDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
Res res;
|
||||
|
||||
if (!TESTT(Seg, seg))
|
||||
return ResFAIL;
|
||||
if (stream == NULL)
|
||||
return ResFAIL;
|
||||
|
||||
res = WriteF(stream, depth,
|
||||
"shield depth $U\n", (WriteFU)seg->depth,
|
||||
"protection mode: ",
|
||||
(SegPM(seg) & AccessREAD) ? "" : "!", "READ", " ",
|
||||
(SegPM(seg) & AccessWRITE) ? "" : "!", "WRITE", "\n",
|
||||
"shield mode: ",
|
||||
(SegSM(seg) & AccessREAD) ? "" : "!", "READ", " ",
|
||||
(SegSM(seg) & AccessWRITE) ? "" : "!", "WRITE", "\n",
|
||||
"ranks:",
|
||||
RankSetIsMember(seg->rankSet, RankAMBIG) ? " ambiguous" : "",
|
||||
RankSetIsMember(seg->rankSet, RankEXACT) ? " exact" : "",
|
||||
RankSetIsMember(seg->rankSet, RankFINAL) ? " final" : "",
|
||||
RankSetIsMember(seg->rankSet, RankWEAK) ? " weak" : "",
|
||||
"\n",
|
||||
"white $B\n", (WriteFB)seg->white,
|
||||
"grey $B\n", (WriteFB)seg->grey,
|
||||
"nailed $B\n", (WriteFB)seg->nailed,
|
||||
NULL);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/* Class GCSeg -- Segment class with GC support
|
||||
*/
|
||||
|
||||
|
|
@ -1553,32 +1516,29 @@ static Res gcSegSplit(Seg seg, Seg segHi,
|
|||
|
||||
static Res gcSegDescribe(Seg seg, mps_lib_FILE *stream, Count depth)
|
||||
{
|
||||
GCSeg gcseg = CouldBeA(GCSeg, seg);
|
||||
Res res;
|
||||
GCSeg gcseg;
|
||||
|
||||
if (!TESTT(Seg, seg))
|
||||
return ResFAIL;
|
||||
if (!TESTC(GCSeg, gcseg))
|
||||
return ResPARAM;
|
||||
if (stream == NULL)
|
||||
return ResFAIL;
|
||||
gcseg = SegGCSeg(seg);
|
||||
if (!TESTT(GCSeg, gcseg))
|
||||
return ResFAIL;
|
||||
return ResPARAM;
|
||||
|
||||
/* Describe the superclass fields first via next-method call */
|
||||
res = NextMethod(Seg, GCSeg, describe)(seg, stream, depth);
|
||||
if (res != ResOK)
|
||||
return res;
|
||||
|
||||
res = WriteF(stream, depth,
|
||||
res = WriteF(stream, depth + 2,
|
||||
"summary $W\n", (WriteFW)gcseg->summary,
|
||||
NULL);
|
||||
if (res != ResOK)
|
||||
return res;
|
||||
|
||||
if (gcseg->buffer == NULL) {
|
||||
res = WriteF(stream, depth, "buffer: NULL\n", NULL);
|
||||
res = WriteF(stream, depth + 2, "buffer: NULL\n", NULL);
|
||||
} else {
|
||||
res = BufferDescribe(gcseg->buffer, stream, depth);
|
||||
res = BufferDescribe(gcseg->buffer, stream, depth + 2);
|
||||
}
|
||||
if (res != ResOK)
|
||||
return res;
|
||||
|
|
@ -1629,7 +1589,7 @@ DEFINE_CLASS(Seg, Seg, klass)
|
|||
klass->setRankSummary = segNoSetRankSummary;
|
||||
klass->merge = segTrivMerge;
|
||||
klass->split = segTrivSplit;
|
||||
klass->describe = segTrivDescribe;
|
||||
klass->describe = SegAbsDescribe;
|
||||
klass->sig = SegClassSig;
|
||||
AVERT(SegClass, klass);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue