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

📄 generate.c

📁 clips源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
   /* expression generated.                         */   /*===============================================*/   if (theField->patternType->genJNConstantFunction != NULL)     {       if (isNand)        { return (*theField->patternType->genJNConstantFunction)(theEnv,theField,NESTED_RHS); }      else        { return (*theField->patternType->genJNConstantFunction)(theEnv,theField,RHS); }     }   /*===================================================*/   /* Otherwise, generate a test which uses the eq/neq  */   /* function to compare the pattern field/slot to the */   /* constant and then return the expression.          */   /*===================================================*/   if (theField->negated)     { top = GenConstant(theEnv,FCALL,ExpressionData(theEnv)->PTR_NEQ); }   else     { top = GenConstant(theEnv,FCALL,ExpressionData(theEnv)->PTR_EQ); }   if (isNand)      { top->argList = (*theField->patternType->genGetJNValueFunction)(theEnv,theField,NESTED_RHS); }   else      { top->argList = (*theField->patternType->genGetJNValueFunction)(theEnv,theField,RHS); }         top->argList->nextArg = GenConstant(theEnv,theField->type,theField->value);   return(top);  }/******************************************************//* GenJNColon: Generates an expression for use in the *//*  join network. The expression generated is for a   *//*  predicate field constraint (the : constraint).    *//******************************************************/static struct expr *GenJNColon(  void *theEnv,  struct lhsParseNode *theField,  int isNand)  {   struct expr *top, *conversion;   /*==================================================*/   /* Replace variables with function calls to extract */   /* the appropriate value from the data entity.      */   /*==================================================*/   if (isNand)     { conversion = GetvarReplace(theEnv,theField->expression,TRUE); }   else     { conversion = GetvarReplace(theEnv,theField->expression,FALSE); }   /*================================================*/   /* If the predicate constraint is negated by a ~, */   /* then wrap a "not" function call around the     */   /* expression before returning it. Otherwise,     */   /* just return the expression.                    */   /*================================================*/   if (theField->negated)     {      top = GenConstant(theEnv,FCALL,ExpressionData(theEnv)->PTR_NOT);      top->argList = conversion;     }   else     { top = conversion; }   return(top);  }/******************************************************//* GenPNColon: Generates an expression for use in the *//*  pattern network. The expression generated is for  *//*  a predicate field constraint (the : constraint).  *//******************************************************/static struct expr *GenPNColon(  void *theEnv,  struct lhsParseNode *theField)  {   struct expr *top, *conversion;   /*==================================================*/   /* Replace variables with function calls to extract */   /* the appropriate value from the data entity.      */   /*==================================================*/   conversion = GetfieldReplace(theEnv,theField->expression);   /*================================================*/   /* If the predicate constraint is negated by a ~, */   /* then wrap a "not" function call around the     */   /* expression before returning it. Otherwise,     */   /* just return the expression.                    */   /*================================================*/   if (theField->negated)     {      top = GenConstant(theEnv,FCALL,ExpressionData(theEnv)->PTR_NOT);      top->argList = conversion;     }   else     { top = conversion; }   return(top);  }/******************************************************//* GenJNEq: Generates an expression for use in the    *//*  join network. The expression generated is for a   *//*  return value field constraint (the = constraint). *//******************************************************/static struct expr *GenJNEq(  void *theEnv,  struct lhsParseNode *theField,  int isNand)  {   struct expr *top, *conversion;   /*==================================================*/   /* Replace variables with function calls to extract */   /* the appropriate value from the data entity.      */   /*==================================================*/   if (isNand)     { conversion = GetvarReplace(theEnv,theField->expression,TRUE); }   else     { conversion = GetvarReplace(theEnv,theField->expression,FALSE); }   /*============================================================*/   /* If the return value constraint is negated by a ~, then use */   /* the neq function to compare the value of the field to the  */   /* value returned by the function call. Otherwise, use eq to  */   /* compare the two values.                                    */   /*============================================================*/   if (theField->negated)     { top = GenConstant(theEnv,FCALL,ExpressionData(theEnv)->PTR_NEQ); }   else     { top = GenConstant(theEnv,FCALL,ExpressionData(theEnv)->PTR_EQ); }   if (isNand)     { top->argList = (*theField->patternType->genGetJNValueFunction)(theEnv,theField,NESTED_RHS); }   else     { top->argList = (*theField->patternType->genGetJNValueFunction)(theEnv,theField,RHS); }        top->argList->nextArg = conversion;   return(top);  }/*******************************************************//* GenPNEq: Generates an expression for use in the     *//*  pattern network. The expression generated is for a *//*  return value field constraint (the = constraint).  *//*******************************************************/static struct expr *GenPNEq(  void *theEnv,  struct lhsParseNode *theField)  {   struct expr *top, *conversion;   /*==================================================*/   /* Replace variables with function calls to extract */   /* the appropriate value from the data entity.      */   /*==================================================*/   conversion = GetfieldReplace(theEnv,theField->expression);   /*============================================================*/   /* If the return value constraint is negated by a ~, then use */   /* the neq function to compare the value of the field to the  */   /* value returned by the function call. Otherwise, use eq to  */   /* compare the two values.                                    */   /*============================================================*/   if (theField->negated)     { top = GenConstant(theEnv,FCALL,ExpressionData(theEnv)->PTR_NEQ); }   else     { top = GenConstant(theEnv,FCALL,ExpressionData(theEnv)->PTR_EQ); }   top->argList = (*theField->patternType->genGetPNValueFunction)(theEnv,theField);   top->argList->nextArg = conversion;   return(top);  }/*******************************************************************//* GetvarReplace: Replaces occurences of variables in expressions *//*   with function calls that will extract the variable's value    *//*   from a partial match (i.e. from information stored in the     *//*   join network or the activation of the rule).                  *//*******************************************************************/globle struct expr *GetvarReplace(  void *theEnv,  struct lhsParseNode *nodeList,  int isNand)  {   struct expr *newList;   /*====================================*/   /* Return NULL for a NULL pointer     */   /* (i.e. nothing has to be replaced). */   /*====================================*/   if (nodeList == NULL) return(NULL);        /*=====================================================*/   /* Create an expression data structure and recursively */   /* replace variables in its argument list and next     */   /* argument links.                                     */   /*=====================================================*/   newList = get_struct(theEnv,expr);   newList->type = nodeList->type;   newList->value = nodeList->value;   newList->nextArg = GetvarReplace(theEnv,nodeList->right,isNand);   newList->argList = GetvarReplace(theEnv,nodeList->bottom,isNand);   /*=========================================================*/   /* If the present node being examined is either a local or */   /* global variable, then replace it with a function call   */   /* that will return the variable's value.                  */   /*=========================================================*/   if ((nodeList->type == SF_VARIABLE) || (nodeList->type == MF_VARIABLE))     {      /*=============================================================*/      /* Referencing a variable outside the scope of the immediately */      /* enclosing not/and CE requires that the test be performed in */      /* the "join from the right" join.                             */      /*=============================================================*/      if (isNand)        {         if (nodeList->beginNandDepth > nodeList->referringNode->beginNandDepth)           {             (*nodeList->referringNode->patternType->replaceGetJNValueFunction)               (theEnv,newList,nodeList->referringNode,LHS);           }         else           {            (*nodeList->referringNode->patternType->replaceGetJNValueFunction)               (theEnv,newList,nodeList->referringNode,NESTED_RHS);           }        }      else        {         if (nodeList->joinDepth != nodeList->referringNode->joinDepth)           {            (*nodeList->referringNode->patternType->replaceGetJNValueFunction)               (theEnv,newList,nodeList->referringNode,LHS);           }         else           {            (*nodeList->referringNode->patternType->replaceGetJNValueFunction)               (theEnv,newList,nodeList->referringNode,RHS);           }        }     }#if DEFGLOBAL_CONSTRUCT   else if (newList->type == GBL_VARIABLE)     { ReplaceGlobalVariable(theEnv,newList); }#endif   /*====================================================*/   /* Return the expression with its variables replaced. */   /*====================================================*/   return(newList);  }  /******************************************************************//* IsNandTest:                 *//******************************************************************/globle intBool IsNandTest(  struct lhsParseNode *nodeList)  {   if (nodeList == NULL) return(FALSE);        if (IsNandTest(nodeList->right))     { return(TRUE); }      if (IsNandTest(nodeList->bottom))     { return(TRUE); }   if ((nodeList->type == SF_VARIABLE) || (nodeList->type == MF_VARIABLE))     {      if (nodeList->beginNandDepth > nodeList->referringNode->beginNandDepth)        { return(TRUE); }     }   return(FALSE);  }

⌨️ 快捷键说明

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