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

📄 evaluatn.c

📁 clips源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
        oldArgument = EvaluationData(theEnv)->CurrentExpression;        EvaluationData(theEnv)->CurrentExpression = problem;#if PROFILING_FUNCTIONS         StartProfile(theEnv,&profileFrame,                     &EvaluationData(theEnv)->PrimitivesArray[problem->type]->usrData,                     ProfileFunctionData(theEnv)->ProfileUserFunctions);#endif        (*EvaluationData(theEnv)->PrimitivesArray[problem->type]->evaluateFunction)(theEnv,problem->value,returnValue);#if PROFILING_FUNCTIONS        EndProfile(theEnv,&profileFrame);#endif        EvaluationData(theEnv)->CurrentExpression = oldArgument;        break;     }   PropagateReturnValue(theEnv,returnValue);   return(EvaluationData(theEnv)->EvaluationError);  }/******************************************//* InstallPrimitive: Installs a primitive *//*   data type in the primitives array.   *//******************************************/globle void InstallPrimitive(  void *theEnv,  struct entityRecord *thePrimitive,  int whichPosition)  {   if (EvaluationData(theEnv)->PrimitivesArray[whichPosition] != NULL)     {      SystemError(theEnv,"EVALUATN",5);      EnvExitRouter(theEnv,EXIT_FAILURE);     }   EvaluationData(theEnv)->PrimitivesArray[whichPosition] = thePrimitive;  }/******************************************************//* SetEvaluationError: Sets the EvaluationError flag. *//******************************************************/globle void SetEvaluationError(  void *theEnv,  int value)  {   EvaluationData(theEnv)->EvaluationError = value;   if (value == TRUE)      { EvaluationData(theEnv)->HaltExecution = TRUE; }  }/*********************************************************//* GetEvaluationError: Returns the EvaluationError flag. *//*********************************************************/globle int GetEvaluationError(  void *theEnv)  {   return(EvaluationData(theEnv)->EvaluationError);  }/**************************************************//* SetHaltExecution: Sets the HaltExecution flag. *//**************************************************/globle void SetHaltExecution(  void *theEnv,  int value)  {    EvaluationData(theEnv)->HaltExecution = value;   }/*****************************************************//* GetHaltExecution: Returns the HaltExecution flag. *//*****************************************************/globle int GetHaltExecution(  void *theEnv)  {   return(EvaluationData(theEnv)->HaltExecution);  }/******************************************************//* ReturnValues: Returns a linked list of DATA_OBJECT *//*   structures to the pool of free memory.           *//******************************************************/globle void ReturnValues(  void *theEnv,  DATA_OBJECT_PTR garbagePtr)  {   DATA_OBJECT_PTR nextPtr;   while (garbagePtr != NULL)     {      nextPtr = garbagePtr->next;      ValueDeinstall(theEnv,garbagePtr);      rtn_struct(theEnv,dataObject,garbagePtr);      garbagePtr = nextPtr;     }  }/***************************************************//* PrintDataObject: Prints a DATA_OBJECT structure *//*   to the specified logical name.                *//***************************************************/globle void PrintDataObject(  void *theEnv,  char *fileid,  DATA_OBJECT_PTR argPtr)  {   switch(argPtr->type)     {      case RVOID:      case SYMBOL:      case STRING:      case INTEGER:      case FLOAT:      case EXTERNAL_ADDRESS:      case FACT_ADDRESS:#if OBJECT_SYSTEM      case INSTANCE_NAME:      case INSTANCE_ADDRESS:#endif        PrintAtom(theEnv,fileid,argPtr->type,argPtr->value);        break;      case MULTIFIELD:        PrintMultifield(theEnv,fileid,(struct multifield *) argPtr->value,                        argPtr->begin,argPtr->end,TRUE);        break;      default:        if (EvaluationData(theEnv)->PrimitivesArray[argPtr->type] != NULL)          {           if (EvaluationData(theEnv)->PrimitivesArray[argPtr->type]->longPrintFunction)             {              (*EvaluationData(theEnv)->PrimitivesArray[argPtr->type]->longPrintFunction)(theEnv,fileid,argPtr->value);              break;             }           else if (EvaluationData(theEnv)->PrimitivesArray[argPtr->type]->shortPrintFunction)             {              (*EvaluationData(theEnv)->PrimitivesArray[argPtr->type]->shortPrintFunction)(theEnv,fileid,argPtr->value);              break;             }          }        EnvPrintRouter(theEnv,fileid,"<UnknownPrintType");        PrintLongInteger(theEnv,fileid,(long int) argPtr->type);        EnvPrintRouter(theEnv,fileid,">");        SetHaltExecution(theEnv,TRUE);        SetEvaluationError(theEnv,TRUE);        break;     }  }/****************************************************//* EnvSetMultifieldErrorValue: Creates a multifield *//*   value of length zero for error returns.        *//****************************************************/globle void EnvSetMultifieldErrorValue(  void *theEnv,  DATA_OBJECT_PTR returnValue)  {   returnValue->type = MULTIFIELD;   returnValue->value = EnvCreateMultifield(theEnv,0L);   returnValue->begin = 1;   returnValue->end = 0;  }/**************************************************//* ValueInstall: Increments the appropriate count *//*   (in use) values for a DATA_OBJECT structure. *//**************************************************/globle void ValueInstall(  void *theEnv,  DATA_OBJECT *vPtr)  {   if (vPtr->type == MULTIFIELD) MultifieldInstall(theEnv,(struct multifield *) vPtr->value);   else AtomInstall(theEnv,vPtr->type,vPtr->value);  }/****************************************************//* ValueDeinstall: Decrements the appropriate count *//*   (in use) values for a DATA_OBJECT structure.   *//****************************************************/globle void ValueDeinstall(  void *theEnv,  DATA_OBJECT *vPtr)  {   if (vPtr->type == MULTIFIELD) MultifieldDeinstall(theEnv,(struct multifield *) vPtr->value);   else AtomDeinstall(theEnv,vPtr->type,vPtr->value);  }/*****************************************//* AtomInstall: Increments the reference *//*   count of an atomic data type.       *//*****************************************/globle void AtomInstall(  void *theEnv,  int type,  void *vPtr)  {   switch (type)     {      case SYMBOL:      case STRING:#if DEFGLOBAL_CONSTRUCT      case GBL_VARIABLE:#endif#if OBJECT_SYSTEM      case INSTANCE_NAME:#endif        IncrementSymbolCount(vPtr);        break;      case FLOAT:        IncrementFloatCount(vPtr);        break;      case INTEGER:        IncrementIntegerCount(vPtr);        break;      case MULTIFIELD:        MultifieldInstall(theEnv,(struct multifield *) vPtr);        break;      case RVOID:        break;      default:        if (EvaluationData(theEnv)->PrimitivesArray[type] == NULL) break;        if (EvaluationData(theEnv)->PrimitivesArray[type]->bitMap) IncrementBitMapCount(vPtr);        else if (EvaluationData(theEnv)->PrimitivesArray[type]->incrementBusyCount)          { (*EvaluationData(theEnv)->PrimitivesArray[type]->incrementBusyCount)(theEnv,vPtr); }        break;     }  }/*******************************************//* AtomDeinstall: Decrements the reference *//*   count of an atomic data type.         *//*******************************************/globle void AtomDeinstall(  void *theEnv,  int type,  void *vPtr)  {   switch (type)     {      case SYMBOL:      case STRING:#if DEFGLOBAL_CONSTRUCT      case GBL_VARIABLE:#endif#if OBJECT_SYSTEM      case INSTANCE_NAME:#endif        DecrementSymbolCount(theEnv,(SYMBOL_HN *) vPtr);        break;      case FLOAT:        DecrementFloatCount(theEnv,(FLOAT_HN *) vPtr);        break;      case INTEGER:        DecrementIntegerCount(theEnv,(INTEGER_HN *) vPtr);        break;      case MULTIFIELD:        MultifieldDeinstall(theEnv,(struct multifield *) vPtr);        break;      case RVOID:        break;      default:        if (EvaluationData(theEnv)->PrimitivesArray[type] == NULL) break;        if (EvaluationData(theEnv)->PrimitivesArray[type]->bitMap) DecrementBitMapCount(theEnv,(BITMAP_HN *) vPtr);        else if (EvaluationData(theEnv)->PrimitivesArray[type]->decrementBusyCount)          { (*EvaluationData(theEnv)->PrimitivesArray[type]->decrementBusyCount)(theEnv,vPtr); }     }  }/*********************************************************************//* PropagateReturnValue: Decrements the associated depth for a value *//*   stored in a DATA_OBJECT structure. In effect, the values        *//*   returned by certain evaluations (such as a deffunction call)    *//*   are passed up to the previous depth of evaluation. The return   *//*   value's depth is decremented so that it will not be garbage     *//*   collected along with other items that are no longer needed from *//*   the evaluation that generated the return value.                 *//*********************************************************************/globle void PropagateReturnValue(  void *theEnv,  DATA_OBJECT *vPtr)  {   long i;   struct multifield *theSegment;   struct field *theMultifield;   if (vPtr->type != MULTIFIELD)     { PropagateReturnAtom(theEnv,vPtr->type,vPtr->value); }   else     {      theSegment = (struct multifield *) vPtr->value;      if (theSegment->depth > EvaluationData(theEnv)->CurrentEvaluationDepth)        theSegment->depth = (short) EvaluationData(theEnv)->CurrentEvaluationDepth;      theMultifield = theSegment->theFields;      for (i = 0; i < theSegment->multifieldLength; i++)        { PropagateReturnAtom(theEnv,theMultifield[i].type,theMultifield[i].value); }     }  }/*****************************************//* PropagateReturnAtom: Support function *//*   for PropagateReturnValue.           *//*****************************************/static void PropagateReturnAtom(  void *theEnv,  int type,  void *value)  {   switch (type)     {      case INTEGER         :      case FLOAT           :      case SYMBOL          :      case STRING          :#if OBJECT_SYSTEM      case INSTANCE_NAME   :#endif        if (((SYMBOL_HN *) value)->depth > EvaluationData(theEnv)->CurrentEvaluationDepth)          { ((SYMBOL_HN *) value)->depth = EvaluationData(theEnv)->CurrentEvaluationDepth; }        break;#if OBJECT_SYSTEM      case INSTANCE_ADDRESS :        if (((INSTANCE_TYPE *) value)->depth > EvaluationData(theEnv)->CurrentEvaluationDepth)          { ((INSTANCE_TYPE *) value)->depth = EvaluationData(theEnv)->CurrentEvaluationDepth; }        break;#endif      case FACT_ADDRESS :        if (((int) ((struct fact *) value)->depth) > EvaluationData(theEnv)->CurrentEvaluationDepth)          { ((struct fact *) value)->depth = (unsigned) EvaluationData(theEnv)->CurrentEvaluationDepth; }        break;     }  }#if DEFFUNCTION_CONSTRUCT || DEFGENERIC_CONSTRUCT/********************************************//* EnvFunctionCall: Allows Deffunctions and *//*   Generic Functions to be called from C. *//*   Allows only constants as arguments.    *//********************************************/globle int EnvFunctionCall(  void *theEnv,  char *name,  char *args,  DATA_OBJECT *result)  {   FUNCTION_REFERENCE theReference;   /*=======================================*/   /* Call the function if it can be found. */   /*=======================================*/   if (GetFunctionReference(theEnv,name,&theReference))     { return(FunctionCall2(theEnv,&theReference,args,result)); }   /*=========================================================*/   /* Otherwise signal an error if a deffunction, defgeneric, */   /* or user defined function doesn't exist that matches     */   /* the specified function name.                            */   /*=========================================================*/   PrintErrorID(theEnv,"EVALUATN",2,FALSE);   EnvPrintRouter(theEnv,WERROR,"No function, generic function or deffunction of name ");   EnvPrintRouter(theEnv,WERROR,name);

⌨️ 快捷键说明

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