📄 rulecom.c
字号:
PrintLongInteger(theEnv,WDISPLAY,(long int) i + 1);
EnvPrintRouter(theEnv,WDISPLAY,"\n");
listOfMatches = theStorage[i];
if (listOfMatches == NULL) EnvPrintRouter(theEnv,WDISPLAY," None\n");
while (listOfMatches != NULL)
{
if (GetHaltExecution(theEnv) == TRUE)
{
genfree(theEnv,theStorage,(unsigned) (depth * sizeof(struct partialMatch)));
return(TRUE);
}
PrintPartialMatch(theEnv,WDISPLAY,listOfMatches);
EnvPrintRouter(theEnv,WDISPLAY,"\n");
listOfMatches = listOfMatches->next;
}
}
genfree(theEnv,theStorage,(unsigned) (depth * sizeof(struct partialMatch)));
/*========================================*/
/* Store the beta memory partial matches. */
/*========================================*/
depth = lastJoin->depth;
theStorage = (struct partialMatch **) genalloc(theEnv,(unsigned) (depth * sizeof(struct partialMatch)));
theJoin = lastJoin;
for (i = depth - 1; i >= 0; i--)
{
theStorage[i] = theJoin->beta;
theJoin = theJoin->lastLevel;
}
/*=======================================*/
/* List the beta memory partial matches. */
/*=======================================*/
for (i = 1; i < depth; i++)
{
if (GetHaltExecution(theEnv) == TRUE)
{
genfree(theEnv,theStorage,(unsigned) (depth * sizeof(struct partialMatch)));
return(TRUE);
}
matchesDisplayed = 0;
EnvPrintRouter(theEnv,WDISPLAY,"Partial matches for CEs 1 - ");
PrintLongInteger(theEnv,WDISPLAY,(long int) i + 1);
EnvPrintRouter(theEnv,WDISPLAY,"\n");
listOfMatches = theStorage[i];
while (listOfMatches != NULL)
{
if (GetHaltExecution(theEnv) == TRUE)
{
genfree(theEnv,theStorage,(unsigned) (depth * sizeof(struct partialMatch)));
return(TRUE);
}
if (listOfMatches->counterf == FALSE)
{
matchesDisplayed++;
PrintPartialMatch(theEnv,WDISPLAY,listOfMatches);
EnvPrintRouter(theEnv,WDISPLAY,"\n");
}
listOfMatches = listOfMatches->next;
}
if (matchesDisplayed == 0) { EnvPrintRouter(theEnv,WDISPLAY," None\n"); }
}
genfree(theEnv,theStorage,(unsigned) (depth * sizeof(struct partialMatch)));
}
/*===================*/
/* List activations. */
/*===================*/
rulePtr = tmpPtr;
EnvPrintRouter(theEnv,WDISPLAY,"Activations\n");
flag = 1;
for (agendaPtr = (struct activation *) EnvGetNextActivation(theEnv,NULL);
agendaPtr != NULL;
agendaPtr = (struct activation *) EnvGetNextActivation(theEnv,agendaPtr))
{
if (GetHaltExecution(theEnv) == TRUE) return(TRUE);
if (((struct activation *) agendaPtr)->theRule->header.name == rulePtr->header.name)
{
flag = 0;
PrintPartialMatch(theEnv,WDISPLAY,GetActivationBasis(agendaPtr));
EnvPrintRouter(theEnv,WDISPLAY,"\n");
}
}
if (flag) EnvPrintRouter(theEnv,WDISPLAY," None\n");
return(TRUE);
}
#endif /* DEBUGGING_FUNCTIONS */
#if DEVELOPER
/***********************************************/
/* RuleComplexityCommand: H/L access routine */
/* for the rule-complexity function. */
/***********************************************/
globle long RuleComplexityCommand(
void *theEnv)
{
char *ruleName;
struct defrule *rulePtr;
ruleName = GetConstructName(theEnv,"rule-complexity","rule name");
if (ruleName == NULL) return(-1);
rulePtr = (struct defrule *) EnvFindDefrule(theEnv,ruleName);
if (rulePtr == NULL)
{
CantFindItemErrorMessage(theEnv,"defrule",ruleName);
return(-1);
}
return(rulePtr->complexity);
}
/******************************************/
/* ShowJoinsCommand: H/L access routine */
/* for the show-joins command. */
/******************************************/
globle void ShowJoinsCommand(
void *theEnv)
{
char *ruleName;
void *rulePtr;
ruleName = GetConstructName(theEnv,"show-joins","rule name");
if (ruleName == NULL) return;
rulePtr = EnvFindDefrule(theEnv,ruleName);
if (rulePtr == NULL)
{
CantFindItemErrorMessage(theEnv,"defrule",ruleName);
return;
}
ShowJoins(theEnv,rulePtr);
return;
}
/*********************************/
/* ShowJoins: C access routine */
/* for the show-joins command. */
/*********************************/
static void ShowJoins(
void *theEnv,
void *theRule)
{
struct defrule *rulePtr;
struct joinNode *theJoin;
struct joinNode *joinList[MAXIMUM_NUMBER_OF_PATTERNS];
int numberOfJoins;
rulePtr = (struct defrule *) theRule;
/*=================================================*/
/* Loop through each of the disjuncts for the rule */
/*=================================================*/
while (rulePtr != NULL)
{
/*=====================================*/
/* Determine the number of join nodes. */
/*=====================================*/
numberOfJoins = -1;
theJoin = rulePtr->lastJoin;
while (theJoin != NULL)
{
if (theJoin->joinFromTheRight)
{ theJoin = (struct joinNode *) theJoin->rightSideEntryStructure; }
else
{
numberOfJoins++;
joinList[numberOfJoins] = theJoin;
theJoin = theJoin->lastLevel;
}
}
/*====================*/
/* Display the joins. */
/*====================*/
while (numberOfJoins >= 0)
{
char buffer[20];
sprintf(buffer,"%2d%c%c: ",(int) joinList[numberOfJoins]->depth,
(joinList[numberOfJoins]->patternIsNegated) ? 'n' : ' ',
(joinList[numberOfJoins]->logicalJoin) ? 'l' : ' ');
EnvPrintRouter(theEnv,WDISPLAY,buffer);
PrintExpression(theEnv,WDISPLAY,joinList[numberOfJoins]->networkTest);
EnvPrintRouter(theEnv,WDISPLAY,"\n");
numberOfJoins--;
};
/*===============================*/
/* Proceed to the next disjunct. */
/*===============================*/
rulePtr = rulePtr->disjunct;
if (rulePtr != NULL) EnvPrintRouter(theEnv,WDISPLAY,"\n");
}
}
#endif /* DEVELOPER */
#endif /* DEFRULE_CONSTRUCT */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -