Ejemplo n.º 1
0
static struct expr *GetfieldReplace(
  void *theEnv,
  EXEC_STATUS,
  struct lhsParseNode *nodeList)
  {
   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,execStatus,expr);
   newList->type = nodeList->type;
   newList->value = nodeList->value;
   newList->nextArg = GetfieldReplace(theEnv,execStatus,nodeList->right);
   newList->argList = GetfieldReplace(theEnv,execStatus,nodeList->bottom);

   /*=========================================================*/
   /* 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))
     {
      (*nodeList->referringNode->patternType->replaceGetPNValueFunction)
         (theEnv,execStatus,newList,nodeList->referringNode);
     }
#if DEFGLOBAL_CONSTRUCT
   else if (newList->type == GBL_VARIABLE)
     { ReplaceGlobalVariable(theEnv,execStatus,newList); }
#endif

   /*====================================================*/
   /* Return the expression with its variables replaced. */
   /*====================================================*/

   return(newList);
  }
Ejemplo n.º 2
0
globle struct expr *GetvarReplace(
  void *theEnv,
  struct lhsParseNode *nodeList,
  int isNand,
  struct nandFrame *theNandFrames)
  {
   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,theNandFrames);
   newList->argList = GetvarReplace(theEnv,nodeList->bottom,isNand,theNandFrames);

   /*=========================================================*/
   /* 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))
     {
      AddNandUnification(theEnv,nodeList,theNandFrames);
      
      /*=============================================================*/
      /* 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);
  }