⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 insmoddp.c

📁 NASA 开发使用的一个专家系统
💻 C
📖 第 1 页 / 共 3 页
字号:
         SetpType(&ovs[ovi],MULTIFIELD);         SetpValue(&ovs[ovi],NoParamValue);        }      ovs[ovi].supplementalInfo = slotName;      ovExprs = ovExprs->nextArg->nextArg;      ovs[ovi].next = (ovExprs != NULL) ? &ovs[ovi+1] : NULL;      ovi++;     }   return(ovs);   EvaluateOverridesError:   rm((VOID *) ovs,(int) (sizeof(DATA_OBJECT) * (*ovCnt)));   *error = CLIPS_TRUE;   return(NULL);  }/**********************************************************  NAME         : DeleteSlotOverrideEvaluations  DESCRIPTION  : Deallocates slot override evaluation array  INPUTS       : 1) The data object array                 2) The number of elements  RETURNS      : Nothing useful  SIDE EFFECTS : Deallocates slot override data object                 array for modify- and duplicate- instance  NOTES        : None **********************************************************/static VOID DeleteSlotOverrideEvaluations(ovEvals,ovCnt)  DATA_OBJECT *ovEvals;  int ovCnt;  {   if (ovEvals != NULL)     rm((VOID *) ovEvals,(int) (sizeof(DATA_OBJECT) * ovCnt));  }  /**********************************************************  NAME         : ModifyMsgHandlerSupport  DESCRIPTION  : Support routine for DirectModifyMsgHandler                 and MsgModifyMsgHandler                                  Performs a series of slot updates                 directly or with messages  INPUTS       : 1) A data object buffer to hold the result                 2) A flag indicating whether to use                    put- messages or direct placement  RETURNS      : Nothing useful  SIDE EFFECTS : Slots updated (messages sent)  NOTES        : None **********************************************************/static VOID ModifyMsgHandlerSupport(result,msgpass)  DATA_OBJECT *result;  int msgpass;  {   DATA_OBJECT *slotOverrides,*newval,temp;   EXPRESSION msgExp;   INSTANCE_TYPE *ins;   INSTANCE_SLOT *insSlot;      result->type = SYMBOL;   result->value = CLIPSFalseSymbol;   if (ObjectModDupMsgValid == CLIPS_FALSE)     {      PrintErrorID("INSMODDP",1,CLIPS_FALSE);      PrintCLIPS(WERROR,"Direct/message-modify message valid only in modify-instance.\n");      SetEvaluationError(CLIPS_TRUE);      return;     }   ObjectModDupMsgValid = CLIPS_FALSE;      ins = GetActiveInstance();   if (ins->garbage)     {      StaleInstanceAddress("modify-instance");      SetEvaluationError(CLIPS_TRUE);      return;     }      /* =======================================      Retrieve the slot override data objects      passed from ModifyInstance - the slot      name is stored in the supplementalInfo      field - and the next fields are links      ======================================= */   slotOverrides = (DATA_OBJECT *) GetNthMessageArgument(1)->value;   while (slotOverrides != NULL)     {      /* ===========================================================         No evaluation or error checking needs to be done         since this has already been done by EvaluateSlotOverrides()         =========================================================== */      insSlot = FindInstanceSlot(ins,(SYMBOL_HN *) slotOverrides->supplementalInfo);      if (insSlot == NULL)        {         SlotExistError(ValueToString(slotOverrides->supplementalInfo),"modify-instance");         SetEvaluationError(CLIPS_TRUE);         return;        }      if (msgpass)        {         msgExp.type = (short) slotOverrides->type;         if (msgExp.type != MULTIFIELD)           msgExp.value = slotOverrides->value;         else           msgExp.value = (VOID *) slotOverrides;         msgExp.argList = NULL;         msgExp.nextArg = NULL;         DirectMessage(insSlot->desc->overrideMessage,ins,&temp,&msgExp);         if (EvaluationError ||             ((temp.type == SYMBOL) && (temp.value == CLIPSFalseSymbol)))           return;        }      else        {         if (insSlot->desc->multiple && (slotOverrides->type != MULTIFIELD))           {            temp.type = MULTIFIELD;            temp.value = CreateMultifield(1L);            SetDOBegin(temp,1);            SetDOEnd(temp,1);            SetMFType(temp.value,1,(short) slotOverrides->type);            SetMFValue(temp.value,1,slotOverrides->value);            newval = &temp;           }         else           newval = slotOverrides;         if (PutSlotValue(ins,insSlot,newval,&temp,"modify-instance") == CLIPS_FALSE)           return;        }              slotOverrides = slotOverrides->next;     }   result->value = CLIPSTrueSymbol;  }    /*************************************************************  NAME         : DuplicateMsgHandlerSupport  DESCRIPTION  : Support routine for DirectDuplicateMsgHandler                 and MsgDuplicateMsgHandler                                  Performs a series of slot updates                 directly or with messages  INPUTS       : 1) A data object buffer to hold the result                 2) A flag indicating whether to use                    put- messages or direct placement  RETURNS      : Nothing useful  SIDE EFFECTS : Slots updated (messages sent)  NOTES        : None *************************************************************/static VOID DuplicateMsgHandlerSupport(result,msgpass)  DATA_OBJECT *result;  int msgpass;  {   INSTANCE_TYPE *srcins,*dstins;   SYMBOL_HN *newName;   DATA_OBJECT *slotOverrides;   EXPRESSION *valArg,msgExp;   int i,oldMkInsMsgPass;   INSTANCE_SLOT *dstInsSlot;   DATA_OBJECT temp,junk,*newval;      result->type = SYMBOL;   result->value = CLIPSFalseSymbol;   if (ObjectModDupMsgValid == CLIPS_FALSE)     {      PrintErrorID("INSMODDP",2,CLIPS_FALSE);      PrintCLIPS(WERROR,"Direct/message-duplicate message valid only in duplicate-instance.\n");      SetEvaluationError(CLIPS_TRUE);      return;     }   ObjectModDupMsgValid = CLIPS_FALSE;      /* ==================================      Grab the slot override expressions      and determine the source instance      and the name of the new instance      ================================== */   srcins = GetActiveInstance();   newName = (SYMBOL_HN *) GetNthMessageArgument(1)->value;   slotOverrides = (DATA_OBJECT *) GetNthMessageArgument(2)->value;   if (srcins->garbage)     {      StaleInstanceAddress("duplicate-instance");      SetEvaluationError(CLIPS_TRUE);      return;     }   if (newName == srcins->name)     {      PrintErrorID("INSMODDP",3,CLIPS_FALSE);      PrintCLIPS(WERROR,"Instance copy must have a different name in duplicate-instance.\n");      SetEvaluationError(CLIPS_TRUE);      return;     }        /* ==========================================      Create an uninitialized new instance of      the new name (delete old version - if any)      ========================================== */   oldMkInsMsgPass = MkInsMsgPass;   MkInsMsgPass = msgpass;   dstins = BuildInstance(newName,srcins->cls,CLIPS_TRUE);   MkInsMsgPass = oldMkInsMsgPass;   if (dstins == NULL)     return;   dstins->busy++;      /* ================================      Place slot overrides directly or      with put- messages      ================================ */    while (slotOverrides != NULL)     {      /* ===========================================================         No evaluation or error checking needs to be done         since this has already been done by EvaluateSlotOverrides()         =========================================================== */      dstInsSlot = FindInstanceSlot(dstins,(SYMBOL_HN *) slotOverrides->supplementalInfo);      if (dstInsSlot == NULL)        {         SlotExistError(ValueToString(slotOverrides->supplementalInfo),                        "duplicate-instance");         goto DuplicateError;        }      if (msgpass)        {         msgExp.type = (short) slotOverrides->type;         if (msgExp.type != MULTIFIELD)           msgExp.value = slotOverrides->value;         else           msgExp.value = (VOID *) slotOverrides;         msgExp.argList = NULL;         msgExp.nextArg = NULL;         DirectMessage(dstInsSlot->desc->overrideMessage,dstins,&temp,&msgExp);         if (EvaluationError ||             ((temp.type == SYMBOL) && (temp.value == CLIPSFalseSymbol)))           goto DuplicateError;        }      else        {         if (dstInsSlot->desc->multiple && (slotOverrides->type != MULTIFIELD))           {            temp.type = MULTIFIELD;            temp.value = CreateMultifield(1L);            SetDOBegin(temp,1);            SetDOEnd(temp,1);            SetMFType(temp.value,1,(short) slotOverrides->type);            SetMFValue(temp.value,1,slotOverrides->value);            newval = &temp;           }         else           newval = slotOverrides;         if (PutSlotValue(dstins,dstInsSlot,newval,&temp,"duplicate-instance") == CLIPS_FALSE)           goto DuplicateError;        }      dstInsSlot->override = CLIPS_TRUE;      slotOverrides = slotOverrides->next;     }      /* =======================================      Copy values from source instance to new      directly or with put- messages      ======================================= */   for (i = 0 ; i < dstins->cls->localInstanceSlotCount ; i++)     {      if (dstins->slots[i].override == CLIPS_FALSE)        {         if (msgpass)           {            temp.type = srcins->slots[i].type;            temp.value = srcins->slots[i].value;            if (temp.type == MULTIFIELD)              {               SetDOBegin(temp,1);               SetDOEnd(temp,GetMFLength(temp.value));              }            valArg = ConvertValueToExpression(&temp);            DirectMessage(dstins->slots[i].desc->overrideMessage,                          dstins,&temp,valArg);            ReturnExpression(valArg);            if (EvaluationError ||                ((temp.type == SYMBOL) && (temp.value == CLIPSFalseSymbol)))              goto DuplicateError;           }         else           {            temp.type = srcins->slots[i].type;            temp.value = srcins->slots[i].value;            if (srcins->slots[i].type == MULTIFIELD)              {               SetDOBegin(temp,1);               SetDOEnd(temp,GetMFLength(srcins->slots[i].value));              }            if (PutSlotValue(dstins,&dstins->slots[i],&temp,&junk,"duplicate-instance")                 == CLIPS_FALSE)              goto DuplicateError;           }        }     }         /* =======================================      Send init message for message-duplicate      ======================================= */   if (msgpass)     {      for (i = 0 ; i < dstins->cls->instanceSlotCount ; i++)        dstins->slotAddresses[i]->override = CLIPS_TRUE;      dstins->initializeInProgress = 1;      oldMkInsMsgPass = WithinInit;      WithinInit = CLIPS_TRUE;      DirectMessage(INIT_SYMBOL,dstins,result,NULL);      WithinInit = oldMkInsMsgPass;     }   dstins->busy--;   if (dstins->garbage)     {      result->type = SYMBOL;      result->value = CLIPSFalseSymbol;      SetEvaluationError(CLIPS_TRUE);     }   else     {      result->type = INSTANCE_NAME;      result->value = (VOID *) GetFullInstanceName(dstins);     }   return;   DuplicateError:   dstins->busy--;   QuashInstance(dstins);   SetEvaluationError(CLIPS_TRUE);  }   #endif  /***************************************************  NAME         :   DESCRIPTION  :   INPUTS       :   RETURNS      :   SIDE EFFECTS :   NOTES        :  ***************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -