00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #define _ARGACCES_SOURCE_
00029
00030 #include "setup.h"
00031
00032 #include <stdio.h>
00033 #define _STDIO_INCLUDED_
00034 #include <string.h>
00035 #include <ctype.h>
00036 #include <stdlib.h>
00037
00038 #include "envrnmnt.h"
00039 #include "extnfunc.h"
00040 #include "router.h"
00041 #include "cstrnchk.h"
00042 #include "insfun.h"
00043 #include "factmngr.h"
00044 #include "prntutil.h"
00045 #include "sysdep.h"
00046
00047 #include "argacces.h"
00048
00049
00050
00051
00052
00053 static void NonexistantError(void *,char *,char *,int);
00054 static void ExpectedTypeError3(void *,char *,char *,int,char *);
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 globle char *EnvRtnLexeme(
00065 void *theEnv,
00066 int argumentPosition)
00067 {
00068 int count = 1;
00069 DATA_OBJECT result;
00070 struct expr *argPtr;
00071
00072
00073
00074
00075
00076 for (argPtr = EvaluationData(theEnv)->CurrentExpression->argList;
00077 (argPtr != NULL) && (count < argumentPosition);
00078 argPtr = argPtr->nextArg)
00079 { count++; }
00080
00081 if (argPtr == NULL)
00082 {
00083 NonexistantError(theEnv,"RtnLexeme",
00084 ValueToString(ExpressionFunctionCallName(EvaluationData(theEnv)->CurrentExpression)),
00085 argumentPosition);
00086 SetHaltExecution(theEnv,TRUE);
00087 SetEvaluationError(theEnv,TRUE);
00088 return(NULL);
00089 }
00090
00091
00092
00093
00094
00095
00096 EvaluateExpression(theEnv,argPtr,&result);
00097
00098 if ((result.type == SYMBOL) ||
00099 #if OBJECT_SYSTEM
00100 (result.type == INSTANCE_NAME) ||
00101 #endif
00102 (result.type == STRING))
00103 { return(ValueToString(result.value));}
00104
00105
00106
00107
00108
00109 ExpectedTypeError3(theEnv,"RtnLexeme",
00110 ValueToString(ExpressionFunctionCallName(EvaluationData(theEnv)->CurrentExpression)),
00111 argumentPosition,"symbol, string, or instance name");
00112 SetHaltExecution(theEnv,TRUE);
00113 SetEvaluationError(theEnv,TRUE);
00114 return(NULL);
00115 }
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126 globle double EnvRtnDouble(
00127 void *theEnv,
00128 int argumentPosition)
00129 {
00130 int count = 1;
00131 DATA_OBJECT result;
00132 struct expr *argPtr;
00133
00134
00135
00136
00137
00138 for (argPtr = EvaluationData(theEnv)->CurrentExpression->argList;
00139 (argPtr != NULL) && (count < argumentPosition);
00140 argPtr = argPtr->nextArg)
00141 { count++; }
00142
00143 if (argPtr == NULL)
00144 {
00145 NonexistantError(theEnv,"RtnDouble",
00146 ValueToString(ExpressionFunctionCallName(EvaluationData(theEnv)->CurrentExpression)),
00147 argumentPosition);
00148 SetHaltExecution(theEnv,TRUE);
00149 SetEvaluationError(theEnv,TRUE);
00150 return(1.0);
00151 }
00152
00153
00154
00155
00156
00157
00158 EvaluateExpression(theEnv,argPtr,&result);
00159
00160 if (result.type == FLOAT)
00161 { return(ValueToDouble(result.value)); }
00162 else if (result.type == INTEGER)
00163 { return((double) ValueToLong(result.value)); }
00164
00165
00166
00167
00168
00169 ExpectedTypeError3(theEnv,"RtnDouble",
00170 ValueToString(ExpressionFunctionCallName(EvaluationData(theEnv)->CurrentExpression)),
00171 argumentPosition,"number");
00172 SetHaltExecution(theEnv,TRUE);
00173 SetEvaluationError(theEnv,TRUE);
00174 return(1.0);
00175 }
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186 globle long long EnvRtnLong(
00187 void *theEnv,
00188 int argumentPosition)
00189 {
00190 int count = 1;
00191 DATA_OBJECT result;
00192 struct expr *argPtr;
00193
00194
00195
00196
00197
00198 for (argPtr = EvaluationData(theEnv)->CurrentExpression->argList;
00199 (argPtr != NULL) && (count < argumentPosition);
00200 argPtr = argPtr->nextArg)
00201 { count++; }
00202
00203 if (argPtr == NULL)
00204 {
00205 NonexistantError(theEnv,"RtnLong",
00206 ValueToString(ExpressionFunctionCallName(EvaluationData(theEnv)->CurrentExpression)),
00207 argumentPosition);
00208 SetHaltExecution(theEnv,TRUE);
00209 SetEvaluationError(theEnv,TRUE);
00210 return(1L);
00211 }
00212
00213
00214
00215
00216
00217
00218 EvaluateExpression(theEnv,argPtr,&result);
00219
00220 if (result.type == FLOAT)
00221 { return((long) ValueToDouble(result.value)); }
00222 else if (result.type == INTEGER)
00223 { return(ValueToLong(result.value)); }
00224
00225
00226
00227
00228
00229 ExpectedTypeError3(theEnv,"RtnLong",
00230 ValueToString(ExpressionFunctionCallName(EvaluationData(theEnv)->CurrentExpression)),
00231 argumentPosition,"number");
00232 SetHaltExecution(theEnv,TRUE);
00233 SetEvaluationError(theEnv,TRUE);
00234 return(1L);
00235 }
00236
00237
00238
00239
00240
00241
00242
00243
00244 globle DATA_OBJECT_PTR EnvRtnUnknown(
00245 void *theEnv,
00246 int argumentPosition,
00247 DATA_OBJECT_PTR returnValue)
00248 {
00249 int count = 1;
00250 struct expr *argPtr;
00251
00252
00253
00254
00255
00256 for (argPtr = EvaluationData(theEnv)->CurrentExpression->argList;
00257 (argPtr != NULL) && (count < argumentPosition);
00258 argPtr = argPtr->nextArg)
00259 { count++; }
00260
00261 if (argPtr == NULL)
00262 {
00263 NonexistantError(theEnv,"RtnUnknown",
00264 ValueToString(ExpressionFunctionCallName(EvaluationData(theEnv)->CurrentExpression)),
00265 argumentPosition);
00266 SetHaltExecution(theEnv,TRUE);
00267 SetEvaluationError(theEnv,TRUE);
00268 return(NULL);
00269 }
00270
00271
00272
00273
00274
00275 EvaluateExpression(theEnv,argPtr,returnValue);
00276 return(returnValue);
00277 }
00278
00279
00280
00281
00282
00283 globle int EnvRtnArgCount(
00284 void *theEnv)
00285 {
00286 int count = 0;
00287 struct expr *argPtr;
00288
00289 for (argPtr = EvaluationData(theEnv)->CurrentExpression->argList;
00290 argPtr != NULL;
00291 argPtr = argPtr->nextArg)
00292 { count++; }
00293
00294 return(count);
00295 }
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307 globle int EnvArgCountCheck(
00308 void *theEnv,
00309 char *functionName,
00310 int countRelation,
00311 int expectedNumber)
00312 {
00313 int numberOfArguments;
00314
00315
00316
00317
00318
00319
00320 numberOfArguments = EnvRtnArgCount(theEnv);
00321
00322
00323
00324
00325
00326
00327 if (countRelation == EXACTLY)
00328 { if (numberOfArguments == expectedNumber) return(numberOfArguments); }
00329 else if (countRelation == AT_LEAST)
00330 { if (numberOfArguments >= expectedNumber) return(numberOfArguments); }
00331 else if (countRelation == NO_MORE_THAN)
00332 { if (numberOfArguments <= expectedNumber) return(numberOfArguments); }
00333
00334
00335
00336
00337
00338
00339 ExpectedCountError(theEnv,functionName,countRelation,expectedNumber);
00340
00341 SetHaltExecution(theEnv,TRUE);
00342 SetEvaluationError(theEnv,TRUE);
00343
00344 return(-1);
00345 }
00346
00347
00348
00349
00350
00351
00352
00353 globle int EnvArgRangeCheck(
00354 void *theEnv,
00355 char *functionName,
00356 int min,
00357 int max)
00358 {
00359 int numberOfArguments;
00360
00361 numberOfArguments = EnvRtnArgCount(theEnv);
00362 if ((numberOfArguments < min) || (numberOfArguments > max))
00363 {
00364 PrintErrorID(theEnv,"ARGACCES",1,FALSE);
00365 EnvPrintRouter(theEnv,WERROR,"Function ");
00366 EnvPrintRouter(theEnv,WERROR,functionName);
00367 EnvPrintRouter(theEnv,WERROR," expected at least ");
00368 PrintLongInteger(theEnv,WERROR,(long) min);
00369 EnvPrintRouter(theEnv,WERROR," and no more than ");
00370 PrintLongInteger(theEnv,WERROR,(long) max);
00371 EnvPrintRouter(theEnv,WERROR," arguments.\n");
00372 SetHaltExecution(theEnv,TRUE);
00373 SetEvaluationError(theEnv,TRUE);
00374 return(-1);
00375 }
00376
00377 return(numberOfArguments);
00378 }
00379
00380
00381
00382
00383
00384
00385
00386
00387 globle int EnvArgTypeCheck(
00388 void *theEnv,
00389 char *functionName,
00390 int argumentPosition,
00391 int expectedType,
00392 DATA_OBJECT_PTR returnValue)
00393 {
00394
00395
00396
00397
00398 EnvRtnUnknown(theEnv,argumentPosition,returnValue);
00399 if (EvaluationData(theEnv)->EvaluationError) return(FALSE);
00400
00401
00402
00403
00404
00405
00406 if (returnValue->type == expectedType) return (TRUE);
00407
00408
00409
00410
00411
00412
00413
00414 if ((expectedType == INTEGER_OR_FLOAT) &&
00415 ((returnValue->type == INTEGER) || (returnValue->type == FLOAT)))
00416 { return(TRUE); }
00417
00418 if ((expectedType == SYMBOL_OR_STRING) &&
00419 ((returnValue->type == SYMBOL) || (returnValue->type == STRING)))
00420 { return(TRUE); }
00421
00422 #if OBJECT_SYSTEM
00423 if (((expectedType == SYMBOL_OR_STRING) || (expectedType == SYMBOL)) &&
00424 (returnValue->type == INSTANCE_NAME))
00425 { return(TRUE); }
00426
00427 if ((expectedType == INSTANCE_NAME) &&
00428 ((returnValue->type == INSTANCE_NAME) || (returnValue->type == SYMBOL)))
00429 { return(TRUE); }
00430
00431 if ((expectedType == INSTANCE_OR_INSTANCE_NAME) &&
00432 ((returnValue->type == INSTANCE_ADDRESS) ||
00433 (returnValue->type == INSTANCE_NAME) ||
00434 (returnValue->type == SYMBOL)))
00435 { return(TRUE); }
00436 #endif
00437
00438
00439
00440
00441
00442
00443
00444 if ((returnValue->type == INTEGER) && (expectedType == FLOAT))
00445 {
00446 returnValue->type = FLOAT;
00447 returnValue->value = (void *) EnvAddDouble(theEnv,(double) ValueToLong(returnValue->value));
00448 return(TRUE);
00449 }
00450
00451 if ((returnValue->type == FLOAT) && (expectedType == INTEGER))
00452 {
00453 returnValue->type = INTEGER;
00454 returnValue->value = (void *) EnvAddLong(theEnv,(long long) ValueToDouble(returnValue->value));
00455 return(TRUE);
00456 }
00457
00458
00459
00460
00461
00462
00463 if (expectedType == FLOAT) ExpectedTypeError1(theEnv,functionName,argumentPosition,"float");
00464 else if (expectedType == INTEGER) ExpectedTypeError1(theEnv,functionName,argumentPosition,"integer");
00465 else if (expectedType == SYMBOL) ExpectedTypeError1(theEnv,functionName,argumentPosition,"symbol");
00466 else if (expectedType == STRING) ExpectedTypeError1(theEnv,functionName,argumentPosition,"string");
00467 else if (expectedType == MULTIFIELD) ExpectedTypeError1(theEnv,functionName,argumentPosition,"multifield");
00468 else if (expectedType == INTEGER_OR_FLOAT) ExpectedTypeError1(theEnv,functionName,argumentPosition,"integer or float");
00469 else if (expectedType == SYMBOL_OR_STRING) ExpectedTypeError1(theEnv,functionName,argumentPosition,"symbol or string");
00470 #if OBJECT_SYSTEM
00471 else if (expectedType == INSTANCE_NAME) ExpectedTypeError1(theEnv,functionName,argumentPosition,"instance name");
00472 else if (expectedType == INSTANCE_ADDRESS) ExpectedTypeError1(theEnv,functionName,argumentPosition,"instance address");
00473 else if (expectedType == INSTANCE_OR_INSTANCE_NAME) ExpectedTypeError1(theEnv,functionName,argumentPosition,"instance address or instance name");
00474 #endif
00475
00476 SetHaltExecution(theEnv,TRUE);
00477 SetEvaluationError(theEnv,TRUE);
00478
00479 return(FALSE);
00480 }
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490 globle intBool GetNumericArgument(
00491 void *theEnv,
00492 struct expr *theArgument,
00493 char *functionName,
00494 DATA_OBJECT *result,
00495 intBool convertToFloat,
00496 int whichArgument)
00497 {
00498 unsigned short theType;
00499 void *theValue;
00500
00501
00502
00503
00504
00505
00506 switch(theArgument->type)
00507 {
00508 case FLOAT:
00509 case INTEGER:
00510 theType = theArgument->type;
00511 theValue = theArgument->value;
00512 break;
00513
00514 default:
00515 EvaluateExpression(theEnv,theArgument,result);
00516 theType = result->type;
00517 theValue = result->value;
00518 break;
00519 }
00520
00521
00522
00523
00524
00525
00526 if ((theType != FLOAT) && (theType != INTEGER))
00527 {
00528 ExpectedTypeError1(theEnv,functionName,whichArgument,"integer or float");
00529 SetHaltExecution(theEnv,TRUE);
00530 SetEvaluationError(theEnv,TRUE);
00531 result->type = INTEGER;
00532 result->value = (void *) EnvAddLong(theEnv,0LL);
00533 return(FALSE);
00534 }
00535
00536
00537
00538
00539
00540
00541 if ((convertToFloat) && (theType == INTEGER))
00542 {
00543 theType = FLOAT;
00544 theValue = (void *) EnvAddDouble(theEnv,(double) ValueToLong(theValue));
00545 }
00546
00547
00548
00549
00550
00551
00552 result->type = theType;
00553 result->value = theValue;
00554
00555 return(TRUE);
00556 }
00557
00558
00559
00560
00561
00562
00563
00564 globle char *GetLogicalName(
00565 void *theEnv,
00566 int whichArgument,
00567 char *defaultLogicalName)
00568 {
00569 char *logicalName;
00570 DATA_OBJECT result;
00571
00572 EnvRtnUnknown(theEnv,whichArgument,&result);
00573
00574 if ((GetType(result) == SYMBOL) ||
00575 (GetType(result) == STRING) ||
00576 (GetType(result) == INSTANCE_NAME))
00577 {
00578 logicalName = ValueToString(result.value);
00579 if ((strcmp(logicalName,"t") == 0) || (strcmp(logicalName,"T") == 0))
00580 { logicalName = defaultLogicalName; }
00581 }
00582 else if (GetType(result) == FLOAT)
00583 {
00584 logicalName = ValueToString(EnvAddSymbol(theEnv,FloatToString(theEnv,DOToDouble(result))));
00585 }
00586 else if (GetType(result) == INTEGER)
00587 {
00588 logicalName = ValueToString(EnvAddSymbol(theEnv,LongIntegerToString(theEnv,DOToLong(result))));
00589 }
00590 else
00591 { logicalName = NULL; }
00592
00593 return(logicalName);
00594 }
00595
00596
00597
00598
00599
00600
00601
00602 globle char *GetFileName(
00603 void *theEnv,
00604 char *functionName,
00605 int whichArgument)
00606 {
00607 DATA_OBJECT result;
00608
00609 EnvRtnUnknown(theEnv,whichArgument,&result);
00610 if ((GetType(result) != STRING) && (GetType(result) != SYMBOL))
00611 {
00612 ExpectedTypeError1(theEnv,functionName,whichArgument,"file name");
00613 return(NULL);
00614 }
00615
00616 return(DOToString(result));
00617 }
00618
00619
00620
00621
00622 globle void OpenErrorMessage(
00623 void *theEnv,
00624 char *functionName,
00625 char *fileName)
00626 {
00627 PrintErrorID(theEnv,"ARGACCES",2,FALSE);
00628 EnvPrintRouter(theEnv,WERROR,"Function ");
00629 EnvPrintRouter(theEnv,WERROR,functionName);
00630 EnvPrintRouter(theEnv,WERROR," was unable to open file ");
00631 EnvPrintRouter(theEnv,WERROR,fileName);
00632 EnvPrintRouter(theEnv,WERROR,".\n");
00633 }
00634
00635
00636
00637
00638
00639
00640
00641
00642 globle struct defmodule *GetModuleName(
00643 void *theEnv,
00644 char *functionName,
00645 int whichArgument,
00646 int *error)
00647 {
00648 DATA_OBJECT result;
00649 struct defmodule *theModule;
00650
00651 *error = FALSE;
00652
00653
00654
00655
00656
00657 EnvRtnUnknown(theEnv,whichArgument,&result);
00658
00659
00660
00661
00662
00663 if (GetType(result) != SYMBOL)
00664 {
00665 ExpectedTypeError1(theEnv,functionName,whichArgument,"defmodule name");
00666 *error = TRUE;
00667 return(NULL);
00668 }
00669
00670
00671
00672
00673
00674
00675 if ((theModule = (struct defmodule *) EnvFindDefmodule(theEnv,DOToString(result))) == NULL)
00676 {
00677 if (strcmp("*",DOToString(result)) != 0)
00678 {
00679 ExpectedTypeError1(theEnv,functionName,whichArgument,"defmodule name");
00680 *error = TRUE;
00681 }
00682 return(NULL);
00683 }
00684
00685
00686
00687
00688
00689 return(theModule);
00690 }
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700 globle char *GetConstructName(
00701 void *theEnv,
00702 char *functionName,
00703 char *constructType)
00704 {
00705 DATA_OBJECT result;
00706
00707 if (EnvRtnArgCount(theEnv) != 1)
00708 {
00709 ExpectedCountError(theEnv,functionName,EXACTLY,1);
00710 return(NULL);
00711 }
00712
00713 EnvRtnUnknown(theEnv,1,&result);
00714
00715 if (GetType(result) != SYMBOL)
00716 {
00717 ExpectedTypeError1(theEnv,functionName,1,constructType);
00718 return(NULL);
00719 }
00720
00721 return(DOToString(result));
00722 }
00723
00724
00725
00726
00727 static void NonexistantError(
00728 void *theEnv,
00729 char *accessFunction,
00730 char *functionName,
00731 int argumentPosition)
00732 {
00733 PrintErrorID(theEnv,"ARGACCES",3,FALSE);
00734 EnvPrintRouter(theEnv,WERROR,"Function ");
00735 EnvPrintRouter(theEnv,WERROR,accessFunction);
00736 EnvPrintRouter(theEnv,WERROR," received a request from function ");
00737 EnvPrintRouter(theEnv,WERROR,functionName);
00738 EnvPrintRouter(theEnv,WERROR," for argument #");
00739 PrintLongInteger(theEnv,WERROR,(long int) argumentPosition);
00740 EnvPrintRouter(theEnv,WERROR," which is non-existent\n");
00741 }
00742
00743
00744
00745
00746
00747 globle void ExpectedCountError(
00748 void *theEnv,
00749 char *functionName,
00750 int countRelation,
00751 int expectedNumber)
00752 {
00753 PrintErrorID(theEnv,"ARGACCES",4,FALSE);
00754 EnvPrintRouter(theEnv,WERROR,"Function ");
00755 EnvPrintRouter(theEnv,WERROR,functionName);
00756
00757 if (countRelation == EXACTLY)
00758 { EnvPrintRouter(theEnv,WERROR," expected exactly "); }
00759 else if (countRelation == AT_LEAST)
00760 { EnvPrintRouter(theEnv,WERROR," expected at least "); }
00761 else if (countRelation == NO_MORE_THAN)
00762 { EnvPrintRouter(theEnv,WERROR," expected no more than "); }
00763 else
00764 { EnvPrintRouter(theEnv,WERROR," generated an illegal argument check for "); }
00765
00766 PrintLongInteger(theEnv,WERROR,(long int) expectedNumber);
00767 EnvPrintRouter(theEnv,WERROR," argument(s)\n");
00768 }
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784 globle intBool CheckFunctionArgCount(
00785 void *theEnv,
00786 char *functionName,
00787 char *restrictions,
00788 int argumentCount)
00789 {
00790 register int minArguments, maxArguments;
00791 char theChar[2];
00792
00793 theChar[0] = '0';
00794 theChar[1] = EOS;
00795
00796
00797
00798
00799
00800
00801 if (restrictions == NULL) return(TRUE);
00802
00803
00804
00805
00806
00807
00808 if (isdigit(restrictions[0]))
00809 {
00810 theChar[0] = restrictions[0];
00811 minArguments = atoi(theChar);
00812 }
00813 else
00814 { minArguments = -1; }
00815
00816
00817
00818
00819
00820
00821 if (isdigit(restrictions[1]))
00822 {
00823 theChar[0] = restrictions[1];
00824 maxArguments = atoi(theChar);
00825 }
00826 else
00827 { maxArguments = 10000; }
00828
00829
00830
00831
00832
00833
00834 if (minArguments == maxArguments)
00835 {
00836 if (argumentCount != minArguments)
00837 {
00838 ExpectedCountError(theEnv,functionName,EXACTLY,minArguments);
00839 SetEvaluationError(theEnv,TRUE);
00840 return(FALSE);
00841 }
00842 return(TRUE);
00843 }
00844
00845
00846
00847
00848
00849
00850 if (argumentCount < minArguments)
00851 {
00852 ExpectedCountError(theEnv,functionName,AT_LEAST,minArguments);
00853 SetEvaluationError(theEnv,TRUE);
00854 return(FALSE);
00855 }
00856
00857
00858
00859
00860
00861
00862 if (argumentCount > maxArguments)
00863 {
00864 ExpectedCountError(theEnv,functionName,NO_MORE_THAN,maxArguments);
00865 SetEvaluationError(theEnv,TRUE);
00866 return(FALSE);
00867 }
00868
00869
00870
00871
00872
00873
00874 return(TRUE);
00875 }
00876
00877
00878
00879
00880
00881
00882 globle void ExpectedTypeError1(
00883 void *theEnv,
00884 char *functionName,
00885 int whichArg,
00886 char *expectedType)
00887 {
00888 PrintErrorID(theEnv,"ARGACCES",5,FALSE);
00889 EnvPrintRouter(theEnv,WERROR,"Function ");
00890 EnvPrintRouter(theEnv,WERROR,functionName);
00891 EnvPrintRouter(theEnv,WERROR," expected argument #");
00892 PrintLongInteger(theEnv,WERROR,(long int) whichArg);
00893 EnvPrintRouter(theEnv,WERROR," to be of type ");
00894 EnvPrintRouter(theEnv,WERROR,expectedType);
00895 EnvPrintRouter(theEnv,WERROR,"\n");
00896 }
00897
00898
00899
00900
00901
00902
00903
00904 globle void ExpectedTypeError2(
00905 void *theEnv,
00906 char *functionName,
00907 int whichArg)
00908 {
00909 struct FunctionDefinition *theFunction;
00910 char *theType;
00911
00912 theFunction = FindFunction(theEnv,functionName);
00913
00914 if (theFunction == NULL) return;
00915
00916 theType = GetArgumentTypeName(GetNthRestriction(theFunction,whichArg));
00917
00918 ExpectedTypeError1(theEnv,functionName,whichArg,theType);
00919 }
00920
00921
00922
00923
00924
00925
00926
00927 static void ExpectedTypeError3(
00928 void *theEnv,
00929 char *accessFunction,
00930 char *functionName,
00931 int argumentPosition,
00932 char *type)
00933 {
00934 PrintErrorID(theEnv,"ARGACCES",6,FALSE);
00935 EnvPrintRouter(theEnv,WERROR,"Function ");
00936 EnvPrintRouter(theEnv,WERROR,accessFunction);
00937 EnvPrintRouter(theEnv,WERROR," received a request from function ");
00938 EnvPrintRouter(theEnv,WERROR,functionName);
00939 EnvPrintRouter(theEnv,WERROR," for argument #");
00940 PrintLongInteger(theEnv,WERROR,(long int) argumentPosition);
00941 EnvPrintRouter(theEnv,WERROR," which is not of type ");
00942 EnvPrintRouter(theEnv,WERROR,type);
00943 EnvPrintRouter(theEnv,WERROR,"\n");
00944 }
00945
00946
00947
00948
00949
00950 void *GetFactOrInstanceArgument(
00951 void *theEnv,
00952 int thePosition,
00953 DATA_OBJECT *item,
00954 char *functionName)
00955 {
00956 #if DEFTEMPLATE_CONSTRUCT || OBJECT_SYSTEM
00957 void *ptr;
00958 #endif
00959
00960
00961
00962
00963
00964 EnvRtnUnknown(theEnv,thePosition,item);
00965
00966
00967
00968
00969
00970 if ((GetpType(item) == FACT_ADDRESS) ||
00971 (GetpType(item) == INSTANCE_ADDRESS))
00972 { return(GetpValue(item)); }
00973
00974
00975
00976
00977
00978
00979 #if DEFTEMPLATE_CONSTRUCT
00980 else if (GetpType(item) == INTEGER)
00981 {
00982 if ((ptr = (void *) FindIndexedFact(theEnv,DOPToLong(item))) == NULL)
00983 {
00984 char tempBuffer[20];
00985 gensprintf(tempBuffer,"f-%lld",DOPToLong(item));
00986 CantFindItemErrorMessage(theEnv,"fact",tempBuffer);
00987 }
00988 return(ptr);
00989 }
00990 #endif
00991
00992
00993
00994
00995
00996
00997 #if OBJECT_SYSTEM
00998 else if ((GetpType(item) == INSTANCE_NAME) || (GetpType(item) == SYMBOL))
00999 {
01000 if ((ptr = (void *) FindInstanceBySymbol(theEnv,(SYMBOL_HN *) GetpValue(item))) == NULL)
01001 {
01002 CantFindItemErrorMessage(theEnv,"instance",ValueToString(GetpValue(item)));
01003 }
01004 return(ptr);
01005 }
01006 #endif
01007
01008
01009
01010
01011
01012 ExpectedTypeError2(theEnv,functionName,thePosition);
01013 return(NULL);
01014 }
01015
01016
01017
01018
01019
01020 void IllegalLogicalNameMessage(
01021 void *theEnv,
01022 char *theFunction)
01023 {
01024 PrintErrorID(theEnv,"IOFUN",1,FALSE);
01025 EnvPrintRouter(theEnv,WERROR,"Illegal logical name used for ");
01026 EnvPrintRouter(theEnv,WERROR,theFunction);
01027 EnvPrintRouter(theEnv,WERROR," function.\n");
01028 }