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

📄 ruledef.c

📁 clips源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/***********************************************//* AllocateModule: Allocates a defrule module. *//***********************************************/static void *AllocateModule(  void *theEnv)  {   struct defruleModule *theItem;   theItem = get_struct(theEnv,defruleModule);   theItem->agenda = NULL;   theItem->groupings = NULL;   return((void *) theItem);  }/*********************************************//* ReturnModule: Deallocates a defrule module. *//*********************************************/static void ReturnModule(  void *theEnv,  void *theItem)  {   FreeConstructHeaderModule(theEnv,(struct defmoduleItemHeader *) theItem,DefruleData(theEnv)->DefruleConstruct);   rtn_struct(theEnv,defruleModule,theItem);  }/************************************************************//* GetDefruleModuleItem: Returns a pointer to the defmodule *//*  item for the specified defrule or defmodule.            *//************************************************************/globle struct defruleModule *GetDefruleModuleItem(  void *theEnv,  struct defmodule *theModule)  {      return((struct defruleModule *) GetConstructModuleItemByIndex(theEnv,theModule,DefruleData(theEnv)->DefruleModuleIndex));   }/*******************************************************************//* EnvFindDefrule: Searches for a defrule in the list of defrules. *//*   Returns a pointer to the defrule if found, otherwise NULL.    *//*******************************************************************/globle void *EnvFindDefrule(  void *theEnv,  char *defruleName)  {      return(FindNamedConstruct(theEnv,defruleName,DefruleData(theEnv)->DefruleConstruct));   }/************************************************************//* EnvGetNextDefrule: If passed a NULL pointer, returns the *//*   first defrule in the ListOfDefrules. Otherwise returns *//*   the next defrule following the defrule passed as an    *//*   argument.                                              *//************************************************************/globle void *EnvGetNextDefrule(  void *theEnv,  void *defrulePtr)  {      return((void *) GetNextConstructItem(theEnv,(struct constructHeader *) defrulePtr,DefruleData(theEnv)->DefruleModuleIndex));   }/*******************************************************//* EnvIsDefruleDeletable: Returns TRUE if a particular *//*   defrule can be deleted, otherwise returns FALSE.  *//*******************************************************/globle intBool EnvIsDefruleDeletable(  void *theEnv,  void *vTheDefrule)  {   struct defrule *theDefrule;   if (! ConstructsDeletable(theEnv))     { return FALSE; }   for (theDefrule = (struct defrule *) vTheDefrule;        theDefrule != NULL;        theDefrule = theDefrule->disjunct)     { if (theDefrule->executing) return(FALSE); }   if (EngineData(theEnv)->JoinOperationInProgress) return(FALSE);   return(TRUE);  }#if RUN_TIME/******************************************//* DefruleRunTimeInitialize:  Initializes *//*   defrule in a run-time module.        *//******************************************/globle void DefruleRunTimeInitialize(  void *theEnv,  struct joinLink *rightPrime,  struct joinLink *leftPrime)  {   struct defmodule *theModule;   struct defrule *theRule;   DefruleData(theEnv)->RightPrimeJoins = rightPrime;   DefruleData(theEnv)->LeftPrimeJoins = leftPrime;      SaveCurrentModule(theEnv);   for (theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,NULL);        theModule != NULL;        theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,theModule))     {      EnvSetCurrentModule(theEnv,(void *) theModule);      for (theRule = EnvGetNextDefrule(theEnv,NULL);           theRule != NULL;           theRule = EnvGetNextDefrule(theEnv,theRule))        { AddBetaMemoriesToRule(theEnv,theRule->lastJoin); }     }        RestoreCurrentModule(theEnv);  }/******************************************//* AddBetaMemoriesToRule:     *//******************************************/static void AddBetaMemoriesToRule(  void *theEnv,  struct joinNode *theNode)  {   AddBetaMemoriesToJoin(theEnv,theNode);      if (theNode->lastLevel != NULL)     { AddBetaMemoriesToRule(theEnv,theNode->lastLevel); }        if (theNode->joinFromTheRight)     { AddBetaMemoriesToRule(theEnv,theNode->rightSideEntryStructure); }  }  #endif#if RUN_TIME || BLOAD_ONLY || BLOAD || BLOAD_AND_BSAVE/******************************************//* AddBetaMemoriesToJoin:     *//******************************************/globle void AddBetaMemoriesToJoin(  void *theEnv,  struct joinNode *theNode)  {      if ((theNode->leftMemory != NULL) || (theNode->rightMemory != NULL))     { return; }   if ((! theNode->firstJoin) || theNode->patternIsExists)     {      if (theNode->leftHash == NULL)        {         theNode->leftMemory = get_struct(theEnv,betaMemory);          theNode->leftMemory->beta = genalloc(theEnv,sizeof(struct partialMatch *));         theNode->leftMemory->beta[0] = NULL;         theNode->leftMemory->size = 1;         theNode->leftMemory->count = 0;         theNode->leftMemory->last = NULL;        }      else        {         theNode->leftMemory = get_struct(theEnv,betaMemory);          theNode->leftMemory->beta = genalloc(theEnv,sizeof(struct partialMatch *) * INITIAL_BETA_HASH_SIZE);         memset(theNode->leftMemory->beta,0,sizeof(struct partialMatch *) * INITIAL_BETA_HASH_SIZE);         theNode->leftMemory->size = INITIAL_BETA_HASH_SIZE;         theNode->leftMemory->count = 0;         theNode->leftMemory->last = NULL;        }      if (theNode->firstJoin && theNode->patternIsExists)        {         theNode->leftMemory->beta[0] = CreateEmptyPartialMatch(theEnv);          theNode->leftMemory->beta[0]->owner = theNode;        }     }   else     { theNode->leftMemory = NULL; }   if (theNode->joinFromTheRight)     {      if (theNode->leftHash == NULL)        {         theNode->rightMemory = get_struct(theEnv,betaMemory);          theNode->rightMemory->beta = genalloc(theEnv,sizeof(struct partialMatch *));         theNode->rightMemory->last = genalloc(theEnv,sizeof(struct partialMatch *));         theNode->rightMemory->beta[0] = NULL;         theNode->rightMemory->last[0] = NULL;         theNode->rightMemory->size = 1;         theNode->rightMemory->count = 0;        }      else        {         theNode->rightMemory = get_struct(theEnv,betaMemory);          theNode->rightMemory->beta = genalloc(theEnv,sizeof(struct partialMatch *) * INITIAL_BETA_HASH_SIZE);         theNode->rightMemory->last = genalloc(theEnv,sizeof(struct partialMatch *) * INITIAL_BETA_HASH_SIZE);         memset(theNode->rightMemory->beta,0,sizeof(struct partialMatch *) * INITIAL_BETA_HASH_SIZE);         memset(theNode->rightMemory->last,0,sizeof(struct partialMatch *) * INITIAL_BETA_HASH_SIZE);         theNode->rightMemory->size = INITIAL_BETA_HASH_SIZE;         theNode->rightMemory->count = 0;        }     }   else if (theNode->firstJoin && (theNode->rightSideEntryStructure == NULL))     {      theNode->rightMemory = get_struct(theEnv,betaMemory);       theNode->rightMemory->beta = genalloc(theEnv,sizeof(struct partialMatch *));      theNode->rightMemory->last = genalloc(theEnv,sizeof(struct partialMatch *));      theNode->rightMemory->beta[0] = CreateEmptyPartialMatch(theEnv);      theNode->rightMemory->beta[0]->owner = theNode;      theNode->rightMemory->beta[0]->rhsMemory = TRUE;      theNode->rightMemory->last[0] = theNode->rightMemory->beta[0];      theNode->rightMemory->size = 1;      theNode->rightMemory->count = 1;         }   else     { theNode->rightMemory = NULL; }  }#endif#endif /* DEFRULE_CONSTRUCT */

⌨️ 快捷键说明

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