📄 dffnxfun.c
字号:
/*******************************************************/ /* "C" Language Integrated Production System */ /* */ /* CLIPS Version 6.05 04/09/97 */ /* */ /* DEFFUNCTION MODULE */ /*******************************************************//*************************************************************//* Purpose: *//* *//* Principal Programmer(s): *//* Brian L. Donnell *//* *//* Contributing Programmer(s): *//* Gary D. Riley *//* *//* Revision History: *//* *//*************************************************************//* ========================================= ***************************************** 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#if (! RUN_TIME)#include "extnfunc.h"#endif#include "dffnxexe.h"#if DEBUGGING_FUNCTIONS#include "watch.h"#endif#include "argacces.h"#include "clipsmem.h"#include "cstrccom.h"#include "router.h"#define _DFFNXFUN_SOURCE_#include "dffnxfun.h"/* ========================================= ***************************************** CONSTANTS ========================================= ***************************************** *//* ========================================= ***************************************** MACROS AND TYPES ========================================= ***************************************** */ /* ========================================= ***************************************** INTERNALLY VISIBLE FUNCTION HEADERS ========================================= ***************************************** */#if ANSI_COMPILERstatic VOID PrintDeffunctionCall(char *,VOID *);static BOOLEAN EvaluateDeffunctionCall(VOID *,DATA_OBJECT *);static VOID DecrementDeffunctionBusyCount(VOID *);static VOID IncrementDeffunctionBusyCount(VOID *);#if ! RUN_TIMEstatic VOID *AllocateModule(void);static VOID FreeModule(VOID *);static BOOLEAN ClearDeffunctionsReady(void);#endif#if (! BLOAD_ONLY) && (! RUN_TIME)static BOOLEAN RemoveAllDeffunctions(void);static VOID DeffunctionDeleteError(char *);static VOID SaveDeffunctionHeaders(char *);static VOID SaveDeffunctionHeader(struct constructHeader *,VOID *);static VOID SaveDeffunctions(char *);#endif#if DEBUGGING_FUNCTIONSstatic BOOLEAN DeffunctionWatchAccess(int,int,EXPRESSION *);static BOOLEAN DeffunctionWatchPrint(char *,int,EXPRESSION *);#endif#elsestatic VOID PrintDeffunctionCall();static BOOLEAN EvaluateDeffunctionCall();static VOID DecrementDeffunctionBusyCount();static VOID IncrementDeffunctionBusyCount();#if ! RUN_TIMEstatic VOID *AllocateModule();static VOID FreeModule();static BOOLEAN ClearDeffunctionsReady();#endif#if (! BLOAD_ONLY) && (! RUN_TIME)static VOID DeffunctionDeleteError();static VOID SaveDeffunctionHeaders();static VOID SaveDeffunctionHeader();static VOID SaveDeffunctions();#endif#if DEBUGGING_FUNCTIONSstatic BOOLEAN RemoveAllDeffunctions();static BOOLEAN DeffunctionWatchAccess();static BOOLEAN DeffunctionWatchPrint();#endif#endif/* ========================================= ***************************************** EXTERNALLY VISIBLE GLOBAL VARIABLES ========================================= ***************************************** */globle struct construct *DeffunctionConstruct;globle int DeffunctionModuleIndex;#if DEBUGGING_FUNCTIONSgloble BOOLEAN WatchDeffunctions = OFF;#endif/* ========================================= ***************************************** INTERNALLY VISIBLE GLOBAL VARIABLES ========================================= ***************************************** */static ENTITY_RECORD DeffunctionEntityRecord = { PCALL,0,0,1, PrintDeffunctionCall,PrintDeffunctionCall, NULL,EvaluateDeffunctionCall,NULL, DecrementDeffunctionBusyCount,IncrementDeffunctionBusyCount, NULL,NULL,NULL,NULL };/* ========================================= ***************************************** 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() { InstallPrimitive(&DeffunctionEntityRecord,PCALL); DeffunctionModuleIndex = RegisterModuleItem("deffunction",#if (! RUN_TIME) AllocateModule,FreeModule,#else NULL,NULL,#endif#if BLOAD_AND_BSAVE || BLOAD || BLOAD_ONLY BloadDeffunctionModuleReference,#else NULL,#endif#if CONSTRUCT_COMPILER && (! RUN_TIME) DeffunctionCModuleReference,#else NULL,#endif FindDeffunction); DeffunctionConstruct = AddConstruct("deffunction","deffunctions",#if (! BLOAD_ONLY) && (! RUN_TIME) ParseDeffunction,#else NULL,#endif FindDeffunction, GetConstructNamePointer,GetConstructPPForm, GetConstructModuleItem,GetNextDeffunction, SetNextConstruct,IsDeffunctionDeletable, Undeffunction,#if (! BLOAD_ONLY) && (! RUN_TIME) RemoveDeffunction#else NULL#endif );#if ! RUN_TIME AddClearReadyFunction("deffunction",ClearDeffunctionsReady,0);#if ! BLOAD_ONLY#if DEFMODULE_CONSTRUCT AddPortConstructItem("deffunction",SYMBOL);#endif AddSaveFunction("deffunction-headers",SaveDeffunctionHeaders,1000); AddSaveFunction("deffunctions",SaveDeffunctions,0); DefineFunction2("undeffunction",'v',PTIF UndeffunctionCommand,"UndeffunctionCommand","11w");#endif#if DEBUGGING_FUNCTIONS DefineFunction2("list-deffunctions",'v',PTIF ListDeffunctionsCommand,"ListDeffunctionsCommand","01"); DefineFunction2("ppdeffunction",'v',PTIF PPDeffunctionCommand,"PPDeffunctionCommand","11w");#endif DefineFunction2("get-deffunction-list",'m',PTIF GetDeffunctionListFunction, "GetDeffunctionListFunction","01"); DefineFunction2("deffunction-module",'w',PTIF GetDeffunctionModuleCommand, "GetDeffunctionModuleCommand","11w"); #if BLOAD_AND_BSAVE || BLOAD || BLOAD_ONLY SetupDeffunctionsBload();#endif#if CONSTRUCT_COMPILER SetupDeffunctionCompiler();#endif#endif#if DEBUGGING_FUNCTIONS AddWatchItem("deffunctions",0,&WatchDeffunctions,32, DeffunctionWatchAccess,DeffunctionWatchPrint);#endif }/*************************************************** NAME : FindDeffunction 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 *FindDeffunction(dfnxModuleAndName) char *dfnxModuleAndName; { return(FindNamedConstruct(dfnxModuleAndName,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(deffunctionName) char *deffunctionName; { return((DEFFUNCTION *) LookupConstruct(DeffunctionConstruct,deffunctionName,CLIPS_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(deffunctionName) char *deffunctionName; { return((DEFFUNCTION *) LookupConstruct(DeffunctionConstruct,deffunctionName,CLIPS_FALSE)); } /*************************************************** NAME : Undeffunction DESCRIPTION : External interface routine for removing a deffunction INPUTS : Deffunction pointer RETURNS : CLIPS_FALSE if unsuccessful, CLIPS_TRUE otherwise SIDE EFFECTS : Deffunction deleted, if possible NOTES : None ***************************************************/globle BOOLEAN Undeffunction(vptr) VOID *vptr; {#if (MAC_MPW || MAC_MCW) && (RUN_TIME || BLOAD_ONLY)#pragma unused(vptr)#endif#if BLOAD_ONLY || RUN_TIME return(CLIPS_FALSE);#else#if BLOAD || BLOAD_AND_BSAVE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -