/************************************************************** NAME : NewSlot DESCRIPTION : Allocates and initalizes a new slot structure INPUTS : The symbolic name of the new slot RETURNS : The address of the new slot SIDE EFFECTS : None NOTES : Also adds symbols of the form get-<name> and put-<name> for slot accessors **************************************************************/ static SLOT_DESC *NewSlot( void *theEnv, EXEC_STATUS, SYMBOL_HN *name) { SLOT_DESC *slot; slot = get_struct(theEnv,execStatus,slotDescriptor); slot->dynamicDefault = 1; slot->defaultSpecified = 0; slot->noDefault = 0; #if DEFRULE_CONSTRUCT slot->reactive = 1; #endif slot->noInherit = 0; slot->noWrite = 0; slot->initializeOnly = 0; slot->shared = 0; slot->multiple = 0; slot->composite = 0; slot->sharedCount = 0; slot->publicVisibility = 0; slot->createReadAccessor = FALSE; slot->createWriteAccessor = FALSE; slot->overrideMessageSpecified = 0; slot->cls = NULL; slot->defaultValue = NULL; slot->constraint = GetConstraintRecord(theEnv,execStatus); slot->slotName = AddSlotName(theEnv,execStatus,name,0,FALSE); slot->overrideMessage = slot->slotName->putHandlerName; IncrementSymbolCount(slot->overrideMessage); return(slot); }
/************************************************************** NAME : NewSlot DESCRIPTION : Allocates and initalizes a new slot structure INPUTS : The symbolic name of the new slot RETURNS : The address of the new slot SIDE EFFECTS : None NOTES : Also adds symbols of the form get-<name> and put-<name> for slot accessors **************************************************************/ static SlotDescriptor *NewSlot( Environment *theEnv, CLIPSLexeme *name) { SlotDescriptor *slot; slot = get_struct(theEnv,slotDescriptor); slot->dynamicDefault = 1; slot->defaultSpecified = 0; slot->noDefault = 0; #if DEFRULE_CONSTRUCT slot->reactive = 1; #endif slot->noInherit = 0; slot->noWrite = 0; slot->initializeOnly = 0; slot->shared = 0; slot->multiple = 0; slot->composite = 0; slot->sharedCount = 0; slot->publicVisibility = 0; slot->createReadAccessor = false; slot->createWriteAccessor = false; slot->overrideMessageSpecified = 0; slot->cls = NULL; slot->defaultValue = NULL; slot->constraint = GetConstraintRecord(theEnv); slot->slotName = AddSlotName(theEnv,name,0,false); slot->overrideMessage = slot->slotName->putHandlerName; IncrementLexemeCount(slot->overrideMessage); return(slot); }
/*************************************************************** NAME : CreateSystemClasses DESCRIPTION : Creates the built-in system classes INPUTS : None RETURNS : Nothing useful SIDE EFFECTS : System classes inserted in the class hash table NOTES : The binary/load save indices for the primitive types (integer, float, symbol and string, multifield, external-address and fact-address) are very important. Need to be able to refer to types with the same index regardless of whether the object system is installed or not. Thus, the bsave/blaod indices of these classes match their integer codes. WARNING!!: Assumes no classes exist yet! ***************************************************************/ globle void CreateSystemClasses( void *theEnv) { DEFCLASS *user,*any,*primitive,*number,*lexeme,*address,*instance; #if DEFRULE_CONSTRUCT DEFCLASS *initialObject; #endif /* =================================== Add canonical slot name entries for the is-a and name fields - used for object patterns =================================== */ AddSlotName(theEnv,DefclassData(theEnv)->ISA_SYMBOL,ISA_ID,TRUE); AddSlotName(theEnv,DefclassData(theEnv)->NAME_SYMBOL,NAME_ID,TRUE); /* ========================================================= Bsave Indices for non-primitive classes start at 9 Object is 9, Primitive is 10, Number is 11, Lexeme is 12, Address is 13, and Instance is 14. because: float = 0, integer = 1, symbol = 2, string = 3, multifield = 4, and external-address = 5 and fact-address = 6, instance-adress = 7 and instance-name = 8. ========================================================= */ any = AddSystemClass(theEnv,OBJECT_TYPE_NAME,NULL); primitive = AddSystemClass(theEnv,PRIMITIVE_TYPE_NAME,any); user = AddSystemClass(theEnv,USER_TYPE_NAME,any); number = AddSystemClass(theEnv,NUMBER_TYPE_NAME,primitive); DefclassData(theEnv)->PrimitiveClassMap[INTEGER] = AddSystemClass(theEnv,INTEGER_TYPE_NAME,number); DefclassData(theEnv)->PrimitiveClassMap[FLOAT] = AddSystemClass(theEnv,FLOAT_TYPE_NAME,number); lexeme = AddSystemClass(theEnv,LEXEME_TYPE_NAME,primitive); DefclassData(theEnv)->PrimitiveClassMap[SYMBOL] = AddSystemClass(theEnv,SYMBOL_TYPE_NAME,lexeme); DefclassData(theEnv)->PrimitiveClassMap[STRING] = AddSystemClass(theEnv,STRING_TYPE_NAME,lexeme); DefclassData(theEnv)->PrimitiveClassMap[MULTIFIELD] = AddSystemClass(theEnv,MULTIFIELD_TYPE_NAME,primitive); address = AddSystemClass(theEnv,ADDRESS_TYPE_NAME,primitive); DefclassData(theEnv)->PrimitiveClassMap[EXTERNAL_ADDRESS] = AddSystemClass(theEnv,EXTERNAL_ADDRESS_TYPE_NAME,address); DefclassData(theEnv)->PrimitiveClassMap[FACT_ADDRESS] = AddSystemClass(theEnv,FACT_ADDRESS_TYPE_NAME,address); instance = AddSystemClass(theEnv,INSTANCE_TYPE_NAME,primitive); DefclassData(theEnv)->PrimitiveClassMap[INSTANCE_ADDRESS] = AddSystemClass(theEnv,INSTANCE_ADDRESS_TYPE_NAME,instance); DefclassData(theEnv)->PrimitiveClassMap[INSTANCE_NAME] = AddSystemClass(theEnv,INSTANCE_NAME_TYPE_NAME,instance); #if DEFRULE_CONSTRUCT initialObject = AddSystemClass(theEnv,INITIAL_OBJECT_CLASS_NAME,user); initialObject->abstract = 0; initialObject->reactive = 1; #endif /* ================================================================================ INSTANCE-ADDRESS is-a INSTANCE and ADDRESS. The links between INSTANCE-ADDRESS and ADDRESS still need to be made. =============================================================================== */ AddClassLink(theEnv,&DefclassData(theEnv)->PrimitiveClassMap[INSTANCE_ADDRESS]->directSuperclasses,address,-1); AddClassLink(theEnv,&DefclassData(theEnv)->PrimitiveClassMap[INSTANCE_ADDRESS]->allSuperclasses,address,2); AddClassLink(theEnv,&address->directSubclasses,DefclassData(theEnv)->PrimitiveClassMap[INSTANCE_ADDRESS],-1); /* ======================================================================= The order of the class in the list MUST correspond to their type codes! See CONSTANT.H ======================================================================= */ AddConstructToModule((struct constructHeader *) DefclassData(theEnv)->PrimitiveClassMap[FLOAT]); AddConstructToModule((struct constructHeader *) DefclassData(theEnv)->PrimitiveClassMap[INTEGER]); AddConstructToModule((struct constructHeader *) DefclassData(theEnv)->PrimitiveClassMap[SYMBOL]); AddConstructToModule((struct constructHeader *) DefclassData(theEnv)->PrimitiveClassMap[STRING]); AddConstructToModule((struct constructHeader *) DefclassData(theEnv)->PrimitiveClassMap[MULTIFIELD]); AddConstructToModule((struct constructHeader *) DefclassData(theEnv)->PrimitiveClassMap[EXTERNAL_ADDRESS]); AddConstructToModule((struct constructHeader *) DefclassData(theEnv)->PrimitiveClassMap[FACT_ADDRESS]); AddConstructToModule((struct constructHeader *) DefclassData(theEnv)->PrimitiveClassMap[INSTANCE_ADDRESS]); AddConstructToModule((struct constructHeader *) DefclassData(theEnv)->PrimitiveClassMap[INSTANCE_NAME]); AddConstructToModule((struct constructHeader *) any); AddConstructToModule((struct constructHeader *) primitive); AddConstructToModule((struct constructHeader *) number); AddConstructToModule((struct constructHeader *) lexeme); AddConstructToModule((struct constructHeader *) address); AddConstructToModule((struct constructHeader *) instance); AddConstructToModule((struct constructHeader *) user); #if DEFRULE_CONSTRUCT AddConstructToModule((struct constructHeader *) initialObject); #endif for (any = (DEFCLASS *) EnvGetNextDefclass(theEnv,NULL) ; any != NULL ; any = (DEFCLASS *) EnvGetNextDefclass(theEnv,(void *) any)) AssignClassID(theEnv,any); }