Пример #1
0
void ExpectedTypeError1(
  Environment *theEnv,
  const char *functionName,
  unsigned int whichArg,
  const char *expectedType)
  {
   ExpectedTypeError0(theEnv,functionName,whichArg);
   WriteString(theEnv,STDERR,expectedType);
   WriteString(theEnv,STDERR,".\n");
  }
Пример #2
0
void ExpectedTypeError2(
  Environment *theEnv,
  const char *functionName,
  unsigned int whichArg)
  {
   unsigned theRestriction;
   struct functionDefinition *theFunction;

   theFunction = FindFunction(theEnv,functionName);

   if (theFunction == NULL) return;

   theRestriction = GetNthRestriction(theEnv,theFunction,whichArg);
   ExpectedTypeError0(theEnv,functionName,whichArg);
   PrintTypesString(theEnv,STDERR,theRestriction,true);
  }
Пример #3
0
bool UDFNextArgument(
  UDFContext *context,
  unsigned expectedType,
  CLIPSValue *returnValue)
  {
   struct expr *argPtr = context->lastArg;
   int argumentPosition = context->lastPosition;
   void *theEnv = context->environment;
   returnValue->environment = theEnv;
   
   if (argPtr == NULL)
     {
      EnvSetHaltExecution(theEnv,true);
      EnvSetEvaluationError(theEnv,true);
      return false;
     }
     
   context->lastPosition++;
   context->lastArg = context->lastArg->nextArg;
   
   switch (argPtr->type)
     {
      case INTEGER:
        returnValue->type = argPtr->type;
        returnValue->bitType = INTEGER_TYPE;
        returnValue->value = argPtr->value;
        if (expectedType & INTEGER_TYPE) return(true);
        ExpectedTypeError0(theEnv,UDFContextFunctionName(context),argumentPosition);
        PrintTypesString(theEnv,WERROR,expectedType,true);
        EnvSetHaltExecution(theEnv,true);
        EnvSetEvaluationError(theEnv,true);
        AssignErrorValue(context);
        return false;
        break;

      case FLOAT:
        returnValue->type = argPtr->type;
        returnValue->bitType = FLOAT_TYPE;
        returnValue->value = argPtr->value;
        if (expectedType & FLOAT_TYPE) return(true);
        ExpectedTypeError0(theEnv,UDFContextFunctionName(context),argumentPosition);
        PrintTypesString(theEnv,WERROR,expectedType,true);
        EnvSetHaltExecution(theEnv,true);
        EnvSetEvaluationError(theEnv,true);
        AssignErrorValue(context);
        return false;
        break;

      case SYMBOL:
        returnValue->type = argPtr->type;
        returnValue->value = argPtr->value;
        returnValue->bitType = SYMBOL_TYPE;
        if (expectedType & SYMBOL_TYPE) return(true);
        ExpectedTypeError0(theEnv,UDFContextFunctionName(context),argumentPosition);
        PrintTypesString(theEnv,WERROR,expectedType,true);
        EnvSetHaltExecution(theEnv,true);
        EnvSetEvaluationError(theEnv,true);
        AssignErrorValue(context);
        return false;
        break;

      case STRING:
        returnValue->type = argPtr->type;
        returnValue->value = argPtr->value;
        returnValue->bitType = STRING_TYPE;
        if (expectedType & STRING_TYPE) return(true);
        ExpectedTypeError0(theEnv,UDFContextFunctionName(context),argumentPosition);
        PrintTypesString(theEnv,WERROR,expectedType,true);
        EnvSetHaltExecution(theEnv,true);
        EnvSetEvaluationError(theEnv,true);
        AssignErrorValue(context);
        return false;
        break;

      case INSTANCE_NAME:
        returnValue->type = argPtr->type;
        returnValue->value = argPtr->value;
        returnValue->bitType = INSTANCE_NAME_TYPE;
        if (expectedType & INSTANCE_NAME_TYPE) return(true);
        ExpectedTypeError0(theEnv,UDFContextFunctionName(context),argumentPosition);
        PrintTypesString(theEnv,WERROR,expectedType,true);
        EnvSetHaltExecution(theEnv,true);
        EnvSetEvaluationError(theEnv,true);
        AssignErrorValue(context);
        return false;
        break;
     }

   EvaluateExpression(theEnv,argPtr,returnValue);

   switch (returnValue->type)
     {
      case RVOID:
        returnValue->bitType = VOID_TYPE;
        if (expectedType & VOID_TYPE)
          {
           if (EvaluationData(theEnv)->EvaluationError)
             {
              AssignErrorValue(context);
              return false;
             }
           else return true;
          }
        break;

      case INTEGER:
        returnValue->bitType = INTEGER_TYPE;
        if (expectedType & INTEGER_TYPE)
          {
           if (EvaluationData(theEnv)->EvaluationError)
             {
              AssignErrorValue(context);
              return false;
             }
           else return true;
          }
        break;

      case FLOAT:
        returnValue->bitType = FLOAT_TYPE;
        if (expectedType & FLOAT_TYPE)
          {
           if (EvaluationData(theEnv)->EvaluationError)
             {
              AssignErrorValue(context);
              return false;
             }
           else return true;
          }
        break;

      case SYMBOL:
        returnValue->bitType = SYMBOL_TYPE;
        if (expectedType & SYMBOL_TYPE) 
          {
           if (EvaluationData(theEnv)->EvaluationError)
             {
              AssignErrorValue(context);
              return false;
             }
           else return true;
          }
        break;

      case STRING:
        returnValue->bitType = STRING_TYPE;
        if (expectedType & STRING_TYPE) 
          {
           if (EvaluationData(theEnv)->EvaluationError)
             {
              AssignErrorValue(context);
              return false;
             }
           else return true;
          }
        break;

      case INSTANCE_NAME:
        returnValue->bitType = INSTANCE_NAME_TYPE;
        if (expectedType & INSTANCE_NAME_TYPE) 
          {
           if (EvaluationData(theEnv)->EvaluationError)
             {
              AssignErrorValue(context);
              return false;
             }
           else return true;
          }
        break;

      case EXTERNAL_ADDRESS:
        returnValue->bitType = EXTERNAL_ADDRESS_TYPE;
        if (expectedType & EXTERNAL_ADDRESS_TYPE)
          {
           if (EvaluationData(theEnv)->EvaluationError)
             {
              AssignErrorValue(context);
              return false;
             }
           else return true;
          }
        break;

      case FACT_ADDRESS:
        returnValue->bitType = FACT_ADDRESS_TYPE;
        if (expectedType & FACT_ADDRESS_TYPE) 
          {
           if (EvaluationData(theEnv)->EvaluationError)
             {
              AssignErrorValue(context);
              return false;
             }
           else return true;
          }
        break;

      case INSTANCE_ADDRESS:
        returnValue->bitType = INSTANCE_ADDRESS_TYPE;
        if (expectedType & INSTANCE_ADDRESS_TYPE) 
          {
           if (EvaluationData(theEnv)->EvaluationError)
             {
              AssignErrorValue(context);
              return false;
             }
           else return true;
          }
        break;
        
      case MULTIFIELD:
        returnValue->bitType = MULTIFIELD_TYPE;
        if (expectedType & MULTIFIELD_TYPE) 
          {
           if (EvaluationData(theEnv)->EvaluationError)
             {
              AssignErrorValue(context);
              return false;
             }
           else return true;
          }
        break;
     }

   ExpectedTypeError0(theEnv,UDFContextFunctionName(context),argumentPosition);
   PrintTypesString(theEnv,WERROR,expectedType,true);

   EnvSetHaltExecution(theEnv,true);
   EnvSetEvaluationError(theEnv,true);
   AssignErrorValue(context);

   return false;
  }