📄 rulecmp.c
字号:
FILE *theFile; struct defmodule *theModule; int imageID; int maxIndices; int moduleCount; { #if MAC_MPW || MAC_MCW#pragma unused(moduleCount)#endif fprintf(theFile,"{"); ConstructModuleToCode(theFile,theModule,imageID,maxIndices, DefruleModuleIndex,ConstructPrefix(DefruleCodeItem)); fprintf(theFile,",NULL}"); } /**********************************************************//* DefruleToCode: Writes the C code representation of a *//* single defrule data structure to the specified file. *//**********************************************************/static VOID DefruleToCode(theFile,theDefrule,imageID,maxIndices,moduleCount) FILE *theFile; struct defrule *theDefrule; int imageID; int maxIndices; int moduleCount; { /*==================*/ /* Construct Header */ /*==================*/ fprintf(theFile,"{"); ConstructHeaderToCode(theFile,&theDefrule->header,imageID,maxIndices, moduleCount,ModulePrefix(DefruleCodeItem), ConstructPrefix(DefruleCodeItem)); /*==========================*/ /* Flags and Integer Values */ /*==========================*/ fprintf(theFile,",%d,%d,%d,%d,%d,%d,%d,%d,", theDefrule->salience,theDefrule->localVarCnt, theDefrule->complexity,theDefrule->afterBreakpoint, theDefrule->watchActivation,theDefrule->watchFiring, theDefrule->autoFocus,theDefrule->executing); /*==================*/ /* Dynamic Salience */ /*==================*/ #if DYNAMIC_SALIENCE ExpressionToCode(theFile,theDefrule->dynamicSalience); fprintf(theFile,",");#endif /*=============*/ /* RHS Actions */ /*=============*/ ExpressionToCode(theFile,theDefrule->actions); fprintf(theFile,","); /*=========================*/ /* Logical Dependency Join */ /*=========================*/ #if LOGICAL_DEPENDENCIES if (theDefrule->logicalJoin != NULL) { fprintf(theFile,"&%s%d_%ld[%ld],",JoinPrefix(), imageID,(theDefrule->logicalJoin->bsaveID / maxIndices) + 1, theDefrule->logicalJoin->bsaveID % maxIndices); } else { fprintf(theFile,"NULL,"); }#endif /*===========*/ /* Last Join */ /*===========*/ if (theDefrule->lastJoin != NULL) { fprintf(theFile,"&%s%d_%ld[%ld],",JoinPrefix(), imageID,(theDefrule->lastJoin->bsaveID / maxIndices) + 1, theDefrule->lastJoin->bsaveID % maxIndices); } else { fprintf(theFile,"NULL,"); } /*===============*/ /* Next Disjunct */ /*===============*/ if (theDefrule->disjunct != NULL) { fprintf(theFile,"&%s%d_%ld[%ld]}",ConstructPrefix(DefruleCodeItem), imageID,(theDefrule->disjunct->header.bsaveID / maxIndices) + 1, theDefrule->disjunct->header.bsaveID % maxIndices); } else { fprintf(theFile,"NULL}"); } } /***************************************************//* JoinToCode: Writes the C code representation of *//* a single join node to the specified file. *//***************************************************/static VOID JoinToCode(theFile,theJoin,imageID,maxIndices) FILE *theFile; struct joinNode *theJoin; int imageID; int maxIndices; { struct patternParser *theParser; /*===========================*/ /* Mark the join as visited. */ /*===========================*/ theJoin->marked = 0; /*===========================*/ /* Flags and Integer Values. */ /*===========================*/ fprintf(theFile,"{%d,%d,%d,%d,0,0,%d,%d,0,", theJoin->firstJoin,theJoin->logicalJoin, theJoin->joinFromTheRight,theJoin->patternIsNegated, theJoin->rhsType,theJoin->depth); /*==============*/ /* Beta Memory. */ /*==============*/ fprintf(theFile,"NULL,"); /*====================*/ /* Network Expression */ /*====================*/ PrintHashedExpressionReference(theFile,theJoin->networkTest,imageID,maxIndices); fprintf(theFile,","); /*============================*/ /* Right Side Entry Structure */ /*============================*/ if (theJoin->rightSideEntryStructure == NULL) { fprintf(theFile,"NULL,"); } else if (theJoin->joinFromTheRight == CLIPS_FALSE) { theParser = GetPatternParser((int) theJoin->rhsType); if (theParser->codeReferenceFunction == NULL) fprintf(theFile,"NULL,"); else { fprintf(theFile,"VS "); (*theParser->codeReferenceFunction)(theJoin->rightSideEntryStructure, theFile,imageID,maxIndices); fprintf(theFile,","); } } else { fprintf(theFile,"&%s%d_%ld[%ld],",JoinPrefix(), imageID,(((struct joinNode *) theJoin->rightSideEntryStructure)->bsaveID / maxIndices) + 1, ((struct joinNode *) theJoin->rightSideEntryStructure)->bsaveID % maxIndices); } /*=================*/ /* Next Join Level */ /*=================*/ if (theJoin->nextLevel == NULL) { fprintf(theFile,"NULL,"); } else { fprintf(theFile,"&%s%d_%ld[%ld],",JoinPrefix(), imageID,(theJoin->nextLevel->bsaveID / maxIndices) + 1, theJoin->nextLevel->bsaveID % maxIndices); } /*=================*/ /* Last Join Level */ /*=================*/ if (theJoin->lastLevel == NULL) { fprintf(theFile,"NULL,"); } else { fprintf(theFile,"&%s%d_%ld[%ld],",JoinPrefix(), imageID,(theJoin->lastLevel->bsaveID / maxIndices) + 1, theJoin->lastLevel->bsaveID % maxIndices); } /*==================*/ /* Right Drive Node */ /*==================*/ if (theJoin->rightDriveNode == NULL) { fprintf(theFile,"NULL,"); } else { fprintf(theFile,"&%s%d_%ld[%ld],",JoinPrefix(), imageID,(theJoin->rightDriveNode->bsaveID / maxIndices) + 1, theJoin->rightDriveNode->bsaveID % maxIndices); } /*==================*/ /* Right Match Node */ /*==================*/ if (theJoin->rightMatchNode == NULL) { fprintf(theFile,"NULL,"); } else { fprintf(theFile,"&%s%d_%ld[%ld],",JoinPrefix(), imageID,(theJoin->rightMatchNode->bsaveID / maxIndices) + 1, theJoin->rightMatchNode->bsaveID % maxIndices); } /*==================*/ /* Rule to Activate */ /*==================*/ if (theJoin->ruleToActivate == NULL) { fprintf(theFile,"NULL}"); } else { fprintf(theFile,"&%s%d_%ld[%ld]}",ConstructPrefix(DefruleCodeItem),imageID, (theJoin->ruleToActivate->header.bsaveID / maxIndices) + 1, theJoin->ruleToActivate->header.bsaveID % maxIndices); } }/*************************************************************//* DefruleCModuleReference: Writes the C code representation *//* of a reference to a defrule module data structure. *//*************************************************************/globle VOID DefruleCModuleReference(theFile,count,imageID,maxIndices) FILE *theFile; int count; int imageID; int maxIndices; { fprintf(theFile,"MIHS &%s%d_%d[%d]",ModulePrefix(DefruleCodeItem), imageID, (count / maxIndices) + 1, (count % maxIndices)); }#endif /* DEFRULE_CONSTRUCT && (! RUN_TIME) && CONSTRUCT_COMPILER */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -