?? developr.c
字號:
/*******************************************************/ /* "C" Language Integrated Production System */ /* */ /* CLIPS Version 6.30 10/19/06 */ /* */ /* DEVELOPER MODULE */ /*******************************************************//*************************************************************//* Purpose: Provides routines useful for browsing various *//* data structures. The functions are provided for *//* development use. *//* *//* Principal Programmer(s): *//* Gary D. Riley *//* *//* Contributing Programmer(s): *//* *//* Revision History: *//* *//* 6.24: Converted INSTANCE_PATTERN_MATCHING to *//* DEFRULE_CONSTRUCT. *//* *//* 6.30: Added support for hashed alpha memories. *//* *//*************************************************************/#define _DEVELOPR_SOURCE_#include <stdio.h>#define _STDIO_INCLUDED_#include "setup.h"#include "argacces.h"#include "envrnmnt.h"#include "extnfunc.h"#include "inscom.h"#include "modulutl.h"#include "router.h"#include "utility.h"#if DEFRULE_CONSTRUCT && DEFTEMPLATE_CONSTRUCT#include "tmpltdef.h"#include "factbld.h"#include "facthsh.h"#endif#if DEFRULE_CONSTRUCT && OBJECT_SYSTEM#include "classcom.h"#include "classfun.h"#include "objrtmch.h"#endif#if OBJECT_SYSTEM#include "insfun.h"#endif#include "developr.h"#if DEVELOPER#if DEFRULE_CONSTRUCT && OBJECT_SYSTEMstatic void PrintOPNLevel(void *theEnv,OBJECT_PATTERN_NODE *,char *,int);#endif/**************************************************//* DeveloperCommands: Sets up developer commands. *//**************************************************/globle void DeveloperCommands( void *theEnv) {#if ! RUN_TIME EnvDefineFunction2(theEnv,"primitives-info",'v', PTIEF PrimitiveTablesInfo,"PrimitiveTablesInfo","00"); EnvDefineFunction2(theEnv,"primitives-usage",'v', PTIEF PrimitiveTablesUsage,"PrimitiveTablesUsage","00"); EnvDefineFunction2(theEnv,"enable-gc-heuristics",'v', PTIEF EnableGCHeuristics,"EnableGCHeuristics","00"); EnvDefineFunction2(theEnv,"disable-gc-heuristics",'v', PTIEF DisableGCHeuristics,"DisableGCHeuristics","00");#if DEFRULE_CONSTRUCT && DEFTEMPLATE_CONSTRUCT EnvDefineFunction2(theEnv,"show-fpn",'v', PTIEF ShowFactPatternNetwork,"ShowFactPatternNetwork","11w"); EnvDefineFunction2(theEnv,"show-fht",'v', PTIEF ShowFactHashTable,"ShowFactHashTable","00");#endif#if DEFRULE_CONSTRUCT && OBJECT_SYSTEM EnvDefineFunction2(theEnv,"show-opn",'v',PTIEF PrintObjectPatternNetwork, "PrintObjectPatternNetwork","00");#endif#if OBJECT_SYSTEM EnvDefineFunction2(theEnv,"instance-table-usage",'v', PTIEF InstanceTableUsage,"InstanceTableUsage","00");#endif#endif }/******************************************************//* EnableGCHeuristics: *//******************************************************/globle void EnableGCHeuristics( void *theEnv) { EnvArgCountCheck(theEnv,"enable-gc-heuristics",EXACTLY,0); SetGarbageCollectionHeuristics(theEnv,TRUE); } /******************************************************//* DisableGCHeuristics: *//******************************************************/globle void DisableGCHeuristics( void *theEnv) { EnvArgCountCheck(theEnv,"disable-gc-heuristics",EXACTLY,0); SetGarbageCollectionHeuristics(theEnv,FALSE); }/******************************************************//* PrimitiveTablesInfo: Prints information about the *//* symbol, float, integer, and bitmap tables. *//******************************************************/globle void PrimitiveTablesInfo( void *theEnv) { unsigned long i; SYMBOL_HN **symbolArray, *symbolPtr; FLOAT_HN **floatArray, *floatPtr; INTEGER_HN **integerArray, *integerPtr; BITMAP_HN **bitMapArray, *bitMapPtr; unsigned long int symbolCount = 0, integerCount = 0; unsigned long int floatCount = 0, bitMapCount = 0; EnvArgCountCheck(theEnv,"primitives-info",EXACTLY,0); /*====================================*/ /* Count entries in the symbol table. */ /*====================================*/ symbolArray = GetSymbolTable(theEnv); for (i = 0; i < SYMBOL_HASH_SIZE; i++) { for (symbolPtr = symbolArray[i]; symbolPtr != NULL; symbolPtr = symbolPtr->next) { symbolCount++; } } /*====================================*/ /* Count entries in the integer table. */ /*====================================*/ integerArray = GetIntegerTable(theEnv); for (i = 0; i < INTEGER_HASH_SIZE; i++) { for (integerPtr = integerArray[i]; integerPtr != NULL; integerPtr = integerPtr->next) { integerCount++; } } /*====================================*/ /* Count entries in the float table. */ /*====================================*/ floatArray = GetFloatTable(theEnv); for (i = 0; i < FLOAT_HASH_SIZE; i++) { for (floatPtr = floatArray[i]; floatPtr != NULL; floatPtr = floatPtr->next) { floatCount++; } } /*====================================*/ /* Count entries in the bitmap table. */ /*====================================*/ bitMapArray = GetBitMapTable(theEnv); for (i = 0; i < BITMAP_HASH_SIZE; i++) { for (bitMapPtr = bitMapArray[i]; bitMapPtr != NULL; bitMapPtr = bitMapPtr->next) { bitMapCount++; } } /*========================*/ /* Print the information. */ /*========================*/ EnvPrintRouter(theEnv,WDISPLAY,"Symbols: "); PrintLongInteger(theEnv,WDISPLAY,(long long) symbolCount); EnvPrintRouter(theEnv,WDISPLAY,"\n"); EnvPrintRouter(theEnv,WDISPLAY,"Integers: "); PrintLongInteger(theEnv,WDISPLAY,(long long) integerCount); EnvPrintRouter(theEnv,WDISPLAY,"\n"); EnvPrintRouter(theEnv,WDISPLAY,"Floats: "); PrintLongInteger(theEnv,WDISPLAY,(long long) floatCount); EnvPrintRouter(theEnv,WDISPLAY,"\n"); EnvPrintRouter(theEnv,WDISPLAY,"BitMaps: "); PrintLongInteger(theEnv,WDISPLAY,(long long) bitMapCount); EnvPrintRouter(theEnv,WDISPLAY,"\n"); /* EnvPrintRouter(theEnv,WDISPLAY,"Ephemerals: "); PrintLongInteger(theEnv,WDISPLAY,(long long) EphemeralSymbolCount()); EnvPrintRouter(theEnv,WDISPLAY,"\n"); */ } #define COUNT_SIZE 21/******************************************************//* PrimitiveTablesUsage: Prints information about the *//* symbol, float, integer, and bitmap tables. *//******************************************************/globle void PrimitiveTablesUsage( void *theEnv) { unsigned long i; int symbolCounts[COUNT_SIZE], floatCounts[COUNT_SIZE]; SYMBOL_HN **symbolArray, *symbolPtr; FLOAT_HN **floatArray, *floatPtr; unsigned long int symbolCount, totalSymbolCount = 0; unsigned long int floatCount, totalFloatCount = 0; EnvArgCountCheck(theEnv,"primitives-usage",EXACTLY,0); for (i = 0; i < 21; i++) { symbolCounts[i] = 0; floatCounts[i] = 0; } /*====================================*/ /* Count entries in the symbol table. */ /*====================================*/ symbolArray = GetSymbolTable(theEnv); for (i = 0; i < SYMBOL_HASH_SIZE; i++) { symbolCount = 0; for (symbolPtr = symbolArray[i]; symbolPtr != NULL; symbolPtr = symbolPtr->next) { symbolCount++; totalSymbolCount++; } if (symbolCount < (COUNT_SIZE - 1)) { symbolCounts[symbolCount]++; } else { symbolCounts[COUNT_SIZE - 1]++; } } /*===================================*/ /* Count entries in the float table. */ /*===================================*/ floatArray = GetFloatTable(theEnv); for (i = 0; i < FLOAT_HASH_SIZE; i++) { floatCount = 0; for (floatPtr = floatArray[i]; floatPtr != NULL; floatPtr = floatPtr->next) { floatCount++; totalFloatCount++; } if (floatCount < (COUNT_SIZE - 1)) { floatCounts[floatCount]++; } else { floatCounts[COUNT_SIZE - 1]++; } } /*========================*/
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -