/*************************************************** NAME : PrintSlotSources DESCRIPTION : Displays a list of source classes for a composite class (in order of most general to specific) INPUTS : 1) The logical name of the output 2) The name of the slot 3) The precedence list of the class of the slot (the source class shold be first in the list) 4) The index into the packed links array 5) Flag indicating whether to disregard noniherit facet RETURNS : TRUE if a class is printed, FALSE otherwise SIDE EFFECTS : Recursively prints out appropriate memebers from list in reverse order NOTES : None ***************************************************/ static intBool PrintSlotSources( void *theEnv, char *logicalName, SYMBOL_HN *sname, PACKED_CLASS_LINKS *sprec, long theIndex, int inhp) { SLOT_DESC *csp; if (theIndex == sprec->classCount) return(FALSE); csp = FindClassSlot(sprec->classArray[theIndex],sname); if ((csp != NULL) ? ((csp->noInherit == 0) || inhp) : FALSE) { if (csp->composite) { if (PrintSlotSources(theEnv,logicalName,sname,sprec,theIndex+1,FALSE)) EnvPrintRouter(theEnv,logicalName," "); } PrintClassName(theEnv,logicalName,sprec->classArray[theIndex],FALSE); return(TRUE); } else return(PrintSlotSources(theEnv,logicalName,sname,sprec,theIndex+1,FALSE)); }
/*************************************************** NAME : PrintSlotSources DESCRIPTION : Displays a list of source classes for a composite class (in order of most general to specific) INPUTS : 1) The logical name of the output 2) The name of the slot 3) The precedence list of the class of the slot (the source class shold be first in the list) 4) The index into the packed links array 5) Flag indicating whether to disregard noniherit facet RETURNS : True if a class is printed, false otherwise SIDE EFFECTS : Recursively prints out appropriate memebers from list in reverse order NOTES : None ***************************************************/ static bool PrintSlotSources( Environment *theEnv, const char *logicalName, CLIPSLexeme *sname, PACKED_CLASS_LINKS *sprec, unsigned long theIndex, bool inhp) { SlotDescriptor *csp; if (theIndex == sprec->classCount) return false; csp = FindClassSlot(sprec->classArray[theIndex],sname); if ((csp != NULL) ? ((csp->noInherit == 0) || inhp) : false) { if (csp->composite) { if (PrintSlotSources(theEnv,logicalName,sname,sprec,theIndex+1,false)) WriteString(theEnv,logicalName," "); } PrintClassName(theEnv,logicalName,sprec->classArray[theIndex],false,false); return true; } else return(PrintSlotSources(theEnv,logicalName,sname,sprec,theIndex+1,false)); }
globle void EnvSlotSources( void *theEnv, void *clsptr, const char *sname, DATA_OBJECT *result) { register unsigned i; register int classi; register SLOT_DESC *sp,*csp; CLASS_LINK *ctop,*ctmp; DEFCLASS *cls; if ((sp = SlotInfoSlot(theEnv,result,(DEFCLASS *) clsptr,sname,"slot-sources")) == NULL) return; i = 1; ctop = get_struct(theEnv,classLink); ctop->cls = sp->cls; ctop->nxt = NULL; if (sp->composite) { for (classi = 1 ; classi < sp->cls->allSuperclasses.classCount ; classi++) { cls = sp->cls->allSuperclasses.classArray[classi]; csp = FindClassSlot(cls,sp->slotName->name); if ((csp != NULL) ? (csp->noInherit == 0) : FALSE) { ctmp = get_struct(theEnv,classLink); ctmp->cls = cls; ctmp->nxt = ctop; ctop = ctmp; i++; if (csp->composite == 0) break; } } } SetpDOEnd(result,i); result->value = (void *) EnvCreateMultifield(theEnv,i); for (ctmp = ctop , i = 1 ; ctmp != NULL ; ctmp = ctmp->nxt , i++) { SetMFType(result->value,i,SYMBOL); SetMFValue(result->value,i,GetDefclassNamePointer((void *) ctmp->cls)); } DeleteClassLinks(theEnv,ctop); }
/************************************************************************** NAME : BuildCompositeFacets DESCRIPTION : Composite slots are ones that get their facets from more than one class. By default, the most specific class in object's precedence list specifies the complete set of facets for a slot. The composite facet in a slot allows facets that are not overridden by the most specific class to be obtained from other classes. Since all superclasses are predetermined before creating a new class based on them, this routine need only examine the immediately next most specific class for extra facets. Even if that slot is also composite, the other facets have already been filtered down. If the slot is no-inherit, the next most specific class must be examined. INPUTS : 1) The slot descriptor 2) The class precedence list 3) The bitmap marking which facets were specified in the original slot definition RETURNS : Nothing useful SIDE EFFECTS : Composite slot is updated to reflect facets from a less specific class NOTES : Assumes slot is composite *************************************************************************/ static void BuildCompositeFacets( void *theEnv, EXEC_STATUS, SLOT_DESC *sd, PACKED_CLASS_LINKS *preclist, char *specbits, CONSTRAINT_PARSE_RECORD *parsedConstraint) { SLOT_DESC *compslot = NULL; long i; for (i = 1 ; i < preclist->classCount ; i++) { compslot = FindClassSlot(preclist->classArray[i],sd->slotName->name); if ((compslot != NULL) ? (compslot->noInherit == 0) : FALSE) break; } if (compslot != NULL) { if ((sd->defaultSpecified == 0) && (compslot->defaultSpecified == 1)) { sd->dynamicDefault = compslot->dynamicDefault; sd->noDefault = compslot->noDefault; sd->defaultSpecified = 1; if (compslot->defaultValue != NULL) { if (sd->dynamicDefault) { sd->defaultValue = (void *) PackExpression(theEnv,execStatus,(EXPRESSION *) compslot->defaultValue); ExpressionInstall(theEnv,execStatus,(EXPRESSION *) sd->defaultValue); } else { sd->defaultValue = (void *) get_struct(theEnv,execStatus,dataObject); GenCopyMemory(DATA_OBJECT,1,sd->defaultValue,compslot->defaultValue); ValueInstall(theEnv,execStatus,(DATA_OBJECT *) sd->defaultValue); } } } if (TestBitMap(specbits,FIELD_BIT) == 0) sd->multiple = compslot->multiple; if (TestBitMap(specbits,STORAGE_BIT) == 0) sd->shared = compslot->shared; if (TestBitMap(specbits,ACCESS_BIT) == 0) { sd->noWrite = compslot->noWrite; sd->initializeOnly = compslot->initializeOnly; } #if DEFRULE_CONSTRUCT if (TestBitMap(specbits,MATCH_BIT) == 0) sd->reactive = compslot->reactive; #endif if (TestBitMap(specbits,VISIBILITY_BIT) == 0) sd->publicVisibility = compslot->publicVisibility; if (TestBitMap(specbits,CREATE_ACCESSOR_BIT) == 0) { sd->createReadAccessor = compslot->createReadAccessor; sd->createWriteAccessor = compslot->createWriteAccessor; } if ((TestBitMap(specbits,OVERRIDE_MSG_BIT) == 0) && compslot->overrideMessageSpecified) { DecrementSymbolCount(theEnv,execStatus,sd->overrideMessage); sd->overrideMessage = compslot->overrideMessage; IncrementSymbolCount(sd->overrideMessage); sd->overrideMessageSpecified = TRUE; } OverlayConstraint(theEnv,execStatus,parsedConstraint,sd->constraint,compslot->constraint); } }
/************************************************************************** NAME : BuildCompositeFacets DESCRIPTION : Composite slots are ones that get their facets from more than one class. By default, the most specific class in object's precedence list specifies the complete set of facets for a slot. The composite facet in a slot allows facets that are not overridden by the most specific class to be obtained from other classes. Since all superclasses are predetermined before creating a new class based on them, this routine need only examine the immediately next most specific class for extra facets. Even if that slot is also composite, the other facets have already been filtered down. If the slot is no-inherit, the next most specific class must be examined. INPUTS : 1) The slot descriptor 2) The class precedence list 3) The bitmap marking which facets were specified in the original slot definition RETURNS : Nothing useful SIDE EFFECTS : Composite slot is updated to reflect facets from a less specific class NOTES : Assumes slot is composite *************************************************************************/ static void BuildCompositeFacets( Environment *theEnv, SlotDescriptor *sd, PACKED_CLASS_LINKS *preclist, const char *specbits, CONSTRAINT_PARSE_RECORD *parsedConstraint) { SlotDescriptor *compslot = NULL; unsigned long i; for (i = 1 ; i < preclist->classCount ; i++) { compslot = FindClassSlot(preclist->classArray[i],sd->slotName->name); if ((compslot != NULL) ? (compslot->noInherit == 0) : false) break; } if (compslot != NULL) { if ((sd->defaultSpecified == 0) && (compslot->defaultSpecified == 1)) { sd->dynamicDefault = compslot->dynamicDefault; sd->noDefault = compslot->noDefault; sd->defaultSpecified = 1; if (compslot->defaultValue != NULL) { if (sd->dynamicDefault) { sd->defaultValue = PackExpression(theEnv,(Expression *) compslot->defaultValue); ExpressionInstall(theEnv,(Expression *) sd->defaultValue); } else { sd->defaultValue = get_struct(theEnv,udfValue); GenCopyMemory(UDFValue,1,sd->defaultValue,compslot->defaultValue); RetainUDFV(theEnv,(UDFValue *) sd->defaultValue); } } } if (! TestBitMap(specbits,FIELD_BIT)) sd->multiple = compslot->multiple; if (! TestBitMap(specbits,STORAGE_BIT)) sd->shared = compslot->shared; if (! TestBitMap(specbits,ACCESS_BIT)) { sd->noWrite = compslot->noWrite; sd->initializeOnly = compslot->initializeOnly; } #if DEFRULE_CONSTRUCT if (! TestBitMap(specbits,MATCH_BIT)) sd->reactive = compslot->reactive; #endif if (! TestBitMap(specbits,VISIBILITY_BIT)) sd->publicVisibility = compslot->publicVisibility; if (! TestBitMap(specbits,CREATE_ACCESSOR_BIT)) { sd->createReadAccessor = compslot->createReadAccessor; sd->createWriteAccessor = compslot->createWriteAccessor; } if ((! TestBitMap(specbits,OVERRIDE_MSG_BIT)) && compslot->overrideMessageSpecified) { ReleaseLexeme(theEnv,sd->overrideMessage); sd->overrideMessage = compslot->overrideMessage; IncrementLexemeCount(sd->overrideMessage); sd->overrideMessageSpecified = true; } OverlayConstraint(theEnv,parsedConstraint,sd->constraint,compslot->constraint); } }