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

📄 dffnxfun.c

📁 clips源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
   /*******************************************************/   /*      "C" Language Integrated Production System      */   /*                                                     */   /*             CLIPS Version 6.24  06/02/06            */   /*                                                     */   /*                 DEFFUNCTION MODULE                  */   /*******************************************************//*************************************************************//* Purpose:                                                  *//*                                                           *//* Principal Programmer(s):                                  *//*      Brian L. Donnell                                     *//*                                                           *//* Contributing Programmer(s):                               *//*      Gary D. Riley                                        *//*                                                           *//* Revision History:                                         *//*      6.23: Correction for FalseSymbol/TrueSymbol. DR0859  *//*                                                           *//*            Corrected compilation errors for files         *//*            generated by constructs-to-c. DR0861           *//*                                                           *//*            Changed name of variable log to logName        *//*            because of Unix compiler warnings of shadowed  *//*            definitions.                                   *//*                                                           *//*      6.24: Renamed BOOLEAN macro type to intBool.         *//*                                                           *//*            Corrected code to remove run-time program      *//*            compiler warning.                              *//*                                                           *//*************************************************************//* =========================================   *****************************************               EXTERNAL DEFINITIONS   =========================================   ***************************************** */#include "setup.h"#if DEFFUNCTION_CONSTRUCT#if (BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE)#include "bload.h"#include "dffnxbin.h"#endif#if CONSTRUCT_COMPILER && (! RUN_TIME)#include "dffnxcmp.h"#endif#if (! BLOAD_ONLY) && (! RUN_TIME)#include "constrct.h"#include "cstrcpsr.h"#include "dffnxpsr.h"#include "modulpsr.h"#endif#include "envrnmnt.h"#if (! RUN_TIME)#include "extnfunc.h"#endif#include "dffnxexe.h"#if DEBUGGING_FUNCTIONS#include "watch.h"#endif#include "argacces.h"#include "memalloc.h"#include "cstrccom.h"#include "router.h"#define _DFFNXFUN_SOURCE_#include "dffnxfun.h"/* =========================================   *****************************************      INTERNALLY VISIBLE FUNCTION HEADERS   =========================================   ***************************************** */static void PrintDeffunctionCall(void *,char *,void *);static intBool EvaluateDeffunctionCall(void *,void *,DATA_OBJECT *);static void DecrementDeffunctionBusyCount(void *,void *);static void IncrementDeffunctionBusyCount(void *,void *);static void DeallocateDeffunctionData(void *);#if ! RUN_TIMEstatic void DestroyDeffunctionAction(void *,struct constructHeader *,void *);static void *AllocateModule(void *);static void  ReturnModule(void *,void *);static intBool ClearDeffunctionsReady(void *);#endif#if (! BLOAD_ONLY) && (! RUN_TIME)static intBool RemoveAllDeffunctions(void *);static void DeffunctionDeleteError(void *,char *);static void SaveDeffunctionHeaders(void *,void *,char *);static void SaveDeffunctionHeader(void *,struct constructHeader *,void *);static void SaveDeffunctions(void *,void *,char *);#endif#if DEBUGGING_FUNCTIONSstatic unsigned DeffunctionWatchAccess(void *,int,unsigned,EXPRESSION *);static unsigned DeffunctionWatchPrint(void *,char *,int,EXPRESSION *);#endif/* =========================================   *****************************************          EXTERNALLY VISIBLE FUNCTIONS   =========================================   ***************************************** *//***************************************************  NAME         : SetupDeffunctions  DESCRIPTION  : Initializes parsers and access                 functions for deffunctions  INPUTS       : None  RETURNS      : Nothing useful  SIDE EFFECTS : Deffunction environment initialized  NOTES        : None ***************************************************/globle void SetupDeffunctions(  void *theEnv)  {   ENTITY_RECORD deffunctionEntityRecord =                     { "PCALL", PCALL,0,0,1,                       PrintDeffunctionCall,PrintDeffunctionCall,                       NULL,EvaluateDeffunctionCall,NULL,                       DecrementDeffunctionBusyCount,IncrementDeffunctionBusyCount,                       NULL,NULL,NULL,NULL,NULL };   AllocateEnvironmentData(theEnv,DEFFUNCTION_DATA,sizeof(struct deffunctionData),DeallocateDeffunctionData);   memcpy(&DeffunctionData(theEnv)->DeffunctionEntityRecord,&deffunctionEntityRecord,sizeof(struct entityRecord));      InstallPrimitive(theEnv,&DeffunctionData(theEnv)->DeffunctionEntityRecord,PCALL);   DeffunctionData(theEnv)->DeffunctionModuleIndex =                RegisterModuleItem(theEnv,"deffunction",#if (! RUN_TIME)                                    AllocateModule,ReturnModule,#else                                    NULL,NULL,#endif#if BLOAD_AND_BSAVE || BLOAD || BLOAD_ONLY                                    BloadDeffunctionModuleReference,#else                                    NULL,#endif#if CONSTRUCT_COMPILER && (! RUN_TIME)                                    DeffunctionCModuleReference,#else                                    NULL,#endif                                    EnvFindDeffunction);   DeffunctionData(theEnv)->DeffunctionConstruct = AddConstruct(theEnv,"deffunction","deffunctions",#if (! BLOAD_ONLY) && (! RUN_TIME)                                       ParseDeffunction,#else                                       NULL,#endif                                       EnvFindDeffunction,                                       GetConstructNamePointer,GetConstructPPForm,                                       GetConstructModuleItem,EnvGetNextDeffunction,                                       SetNextConstruct,EnvIsDeffunctionDeletable,                                       EnvUndeffunction,#if (! BLOAD_ONLY) && (! RUN_TIME)                                       RemoveDeffunction#else                                       NULL#endif                                       );#if ! RUN_TIME   AddClearReadyFunction(theEnv,"deffunction",ClearDeffunctionsReady,0);#if ! BLOAD_ONLY#if DEFMODULE_CONSTRUCT   AddPortConstructItem(theEnv,"deffunction",SYMBOL);#endif   AddSaveFunction(theEnv,"deffunction-headers",SaveDeffunctionHeaders,1000);   AddSaveFunction(theEnv,"deffunctions",SaveDeffunctions,0);   EnvDefineFunction2(theEnv,"undeffunction",'v',PTIEF UndeffunctionCommand,"UndeffunctionCommand","11w");#endif#if DEBUGGING_FUNCTIONS   EnvDefineFunction2(theEnv,"list-deffunctions",'v',PTIEF ListDeffunctionsCommand,"ListDeffunctionsCommand","01");   EnvDefineFunction2(theEnv,"ppdeffunction",'v',PTIEF PPDeffunctionCommand,"PPDeffunctionCommand","11w");#endif   EnvDefineFunction2(theEnv,"get-deffunction-list",'m',PTIEF GetDeffunctionListFunction,                   "GetDeffunctionListFunction","01");   EnvDefineFunction2(theEnv,"deffunction-module",'w',PTIEF GetDeffunctionModuleCommand,                   "GetDeffunctionModuleCommand","11w");#if BLOAD_AND_BSAVE || BLOAD || BLOAD_ONLY   SetupDeffunctionsBload(theEnv);#endif#if CONSTRUCT_COMPILER   SetupDeffunctionCompiler(theEnv);#endif#endif#if DEBUGGING_FUNCTIONS   AddWatchItem(theEnv,"deffunctions",0,&DeffunctionData(theEnv)->WatchDeffunctions,32,                DeffunctionWatchAccess,DeffunctionWatchPrint);#endif  }  /******************************************************//* DeallocateDeffunctionData: Deallocates environment *//*    data for the deffunction construct.             *//******************************************************/static void DeallocateDeffunctionData(  void *theEnv)  {#if ! RUN_TIME   struct deffunctionModule *theModuleItem;   void *theModule;#if BLOAD || BLOAD_AND_BSAVE   if (Bloaded(theEnv)) return;#endif   DoForAllConstructs(theEnv,DestroyDeffunctionAction,DeffunctionData(theEnv)->DeffunctionModuleIndex,FALSE,NULL);    for (theModule = EnvGetNextDefmodule(theEnv,NULL);        theModule != NULL;        theModule = EnvGetNextDefmodule(theEnv,theModule))     {      theModuleItem = (struct deffunctionModule *)                      GetModuleItem(theEnv,(struct defmodule *) theModule,                                    DeffunctionData(theEnv)->DeffunctionModuleIndex);      rtn_struct(theEnv,deffunctionModule,theModuleItem);     }#else#if MAC_MCW || IBM_MCW || MAC_XCD#pragma unused(theEnv)#endif#endif  }  #if ! RUN_TIME/*****************************************************//* DestroyDeffunctionAction: Action used to remove   *//*   deffunctions as a result of DestroyEnvironment. *//*****************************************************/#if IBM_TBC#pragma argsused#endifstatic void DestroyDeffunctionAction(  void *theEnv,  struct constructHeader *theConstruct,  void *buffer)  {#if MAC_MCW || IBM_MCW || MAC_XCD#pragma unused(buffer)#endif#if (! BLOAD_ONLY) && (! RUN_TIME)   struct deffunctionStruct *theDeffunction = (struct deffunctionStruct *) theConstruct;      if (theDeffunction == NULL) return;      ReturnPackedExpression(theEnv,theDeffunction->code);   DestroyConstructHeader(theEnv,&theDeffunction->header);      rtn_struct(theEnv,deffunctionStruct,theDeffunction);#else#if MAC_MCW || IBM_MCW || MAC_XCD#pragma unused(theConstruct,theEnv)#endif#endif  }#endif/***************************************************  NAME         : EnvFindDeffunction  DESCRIPTION  : Searches for a deffunction  INPUTS       : The name of the deffunction                 (possibly including a module name)  RETURNS      : Pointer to the deffunction if                 found, otherwise NULL  SIDE EFFECTS : None  NOTES        : None ***************************************************/globle void *EnvFindDeffunction(  void *theEnv,  char *dfnxModuleAndName)  {   return(FindNamedConstruct(theEnv,dfnxModuleAndName,DeffunctionData(theEnv)->DeffunctionConstruct));  }/***************************************************  NAME         : LookupDeffunctionByMdlOrScope  DESCRIPTION  : Finds a deffunction anywhere (if                 module is specified) or in current                 or imported modules  INPUTS       : The deffunction name  RETURNS      : The deffunction (NULL if not found)  SIDE EFFECTS : Error message printed on                  ambiguous references  NOTES        : None ***************************************************/globle DEFFUNCTION *LookupDeffunctionByMdlOrScope(  void *theEnv,  char *deffunctionName)  {   return((DEFFUNCTION *) LookupConstruct(theEnv,DeffunctionData(theEnv)->DeffunctionConstruct,deffunctionName,TRUE));  }/***************************************************  NAME         : LookupDeffunctionInScope  DESCRIPTION  : Finds a deffunction in current or                   imported modules (module                   specifier is not allowed)  INPUTS       : The deffunction name  RETURNS      : The deffunction (NULL if not found)  SIDE EFFECTS : Error message printed on                  ambiguous references  NOTES        : None ***************************************************/globle DEFFUNCTION *LookupDeffunctionInScope(  void *theEnv,  char *deffunctionName)  {   return((DEFFUNCTION *) LookupConstruct(theEnv,DeffunctionData(theEnv)->DeffunctionConstruct,deffunctionName,FALSE));  }/***************************************************  NAME         : EnvUndeffunction  DESCRIPTION  : External interface routine for                 removing a deffunction  INPUTS       : Deffunction pointer  RETURNS      : FALSE if unsuccessful,                 TRUE otherwise  SIDE EFFECTS : Deffunction deleted, if possible  NOTES        : None ***************************************************/globle intBool EnvUndeffunction(  void *theEnv,  void *vptr)  {#if (MAC_MCW || IBM_MCW) && (RUN_TIME || BLOAD_ONLY)#pragma unused(theEnv,vptr)#endif

⌨️ 快捷键说明

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