Bool PoolClassCheck(PoolClass klass) { CHECKD(InstClass, &klass->protocol); CHECKL(klass->size >= sizeof(PoolStruct)); CHECKL(AttrCheck(klass->attr)); CHECKL(!(klass->attr & AttrMOVINGGC) || (klass->attr & AttrGC)); CHECKL(FUNCHECK(klass->varargs)); CHECKL(FUNCHECK(klass->init)); CHECKL(FUNCHECK(klass->finish)); CHECKL(FUNCHECK(klass->alloc)); CHECKL(FUNCHECK(klass->free)); CHECKL(FUNCHECK(klass->bufferFill)); CHECKL(FUNCHECK(klass->bufferEmpty)); CHECKL(FUNCHECK(klass->access)); CHECKL(FUNCHECK(klass->whiten)); CHECKL(FUNCHECK(klass->grey)); CHECKL(FUNCHECK(klass->blacken)); CHECKL(FUNCHECK(klass->scan)); CHECKL(FUNCHECK(klass->fix)); CHECKL(FUNCHECK(klass->fixEmergency)); CHECKL(FUNCHECK(klass->reclaim)); CHECKL(FUNCHECK(klass->traceEnd)); CHECKL(FUNCHECK(klass->rampBegin)); CHECKL(FUNCHECK(klass->rampEnd)); CHECKL(FUNCHECK(klass->framePush)); CHECKL(FUNCHECK(klass->framePop)); CHECKL(FUNCHECK(klass->addrObject)); CHECKL(FUNCHECK(klass->walk)); CHECKL(FUNCHECK(klass->freewalk)); CHECKL(FUNCHECK(klass->bufferClass)); CHECKL(FUNCHECK(klass->describe)); CHECKL(FUNCHECK(klass->debugMixin)); CHECKL(FUNCHECK(klass->totalSize)); CHECKL(FUNCHECK(klass->freeSize)); /* Check that pool classes overide sets of related methods. */ CHECKL((klass->init == PoolAbsInit) == (klass->finish == PoolAbsFinish)); CHECKL((klass->bufferFill == PoolNoBufferFill) == (klass->bufferEmpty == PoolNoBufferEmpty)); CHECKL((klass->framePush == PoolNoFramePush) == (klass->framePop == PoolNoFramePop)); CHECKL((klass->rampBegin == PoolNoRampBegin) == (klass->rampEnd == PoolNoRampEnd)); /* Check that pool classes that set attributes also override the methods they imply. */ /* .check.ams.walk: Can't enforce this one until job003738 is resolved. */ /* CHECKL(((klass->attr & AttrFMT) == 0) == (klass->walk == PoolNoWalk)); */ if (klass != &CLASS_STATIC(AbstractCollectPool)) { CHECKL(((klass->attr & AttrGC) == 0) == (klass->fix == PoolNoFix)); CHECKL(((klass->attr & AttrGC) == 0) == (klass->fixEmergency == PoolNoFix)); CHECKL(((klass->attr & AttrGC) == 0) == (klass->reclaim == PoolNoReclaim)); } CHECKS(PoolClass, klass); return TRUE; }
DEFINE_CLASS(Inst, InstClass, klass) { /* Can't use INHERIT_CLASS(klass, InstClass, Inst) here because it causes infinite regression, so we have to set this one up by hand. */ InstClassInitInternal(klass); klass->superclass = &CLASS_STATIC(Inst); klass->name = "InstClass"; klass->level = ClassLevelInstClass; klass->display[ClassLevelInstClass] = CLASS_ID(InstClass); AVERT(InstClass, klass); }
static void InstClassInitInternal(InstClass klass) { ClassLevel i; klass->name = "Inst"; klass->superclass = NULL; for (i = 0; i < ClassDEPTH; ++i) klass->display[i] = NULL; klass->level = 0; klass->display[klass->level] = CLASS_ID(Inst); /* Generic methods */ klass->describe = InstDescribe; klass->finish = InstFinish; klass->init = InstInit; /* We can't call CLASS(InstClass) here because it causes a loop back to here, so we have to tie this knot specially. */ klass->instStruct.klass = &CLASS_STATIC(InstClass); klass->sig = InstClassSig; AVERT(InstClass, klass); }