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

📄 defins.c

📁 clips源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
   /*******************************************************/   /*      "C" Language Integrated Production System      */   /*                                                     */   /*             CLIPS Version 6.24  06/02/06            */   /*                                                     */   /*                  DEFINSTANCES MODULE                */   /*******************************************************//*************************************************************//* Purpose: Kernel definstances interface commands           *//*              and routines                                 *//*                                                           *//* Principal Programmer(s):                                  *//*      Brian L. Donnell                                     *//*                                                           *//* Contributing Programmer(s):                               *//*                                                           *//*                                                           *//* Revision History:                                         *//*      6.23: Correction for FalseSymbol/TrueSymbol. DR0859  *//*                                                           *//*            Corrected compilation errors for files         *//*            generated by constructs-to-c. DR0861           *//*                                                           *//*            Changed name of variable exp to theExp         *//*            because of Unix compiler warnings of shadowed  *//*            definitions.                                   *//*                                                           *//*      6.24: Converted INSTANCE_PATTERN_MATCHING to         *//*            DEFRULE_CONSTRUCT.                             *//*                                                           *//*            Renamed BOOLEAN macro type to intBool.         *//*                                                           *//*************************************************************//* =========================================   *****************************************               EXTERNAL DEFINITIONS   =========================================   ***************************************** */#include "setup.h"#if DEFINSTANCES_CONSTRUCT#if BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE#include "bload.h"#include "dfinsbin.h"#endif#if CONSTRUCT_COMPILER && (! RUN_TIME)#include "dfinscmp.h"#endif#include "argacces.h"#include "classcom.h"#include "classfun.h"#include "cstrccom.h"#include "cstrcpsr.h"#include "constant.h"#include "constrct.h"#include "envrnmnt.h"#include "evaluatn.h"#include "extnfunc.h"#include "insfun.h"#include "inspsr.h"#include "memalloc.h"#include "modulpsr.h"#include "router.h"#include "scanner.h"#include "symbol.h"#include "utility.h"#define _DEFINS_SOURCE_#include "defins.h"/* =========================================   *****************************************                   CONSTANTS   =========================================   ***************************************** */#define ACTIVE_RLN "active"/* =========================================   *****************************************      INTERNALLY VISIBLE FUNCTION HEADERS   =========================================   ***************************************** */#if (! BLOAD_ONLY) && (! RUN_TIME)static int ParseDefinstances(void *,char *);static SYMBOL_HN *ParseDefinstancesName(void *,char *,int *);static void RemoveDefinstances(void *,void *);static void SaveDefinstances(void *,void *,char *);static intBool RemoveAllDefinstances(void *);static void DefinstancesDeleteError(void *,char *);#if DEFRULE_CONSTRUCTstatic void CreateInitialDefinstances(void *);#endif#endif#if ! RUN_TIMEstatic void *AllocateModule(void *);static void  ReturnModule(void *,void *);static intBool ClearDefinstancesReady(void *);static void CheckDefinstancesBusy(void *,struct constructHeader *,void *);static void DestroyDefinstancesAction(void *,struct constructHeader *,void *);#endifstatic void ResetDefinstances(void *);static void ResetDefinstancesAction(void *,struct constructHeader *,void *);static void DeallocateDefinstancesData(void *);/* =========================================   *****************************************          EXTERNALLY VISIBLE FUNCTIONS   =========================================   ***************************************** *//***************************************************  NAME         : SetupDefinstances  DESCRIPTION  : Adds the definstance support routines                   to the Kernel  INPUTS       : None  RETURNS      : Nothing useful  SIDE EFFECTS : Appropriate function lists modified  NOTES        : None ***************************************************/globle void SetupDefinstances(  void *theEnv)  {   AllocateEnvironmentData(theEnv,DEFINSTANCES_DATA,sizeof(struct definstancesData),DeallocateDefinstancesData);   DefinstancesData(theEnv)->DefinstancesModuleIndex =                RegisterModuleItem(theEnv,"definstances",#if (! RUN_TIME)                                    AllocateModule,ReturnModule,#else                                    NULL,NULL,#endif#if BLOAD_AND_BSAVE || BLOAD || BLOAD_ONLY                                    BloadDefinstancesModuleRef,#else                                    NULL,#endif#if CONSTRUCT_COMPILER && (! RUN_TIME)                                    DefinstancesCModuleReference,#else                                    NULL,#endif                                    EnvFindDefinstances);   DefinstancesData(theEnv)->DefinstancesConstruct =      AddConstruct(theEnv,"definstances","definstances",#if (! BLOAD_ONLY) && (! RUN_TIME)                   ParseDefinstances,#else                   NULL,#endif                   EnvFindDefinstances,                   GetConstructNamePointer,GetConstructPPForm,                   GetConstructModuleItem,EnvGetNextDefinstances,SetNextConstruct,                   EnvIsDefinstancesDeletable,EnvUndefinstances,#if (! BLOAD_ONLY) && (! RUN_TIME)                   RemoveDefinstances#else                   NULL#endif                   );#if ! RUN_TIME   AddClearReadyFunction(theEnv,"definstances",ClearDefinstancesReady,0);#if ! BLOAD_ONLY   EnvDefineFunction2(theEnv,"undefinstances",'v',PTIEF UndefinstancesCommand,"UndefinstancesCommand","11w");   AddSaveFunction(theEnv,"definstances",SaveDefinstances,0);#if DEFRULE_CONSTRUCT   EnvAddClearFunction(theEnv,"definstances",CreateInitialDefinstances,-1000);#endif#endif#if DEBUGGING_FUNCTIONS   EnvDefineFunction2(theEnv,"ppdefinstances",'v',PTIEF PPDefinstancesCommand ,"PPDefinstancesCommand","11w");   EnvDefineFunction2(theEnv,"list-definstances",'v',PTIEF ListDefinstancesCommand,"ListDefinstancesCommand","01");#endif   EnvDefineFunction2(theEnv,"get-definstances-list",'m',PTIEF GetDefinstancesListFunction,                   "GetDefinstancesListFunction","01");   EnvDefineFunction2(theEnv,"definstances-module",'w',PTIEF GetDefinstancesModuleCommand,                   "GetDefinstancesModuleCommand","11w");#endif   EnvAddResetFunction(theEnv,"definstances",(void (*)(void *)) ResetDefinstances,0);#if BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE   SetupDefinstancesBload(theEnv);#endif#if CONSTRUCT_COMPILER && (! RUN_TIME)   SetupDefinstancesCompiler(theEnv);#endif  }  /*******************************************************//* DeallocateDefinstancesData: Deallocates environment *//*    data for the definstances construct.             *//*******************************************************/static void DeallocateDefinstancesData(  void *theEnv)  {#if ! RUN_TIME   struct definstancesModule *theModuleItem;   void *theModule;   #if BLOAD || BLOAD_AND_BSAVE   if (Bloaded(theEnv)) return;#endif      DoForAllConstructs(theEnv,DestroyDefinstancesAction,DefinstancesData(theEnv)->DefinstancesModuleIndex,FALSE,NULL);       for (theModule = EnvGetNextDefmodule(theEnv,NULL);        theModule != NULL;        theModule = EnvGetNextDefmodule(theEnv,theModule))     {      theModuleItem = (struct definstancesModule *)                      GetModuleItem(theEnv,(struct defmodule *) theModule,                                    DefinstancesData(theEnv)->DefinstancesModuleIndex);      rtn_struct(theEnv,definstancesModule,theModuleItem);     }#else#if MAC_MCW || IBM_MCW || MAC_XCD#pragma unused(theEnv)#endif#endif  }#if ! RUN_TIME  /*****************************************************//* DestroyDefinstancesAction: Action used to remove  *//*   definstances as a result of DestroyEnvironment. *//*****************************************************/#if IBM_TBC#pragma argsused#endifstatic void DestroyDefinstancesAction(  void *theEnv,  struct constructHeader *theConstruct,  void *buffer)  {#if MAC_MCW || IBM_MCW || MAC_XCD#pragma unused(buffer)#endif#if (! BLOAD_ONLY) && (! RUN_TIME)   struct definstances *theDefinstances = (struct definstances *) theConstruct;      if (theDefinstances == NULL) return;      ReturnPackedExpression(theEnv,theDefinstances->mkinstance);      DestroyConstructHeader(theEnv,&theDefinstances->header);   rtn_struct(theEnv,definstances,theDefinstances);#else#if MAC_MCW || IBM_MCW || MAC_XCD#pragma unused(theConstruct,theEnv)#endif#endif  }#endif/***********************************************************  NAME         : EnvGetNextDefinstances  DESCRIPTION  : Finds first or next definstances  INPUTS       : The address of the current definstances  RETURNS      : The address of the next definstances                   (NULL if none)  SIDE EFFECTS : None  NOTES        : If ptr == NULL, the first definstances                    is returned. ***********************************************************/globle void *EnvGetNextDefinstances(  void *theEnv,  void *ptr)  {   return((void *) GetNextConstructItem(theEnv,(struct constructHeader *) ptr,                                        DefinstancesData(theEnv)->DefinstancesModuleIndex));  }/***************************************************  NAME         : EnvFindDefinstances  DESCRIPTION  : Looks up a definstance construct                   by name-string  INPUTS       : The symbolic name  RETURNS      : The definstance address, or NULL                    if not found  SIDE EFFECTS : None  NOTES        : None ***************************************************/globle void *EnvFindDefinstances(  void *theEnv,  char *name)  {   return(FindNamedConstruct(theEnv,name,DefinstancesData(theEnv)->DefinstancesConstruct));  }/***************************************************  NAME         : EnvIsDefinstancesDeletable  DESCRIPTION  : Determines if a definstances                   can be deleted  INPUTS       : Address of the definstances  RETURNS      : TRUE if deletable, FALSE otherwise  SIDE EFFECTS : None  NOTES        : None ***************************************************/

⌨️ 快捷键说明

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