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

📄 insmoddp.c

📁 NASA 开发使用的一个专家系统
💻 C
📖 第 1 页 / 共 3 页
字号:
      expression information along      to whatever message-handler implements      the duplicate      ====================================== */   exp[0].type = INSTANCE_NAME;   exp[0].value = newName.value;   exp[0].argList = NULL;   exp[0].nextArg = &exp[1];   exp[1].type = EXTERNAL_ADDRESS;   exp[1].value = (VOID *) overrides;   exp[1].argList = NULL;   exp[1].nextArg = NULL;      oldOMDMV = ObjectModDupMsgValid;   ObjectModDupMsgValid = CLIPS_TRUE;   DirectMessage(FindSymbol(DIRECT_DUPLICATE_STRING),ins,result,&exp[0]);   ObjectModDupMsgValid = oldOMDMV;      DeleteSlotOverrideEvaluations(overrides,overrideCount);  }  /*************************************************************  NAME         : MsgDuplicateInstance  DESCRIPTION  : Duplicates an instance via the                 message-duplicate message  INPUTS       : The address of the result value  RETURNS      : Nothing useful  SIDE EFFECTS : Slot updates performed w/ int & put- messages  NOTES        : CLIPS Syntax:                 (duplicate-instance <instance>                   [to <instance-name>] <slot-override>*) *************************************************************/globle VOID MsgDuplicateInstance(result)  DATA_OBJECT *result;  {   INSTANCE_TYPE *ins;   DATA_OBJECT newName;   EXPRESSION exp[2];   DATA_OBJECT *overrides;   int oldOMDMV,overrideCount,error;      /* ===========================================      The slot-overrides need to be evaluated now      to resolve any variable references before a      new frame is pushed for message-handler      execution      =========================================== */   overrides = EvaluateSlotOverrides(GetFirstArgument()->nextArg->nextArg,                                     &overrideCount,&error);   if (error)     {      SetpType(result,SYMBOL);      SetpValue(result,CLIPSFalseSymbol);      return;     }        /* ==================================      Find the instance and make sure it      wasn't deleted by the overrides      ================================== */   ins = CheckInstance(ValueToString(ExpressionFunctionCallName(CurrentExpression)));   if (ins == NULL)     {      SetpType(result,SYMBOL);      SetpValue(result,CLIPSFalseSymbol);      DeleteSlotOverrideEvaluations(overrides,overrideCount);      return;     }   if (ArgTypeCheck(ValueToString(ExpressionFunctionCallName(CurrentExpression)),                    2,INSTANCE_NAME,&newName) == CLIPS_FALSE)     {      SetpType(result,SYMBOL);      SetpValue(result,CLIPSFalseSymbol);      DeleteSlotOverrideEvaluations(overrides,overrideCount);      return;     }   /* ======================================      We are passing the slot override      expression information along      to whatever message-handler implements      the duplicate      ====================================== */   exp[0].type = INSTANCE_NAME;   exp[0].value = newName.value;   exp[0].argList = NULL;   exp[0].nextArg = &exp[1];   exp[1].type = EXTERNAL_ADDRESS;   exp[1].value = (VOID *) overrides;   exp[1].argList = NULL;   exp[1].nextArg = NULL;      oldOMDMV = ObjectModDupMsgValid;   ObjectModDupMsgValid = CLIPS_TRUE;   DirectMessage(FindSymbol(MSG_DUPLICATE_STRING),ins,result,&exp[0]);   ObjectModDupMsgValid = oldOMDMV;      DeleteSlotOverrideEvaluations(overrides,overrideCount);  }#if INSTANCE_PATTERN_MATCHING/**************************************************************  NAME         : InactiveModifyInstance  DESCRIPTION  : Modifies slots of an instance of a class                 Pattern-matching is automatically                 delayed until the slot updates are done  INPUTS       : The address of the result value  RETURNS      : Nothing useful  SIDE EFFECTS : Slot updates performed directly  NOTES        : CLIPS Syntax:                 (modify-instance <instance-name>                   <slot-override>*) **************************************************************/globle VOID InactiveModifyInstance(result)  DATA_OBJECT *result;  {   int ov;      ov = SetDelayObjectPatternMatching(CLIPS_TRUE);   ModifyInstance(result);   SetDelayObjectPatternMatching(ov);  }  /**************************************************************  NAME         : InactiveMsgModifyInstance  DESCRIPTION  : Modifies slots of an instance of a class                 Pattern-matching is automatically                 delayed until the slot updates are done  INPUTS       : The address of the result value  RETURNS      : Nothing useful  SIDE EFFECTS : Slot updates performed with put- messages  NOTES        : CLIPS Syntax:                 (message-modify-instance <instance-name>                   <slot-override>*) **************************************************************/globle VOID InactiveMsgModifyInstance(result)  DATA_OBJECT *result;  {   int ov;      ov = SetDelayObjectPatternMatching(CLIPS_TRUE);   MsgModifyInstance(result);   SetDelayObjectPatternMatching(ov);  }  /*******************************************************************  NAME         : InactiveDuplicateInstance  DESCRIPTION  : Duplicates an instance of a class                 Pattern-matching is automatically                 delayed until the slot updates are done  INPUTS       : The address of the result value  RETURNS      : Nothing useful  SIDE EFFECTS : Slot updates performed directly  NOTES        : CLIPS Syntax:                 (duplicate-instance <instance> [to <instance-name>]                   <slot-override>*) *******************************************************************/globle VOID InactiveDuplicateInstance(result)  DATA_OBJECT *result;  {   int ov;      ov = SetDelayObjectPatternMatching(CLIPS_TRUE);   DuplicateInstance(result);   SetDelayObjectPatternMatching(ov);  }  /**************************************************************  NAME         : InactiveMsgDuplicateInstance  DESCRIPTION  : Duplicates an instance of a class                 Pattern-matching is automatically                 delayed until the slot updates are done  INPUTS       : The address of the result value  RETURNS      : Nothing useful  SIDE EFFECTS : Slot updates performed with put- messages  NOTES        : CLIPS Syntax:                 (message-duplicate-instance <instance>                   [to <instance-name>]                   <slot-override>*) **************************************************************/globle VOID InactiveMsgDuplicateInstance(result)  DATA_OBJECT *result;  {   int ov;      ov = SetDelayObjectPatternMatching(CLIPS_TRUE);   MsgDuplicateInstance(result);   SetDelayObjectPatternMatching(ov);  }  #endif  /*****************************************************  NAME         : DirectDuplicateMsgHandler  DESCRIPTION  : Implementation for the USER class                 handler direct-duplicate                                  Implements duplicate-instance message                 with a series of direct slot                 placements  INPUTS       : A data object buffer to hold the                 result  RETURNS      : Nothing useful  SIDE EFFECTS : Slot values updated  NOTES        : None *****************************************************/globle VOID DirectDuplicateMsgHandler(result)  DATA_OBJECT *result;  {   DuplicateMsgHandlerSupport(result,CLIPS_FALSE);  }  /*****************************************************  NAME         : MsgDuplicateMsgHandler  DESCRIPTION  : Implementation for the USER class                 handler message-duplicate                                  Implements duplicate-instance message                 with a series of put- messages  INPUTS       : A data object buffer to hold the                 result  RETURNS      : Nothing useful  SIDE EFFECTS : Slot values updated  NOTES        : None *****************************************************/globle VOID MsgDuplicateMsgHandler(result)  DATA_OBJECT *result;  {   DuplicateMsgHandlerSupport(result,CLIPS_TRUE);  }/***************************************************  NAME         : DirectModifyMsgHandler  DESCRIPTION  : Implementation for the USER class                 handler direct-modify                                  Implements modify-instance message                 with a series of direct slot                 placements  INPUTS       : A data object buffer to hold the                 result  RETURNS      : Nothing useful  SIDE EFFECTS : Slot values updated  NOTES        : None ***************************************************/globle VOID DirectModifyMsgHandler(result)  DATA_OBJECT *result;  {   ModifyMsgHandlerSupport(result,CLIPS_FALSE);  }  /***************************************************  NAME         : MsgModifyMsgHandler  DESCRIPTION  : Implementation for the USER class                 handler message-modify                                  Implements modify-instance message                 with a series of put- messages  INPUTS       : A data object buffer to hold the                 result  RETURNS      : Nothing useful  SIDE EFFECTS : Slot values updated  NOTES        : None ***************************************************/globle VOID MsgModifyMsgHandler(result)  DATA_OBJECT *result;  {   ModifyMsgHandlerSupport(result,CLIPS_TRUE);  }/* =========================================   *****************************************          INTERNALLY VISIBLE FUNCTIONS   =========================================   ***************************************** */   /***********************************************************  NAME         : EvaluateSlotOverrides  DESCRIPTION  : Evaluates the slot-override expressions                 for modify-instance and duplicate-instance                 Evaluations are stored in an array of                 data objects, where the supplementalInfo                 field points at the name of the slot                 The data object next fields are used                 to link the array as well.  INPUTS       : 1) The slot override expressions                 2) A buffer to hold the number                    of slot overrides                 3) A buffer to hold an error flag  RETURNS      : The slot override data object array  SIDE EFFECTS : Data object array allocated and initialized                 override count and error buffers set  NOTES        : Slot overrides must be evaluated before                 calling supporting message-handlers for                 modify- and duplicate-instance in the                 event that the overrides contain variable                 references to an outer frame ***********************************************************/static DATA_OBJECT *EvaluateSlotOverrides(ovExprs,ovCnt,error)  EXPRESSION *ovExprs;  int *ovCnt,*error;  {   DATA_OBJECT *ovs;   int ovi;   VOID *slotName;      *error = CLIPS_FALSE;   /* ==========================================      There are two expressions chains for every      slot override: one for the slot name and      one for the slot value      ========================================== */   *ovCnt = CountArguments(ovExprs) / 2;   if (*ovCnt == 0)     return(NULL);      /* ===============================================      Evaluate all the slot override names and values      and store them in a contiguous array      =============================================== */   ovs = (DATA_OBJECT *) gm2((int) (sizeof(DATA_OBJECT) * (*ovCnt)));   ovi = 0;   while (ovExprs != NULL)     {      if (EvaluateExpression(ovExprs,&ovs[ovi]))        goto EvaluateOverridesError;      if (ovs[ovi].type != SYMBOL)        {         ExpectedTypeError1(ValueToString(ExpressionFunctionCallName(CurrentExpression)),                            ovi+1,"slot name");         SetEvaluationError(CLIPS_TRUE);         goto EvaluateOverridesError;        }      slotName = ovs[ovi].value;      if (ovExprs->nextArg->argList)        {         if (EvaluateAndStoreInDataObject(CLIPS_FALSE,ovExprs->nextArg->argList,                                               &ovs[ovi]) == CLIPS_FALSE)           goto EvaluateOverridesError;        }      else        {         SetpDOBegin(&ovs[ovi],1);         SetpDOEnd(&ovs[ovi],0);

⌨️ 快捷键说明

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