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
00029
00030
00031
00032
00033 #include "setup.h"
00034
00035 #if DEFRULE_CONSTRUCT && OBJECT_SYSTEM
00036
00037 #include <stdio.h>
00038 #define _STDIO_INCLUDED_
00039 #include <string.h>
00040
00041 #include "classcom.h"
00042 #include "classfun.h"
00043
00044 #if DEVELOPER
00045 #include "exprnops.h"
00046 #endif
00047 #if BLOAD || BLOAD_AND_BSAVE
00048 #include "bload.h"
00049 #endif
00050 #include "constant.h"
00051 #include "drive.h"
00052 #include "engine.h"
00053 #include "envrnmnt.h"
00054 #include "memalloc.h"
00055 #include "multifld.h"
00056 #include "objrtmch.h"
00057 #include "reteutil.h"
00058 #include "router.h"
00059
00060 #define _OBJRTFNX_SOURCE_
00061 #include "objrtfnx.h"
00062
00063
00064
00065
00066
00067
00068
00069 #define GetInsSlot(ins,si) ins->slotAddresses[ins->cls->slotNameMap[si]-1]
00070
00071
00072
00073
00074
00075
00076
00077 static void PrintObjectGetVarJN1(void *,char *,void *);
00078 static intBool ObjectGetVarJNFunction1(void *,void *,DATA_OBJECT *);
00079 static void PrintObjectGetVarJN2(void *,char *,void *);
00080 static intBool ObjectGetVarJNFunction2(void *,void *,DATA_OBJECT *);
00081 static void PrintObjectGetVarPN1(void *,char *,void *);
00082 static intBool ObjectGetVarPNFunction1(void *,void *,DATA_OBJECT *);
00083 static void PrintObjectGetVarPN2(void *,char *,void *);
00084 static intBool ObjectGetVarPNFunction2(void *,void *,DATA_OBJECT *);
00085 static void PrintObjectCmpConstant(void *,char *,void *);
00086 static void PrintSlotLengthTest(void *,char *,void *);
00087 static intBool SlotLengthTestFunction(void *,void *,DATA_OBJECT *);
00088 static void PrintPNSimpleCompareFunction1(void *,char *,void *);
00089 static intBool PNSimpleCompareFunction1(void *,void *,DATA_OBJECT *);
00090 static void PrintPNSimpleCompareFunction2(void *,char *,void *);
00091 static intBool PNSimpleCompareFunction2(void *,void *,DATA_OBJECT *);
00092 static void PrintPNSimpleCompareFunction3(void *,char *,void *);
00093 static intBool PNSimpleCompareFunction3(void *,void *,DATA_OBJECT *);
00094 static void PrintJNSimpleCompareFunction1(void *,char *,void *);
00095 static intBool JNSimpleCompareFunction1(void *,void *,DATA_OBJECT *);
00096 static void PrintJNSimpleCompareFunction2(void *,char *,void *);
00097 static intBool JNSimpleCompareFunction2(void *,void *,DATA_OBJECT *);
00098 static void PrintJNSimpleCompareFunction3(void *,char *,void *);
00099 static intBool JNSimpleCompareFunction3(void *,void *,DATA_OBJECT *);
00100 static void GetPatternObjectAndMarks(void *,int,int,int,INSTANCE_TYPE **,struct multifieldMarker **);
00101 static void GetObjectValueGeneral(void *,DATA_OBJECT *,INSTANCE_TYPE *,
00102 struct multifieldMarker *,struct ObjectMatchVar1 *);
00103 static void GetObjectValueSimple(void *,DATA_OBJECT *,INSTANCE_TYPE *,struct ObjectMatchVar2 *);
00104 static long CalculateSlotField(struct multifieldMarker *,INSTANCE_SLOT *,long,long *);
00105 static void GetInsMultiSlotField(FIELD *,INSTANCE_TYPE *,unsigned,unsigned,unsigned);
00106 static void DeallocateObjectReteData(void *);
00107 static void DestroyObjectPatternNetwork(void *,OBJECT_PATTERN_NODE *);
00108 static void DestroyObjectAlphaNodes(void *,OBJECT_ALPHA_NODE *);
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126 globle void InstallObjectPrimitives(
00127 void *theEnv)
00128 {
00129 struct entityRecord objectGVInfo1 = { "OBJ_GET_SLOT_JNVAR1", OBJ_GET_SLOT_JNVAR1,0,1,0,
00130 PrintObjectGetVarJN1,
00131 PrintObjectGetVarJN1,NULL,
00132 ObjectGetVarJNFunction1,
00133 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
00134
00135 struct entityRecord objectGVInfo2 = { "OBJ_GET_SLOT_JNVAR2", OBJ_GET_SLOT_JNVAR2,0,1,0,
00136 PrintObjectGetVarJN2,
00137 PrintObjectGetVarJN2,NULL,
00138 ObjectGetVarJNFunction2,
00139 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
00140
00141 struct entityRecord objectGVPNInfo1 = { "OBJ_GET_SLOT_PNVAR1", OBJ_GET_SLOT_PNVAR1,0,1,0,
00142 PrintObjectGetVarPN1,
00143 PrintObjectGetVarPN1,NULL,
00144 ObjectGetVarPNFunction1,
00145 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
00146
00147 struct entityRecord objectGVPNInfo2 = { "OBJ_GET_SLOT_PNVAR2", OBJ_GET_SLOT_PNVAR2,0,1,0,
00148 PrintObjectGetVarPN2,
00149 PrintObjectGetVarPN2,NULL,
00150 ObjectGetVarPNFunction2,
00151 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
00152
00153 struct entityRecord objectCmpConstantInfo = { "OBJ_PN_CONSTANT", OBJ_PN_CONSTANT,0,1,1,
00154 PrintObjectCmpConstant,
00155 PrintObjectCmpConstant,NULL,
00156 ObjectCmpConstantFunction,
00157 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
00158
00159 struct entityRecord lengthTestInfo = { "OBJ_SLOT_LENGTH", OBJ_SLOT_LENGTH,0,1,0,
00160 PrintSlotLengthTest,
00161 PrintSlotLengthTest,NULL,
00162 SlotLengthTestFunction,
00163 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
00164
00165 struct entityRecord pNSimpleCompareInfo1 = { "OBJ_PN_CMP1", OBJ_PN_CMP1,0,1,1,
00166 PrintPNSimpleCompareFunction1,
00167 PrintPNSimpleCompareFunction1,NULL,
00168 PNSimpleCompareFunction1,
00169 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
00170
00171 struct entityRecord pNSimpleCompareInfo2 = { "OBJ_PN_CMP2", OBJ_PN_CMP2,0,1,1,
00172 PrintPNSimpleCompareFunction2,
00173 PrintPNSimpleCompareFunction2,NULL,
00174 PNSimpleCompareFunction2,
00175 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
00176
00177 struct entityRecord pNSimpleCompareInfo3 = { "OBJ_PN_CMP3", OBJ_PN_CMP3,0,1,1,
00178 PrintPNSimpleCompareFunction3,
00179 PrintPNSimpleCompareFunction3,NULL,
00180 PNSimpleCompareFunction3,
00181 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
00182
00183 struct entityRecord jNSimpleCompareInfo1 = { "OBJ_JN_CMP1", OBJ_JN_CMP1,0,1,1,
00184 PrintJNSimpleCompareFunction1,
00185 PrintJNSimpleCompareFunction1,NULL,
00186 JNSimpleCompareFunction1,
00187 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
00188
00189 struct entityRecord jNSimpleCompareInfo2 = { "OBJ_JN_CMP2", OBJ_JN_CMP2,0,1,1,
00190 PrintJNSimpleCompareFunction2,
00191 PrintJNSimpleCompareFunction2,NULL,
00192 JNSimpleCompareFunction2,
00193 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
00194
00195 struct entityRecord jNSimpleCompareInfo3 = { "OBJ_JN_CMP3", OBJ_JN_CMP3,0,1,1,
00196 PrintJNSimpleCompareFunction3,
00197 PrintJNSimpleCompareFunction3,NULL,
00198 JNSimpleCompareFunction3,
00199 NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
00200
00201 AllocateEnvironmentData(theEnv,OBJECT_RETE_DATA,sizeof(struct objectReteData),DeallocateObjectReteData);
00202 ObjectReteData(theEnv)->CurrentObjectSlotLength = 1;
00203
00204 memcpy(&ObjectReteData(theEnv)->ObjectGVInfo1,&objectGVInfo1,sizeof(struct entityRecord));
00205 memcpy(&ObjectReteData(theEnv)->ObjectGVInfo2,&objectGVInfo2,sizeof(struct entityRecord));
00206 memcpy(&ObjectReteData(theEnv)->ObjectGVPNInfo1,&objectGVPNInfo1,sizeof(struct entityRecord));
00207 memcpy(&ObjectReteData(theEnv)->ObjectGVPNInfo2,&objectGVPNInfo2,sizeof(struct entityRecord));
00208 memcpy(&ObjectReteData(theEnv)->ObjectCmpConstantInfo,&objectCmpConstantInfo,sizeof(struct entityRecord));
00209 memcpy(&ObjectReteData(theEnv)->LengthTestInfo,&lengthTestInfo,sizeof(struct entityRecord));
00210 memcpy(&ObjectReteData(theEnv)->PNSimpleCompareInfo1,&pNSimpleCompareInfo1,sizeof(struct entityRecord));
00211 memcpy(&ObjectReteData(theEnv)->PNSimpleCompareInfo2,&pNSimpleCompareInfo2,sizeof(struct entityRecord));
00212 memcpy(&ObjectReteData(theEnv)->PNSimpleCompareInfo3,&pNSimpleCompareInfo3,sizeof(struct entityRecord));
00213 memcpy(&ObjectReteData(theEnv)->JNSimpleCompareInfo1,&jNSimpleCompareInfo1,sizeof(struct entityRecord));
00214 memcpy(&ObjectReteData(theEnv)->JNSimpleCompareInfo2,&jNSimpleCompareInfo2,sizeof(struct entityRecord));
00215 memcpy(&ObjectReteData(theEnv)->JNSimpleCompareInfo3,&jNSimpleCompareInfo3,sizeof(struct entityRecord));
00216
00217 InstallPrimitive(theEnv,&ObjectReteData(theEnv)->ObjectGVInfo1,OBJ_GET_SLOT_JNVAR1);
00218 InstallPrimitive(theEnv,&ObjectReteData(theEnv)->ObjectGVInfo2,OBJ_GET_SLOT_JNVAR2);
00219 InstallPrimitive(theEnv,&ObjectReteData(theEnv)->ObjectGVPNInfo1,OBJ_GET_SLOT_PNVAR1);
00220 InstallPrimitive(theEnv,&ObjectReteData(theEnv)->ObjectGVPNInfo2,OBJ_GET_SLOT_PNVAR2);
00221 InstallPrimitive(theEnv,&ObjectReteData(theEnv)->ObjectCmpConstantInfo,OBJ_PN_CONSTANT);
00222 InstallPrimitive(theEnv,&ObjectReteData(theEnv)->LengthTestInfo,OBJ_SLOT_LENGTH);
00223 InstallPrimitive(theEnv,&ObjectReteData(theEnv)->PNSimpleCompareInfo1,OBJ_PN_CMP1);
00224 InstallPrimitive(theEnv,&ObjectReteData(theEnv)->PNSimpleCompareInfo2,OBJ_PN_CMP2);
00225 InstallPrimitive(theEnv,&ObjectReteData(theEnv)->PNSimpleCompareInfo3,OBJ_PN_CMP3);
00226 InstallPrimitive(theEnv,&ObjectReteData(theEnv)->JNSimpleCompareInfo1,OBJ_JN_CMP1);
00227 InstallPrimitive(theEnv,&ObjectReteData(theEnv)->JNSimpleCompareInfo2,OBJ_JN_CMP2);
00228 InstallPrimitive(theEnv,&ObjectReteData(theEnv)->JNSimpleCompareInfo3,OBJ_JN_CMP3);
00229 }
00230
00231
00232
00233
00234
00235 static void DeallocateObjectReteData(
00236 void *theEnv)
00237 {
00238 OBJECT_PATTERN_NODE *theNetwork;
00239
00240 #if BLOAD || BLOAD_AND_BSAVE
00241 if (Bloaded(theEnv)) return;
00242 #endif
00243
00244 theNetwork = ObjectReteData(theEnv)->ObjectPatternNetworkPointer;
00245 DestroyObjectPatternNetwork(theEnv,theNetwork);
00246 }
00247
00248
00249
00250
00251
00252 static void DestroyObjectPatternNetwork(
00253 void *theEnv,
00254 OBJECT_PATTERN_NODE *thePattern)
00255 {
00256 OBJECT_PATTERN_NODE *patternPtr;
00257
00258 if (thePattern == NULL) return;
00259
00260 while (thePattern != NULL)
00261 {
00262 patternPtr = thePattern->rightNode;
00263
00264 DestroyObjectPatternNetwork(theEnv,thePattern->nextLevel);
00265 DestroyObjectAlphaNodes(theEnv,thePattern->alphaNode);
00266 #if ! RUN_TIME
00267 rtn_struct(theEnv,objectPatternNode,thePattern);
00268 #endif
00269 thePattern = patternPtr;
00270 }
00271 }
00272
00273
00274
00275
00276
00277 static void DestroyObjectAlphaNodes(
00278 void *theEnv,
00279 OBJECT_ALPHA_NODE *theNode)
00280 {
00281 OBJECT_ALPHA_NODE *nodePtr;
00282
00283 if (theNode == NULL) return;
00284
00285 while (theNode != NULL)
00286 {
00287 nodePtr = theNode->nxtInGroup;
00288
00289 DestroyAlphaMemory(theEnv,&theNode->header,FALSE);
00290
00291 #if ! RUN_TIME
00292 rtn_struct(theEnv,objectAlphaNode,theNode);
00293 #endif
00294
00295 theNode = nodePtr;
00296 }
00297 }
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312 globle intBool ObjectCmpConstantFunction(
00313 void *theEnv,
00314 void *theValue,
00315 DATA_OBJECT *theResult)
00316 {
00317 struct ObjectCmpPNConstant *hack;
00318 DATA_OBJECT theVar;
00319 EXPRESSION *constantExp;
00320 int rv;
00321 SEGMENT *theSegment;
00322
00323 hack = (struct ObjectCmpPNConstant *) ValueToBitMap(theValue);
00324 if (hack->general)
00325 {
00326 EvaluateExpression(theEnv,GetFirstArgument(),&theVar);
00327 constantExp = GetFirstArgument()->nextArg;
00328 }
00329 else
00330 {
00331 constantExp = GetFirstArgument();
00332 if (ObjectReteData(theEnv)->CurrentPatternObjectSlot->type == MULTIFIELD)
00333 {
00334 theSegment = (struct multifield *) ObjectReteData(theEnv)->CurrentPatternObjectSlot->value;
00335 if (hack->fromBeginning)
00336 {
00337 theVar.type = theSegment->theFields[hack->offset].type;
00338 theVar.value = theSegment->theFields[hack->offset].value;
00339 }
00340 else
00341 {
00342 theVar.type = theSegment->theFields[theSegment->multifieldLength -
00343 (hack->offset + 1)].type;
00344 theVar.value = theSegment->theFields[theSegment->multifieldLength -
00345 (hack->offset + 1)].value;
00346 }
00347 }
00348 else
00349 {
00350 theVar.type = (unsigned short) ObjectReteData(theEnv)->CurrentPatternObjectSlot->type;
00351 theVar.value = ObjectReteData(theEnv)->CurrentPatternObjectSlot->value;
00352 }
00353 }
00354 if (theVar.type != constantExp->type)
00355 rv = hack->fail;
00356 else if (theVar.value != constantExp->value)
00357 rv = hack->fail;
00358 else
00359 rv = hack->pass;
00360 theResult->type = SYMBOL;
00361 theResult->value = rv ? EnvTrueSymbol(theEnv) : EnvFalseSymbol(theEnv);
00362 return(rv);
00363 }
00364
00365
00366
00367
00368
00369
00370
00371 #if WIN_BTC && (! DEVELOPER)
00372 #pragma argsused
00373 #endif
00374 static void PrintObjectGetVarJN1(
00375 void *theEnv,
00376 char *logicalName,
00377 void *theValue)
00378 {
00379 #if DEVELOPER
00380 struct ObjectMatchVar1 *hack;
00381
00382 hack = (struct ObjectMatchVar1 *) ValueToBitMap(theValue);
00383
00384 if (hack->objectAddress)
00385 {
00386 EnvPrintRouter(theEnv,logicalName,"(obj-ptr ");
00387 PrintLongInteger(theEnv,logicalName,(long long) hack->whichPattern);
00388 }
00389 else if (hack->allFields)
00390 {
00391 EnvPrintRouter(theEnv,logicalName,"(obj-slot-contents ");
00392 PrintLongInteger(theEnv,logicalName,(long long) hack->whichPattern);
00393 EnvPrintRouter(theEnv,logicalName," ");
00394 EnvPrintRouter(theEnv,logicalName,ValueToString(FindIDSlotName(theEnv,(unsigned) hack->whichSlot)));
00395 }
00396 else
00397 {
00398 EnvPrintRouter(theEnv,logicalName,"(obj-slot-var ");
00399 PrintLongInteger(theEnv,logicalName,(long long) hack->whichPattern);
00400 EnvPrintRouter(theEnv,logicalName," ");
00401 EnvPrintRouter(theEnv,logicalName,ValueToString(FindIDSlotName(theEnv,(unsigned) hack->whichSlot)));
00402 EnvPrintRouter(theEnv,logicalName," ");
00403 PrintLongInteger(theEnv,logicalName,(long long) hack->whichField);
00404 }
00405 EnvPrintRouter(theEnv,logicalName,")");
00406 #else
00407 #if MAC_MCW || WIN_MCW || MAC_XCD
00408 #pragma unused(theEnv)
00409 #pragma unused(logicalName)
00410 #pragma unused(theValue)
00411 #endif
00412 #endif
00413 }
00414
00415 static intBool ObjectGetVarJNFunction1(
00416 void *theEnv,
00417 void *theValue,
00418 DATA_OBJECT *theResult)
00419 {
00420 struct ObjectMatchVar1 *hack;
00421 INSTANCE_TYPE *theInstance;
00422 struct multifieldMarker *theMarks;
00423
00424 hack = (struct ObjectMatchVar1 *) ValueToBitMap(theValue);
00425 GetPatternObjectAndMarks(theEnv,((int) hack->whichPattern),hack->lhs,hack->rhs,&theInstance,&theMarks);
00426 GetObjectValueGeneral(theEnv,theResult,theInstance,theMarks,hack);
00427 return(TRUE);
00428 }
00429
00430 #if WIN_BTC && (! DEVELOPER)
00431 #pragma argsused
00432 #endif
00433 static void PrintObjectGetVarJN2(
00434 void *theEnv,
00435 char *logicalName,
00436 void *theValue)
00437 {
00438 #if DEVELOPER
00439 struct ObjectMatchVar2 *hack;
00440
00441 hack = (struct ObjectMatchVar2 *) ValueToBitMap(theValue);
00442 EnvPrintRouter(theEnv,logicalName,"(obj-slot-quick-var ");
00443 PrintLongInteger(theEnv,logicalName,(long long) hack->whichPattern);
00444 EnvPrintRouter(theEnv,logicalName," ");
00445 EnvPrintRouter(theEnv,logicalName,ValueToString(FindIDSlotName(theEnv,(unsigned) hack->whichSlot)));
00446 if (hack->fromBeginning)
00447 {
00448 EnvPrintRouter(theEnv,logicalName," B");
00449 PrintLongInteger(theEnv,logicalName,(long long) (hack->beginningOffset + 1));
00450 }
00451 if (hack->fromEnd)
00452 {
00453 EnvPrintRouter(theEnv,logicalName," E");
00454 PrintLongInteger(theEnv,logicalName,(long long) (hack->endOffset + 1));
00455 }
00456 EnvPrintRouter(theEnv,logicalName,")");
00457 #else
00458 #if MAC_MCW || WIN_MCW || MAC_XCD
00459 #pragma unused(theEnv)
00460 #pragma unused(logicalName)
00461 #pragma unused(theValue)
00462 #endif
00463 #endif
00464 }
00465
00466 static intBool ObjectGetVarJNFunction2(
00467 void *theEnv,
00468 void *theValue,
00469 DATA_OBJECT *theResult)
00470 {
00471 struct ObjectMatchVar2 *hack;
00472 INSTANCE_TYPE *theInstance;
00473 struct multifieldMarker *theMarks;
00474
00475 hack = (struct ObjectMatchVar2 *) ValueToBitMap(theValue);
00476 GetPatternObjectAndMarks(theEnv,((int) hack->whichPattern),hack->lhs,hack->rhs,&theInstance,&theMarks);
00477 GetObjectValueSimple(theEnv,theResult,theInstance,hack);
00478 return(TRUE);
00479 }
00480
00481 #if WIN_BTC && (! DEVELOPER)
00482 #pragma argsused
00483 #endif
00484 static void PrintObjectGetVarPN1(
00485 void *theEnv,
00486 char *logicalName,
00487 void *theValue)
00488 {
00489 #if DEVELOPER
00490 struct ObjectMatchVar1 *hack;
00491
00492 hack = (struct ObjectMatchVar1 *) ValueToBitMap(theValue);
00493
00494 if (hack->objectAddress)
00495 EnvPrintRouter(theEnv,logicalName,"(ptn-obj-ptr ");
00496 else if (hack->allFields)
00497 {
00498 EnvPrintRouter(theEnv,logicalName,"(ptn-obj-slot-contents ");
00499 EnvPrintRouter(theEnv,logicalName,ValueToString(FindIDSlotName(theEnv,(unsigned) hack->whichSlot)));
00500 }
00501 else
00502 {
00503 EnvPrintRouter(theEnv,logicalName,"(ptn-obj-slot-var ");
00504 EnvPrintRouter(theEnv,logicalName,ValueToString(FindIDSlotName(theEnv,(unsigned) hack->whichSlot)));
00505 EnvPrintRouter(theEnv,logicalName," ");
00506 PrintLongInteger(theEnv,logicalName,(long long) hack->whichField);
00507 }
00508 EnvPrintRouter(theEnv,logicalName,")");
00509 #else
00510 #if MAC_MCW || WIN_MCW || MAC_XCD
00511 #pragma unused(theEnv)
00512 #pragma unused(logicalName)
00513 #pragma unused(theValue)
00514 #endif
00515 #endif
00516 }
00517
00518 static intBool ObjectGetVarPNFunction1(
00519 void *theEnv,
00520 void *theValue,
00521 DATA_OBJECT *theResult)
00522 {
00523 struct ObjectMatchVar1 *hack;
00524
00525 hack = (struct ObjectMatchVar1 *) ValueToBitMap(theValue);
00526 GetObjectValueGeneral(theEnv,theResult,ObjectReteData(theEnv)->CurrentPatternObject,ObjectReteData(theEnv)->CurrentPatternObjectMarks,hack);
00527 return(TRUE);
00528 }
00529
00530 #if WIN_BTC && (! DEVELOPER)
00531 #pragma argsused
00532 #endif
00533 static void PrintObjectGetVarPN2(
00534 void *theEnv,
00535 char *logicalName,
00536 void *theValue)
00537 {
00538 #if DEVELOPER
00539 struct ObjectMatchVar2 *hack;
00540
00541 hack = (struct ObjectMatchVar2 *) ValueToBitMap(theValue);
00542 EnvPrintRouter(theEnv,logicalName,"(ptn-obj-slot-quick-var ");
00543 EnvPrintRouter(theEnv,logicalName,ValueToString(FindIDSlotName(theEnv,(unsigned) hack->whichSlot)));
00544 if (hack->fromBeginning)
00545 {
00546 EnvPrintRouter(theEnv,logicalName," B");
00547 PrintLongInteger(theEnv,logicalName,(long long) (hack->beginningOffset + 1));
00548 }
00549 if (hack->fromEnd)
00550 {
00551 EnvPrintRouter(theEnv,logicalName," E");
00552 PrintLongInteger(theEnv,logicalName,(long long) (hack->endOffset + 1));
00553 }
00554 EnvPrintRouter(theEnv,logicalName,")");
00555 #else
00556 #if MAC_MCW || WIN_MCW || MAC_XCD
00557 #pragma unused(theEnv)
00558 #pragma unused(logicalName)
00559 #pragma unused(theValue)
00560 #endif
00561 #endif
00562 }
00563
00564 static intBool ObjectGetVarPNFunction2(
00565 void *theEnv,
00566 void *theValue,
00567 DATA_OBJECT *theResult)
00568 {
00569 struct ObjectMatchVar2 *hack;
00570
00571 hack = (struct ObjectMatchVar2 *) ValueToBitMap(theValue);
00572 GetObjectValueSimple(theEnv,theResult,ObjectReteData(theEnv)->CurrentPatternObject,hack);
00573 return(TRUE);
00574 }
00575
00576 #if WIN_BTC && (! DEVELOPER)
00577 #pragma argsused
00578 #endif
00579 static void PrintObjectCmpConstant(
00580 void *theEnv,
00581 char *logicalName,
00582 void *theValue)
00583 {
00584 #if DEVELOPER
00585 struct ObjectCmpPNConstant *hack;
00586
00587 hack = (struct ObjectCmpPNConstant *) ValueToBitMap(theValue);
00588
00589 EnvPrintRouter(theEnv,logicalName,"(obj-const ");
00590 EnvPrintRouter(theEnv,logicalName,hack->pass ? "p " : "n ");
00591 if (hack->general)
00592 PrintExpression(theEnv,logicalName,GetFirstArgument());
00593 else
00594 {
00595 EnvPrintRouter(theEnv,logicalName,hack->fromBeginning ? "B" : "E");
00596 PrintLongInteger(theEnv,logicalName,(long long) hack->offset);
00597 EnvPrintRouter(theEnv,logicalName," ");
00598 PrintExpression(theEnv,logicalName,GetFirstArgument());
00599 }
00600 EnvPrintRouter(theEnv,logicalName,")");
00601 #else
00602 #if MAC_MCW || WIN_MCW || MAC_XCD
00603 #pragma unused(theEnv)
00604 #pragma unused(logicalName)
00605 #pragma unused(theValue)
00606 #endif
00607 #endif
00608 }
00609
00610 #if WIN_BTC && (! DEVELOPER)
00611 #pragma argsused
00612 #endif
00613 static void PrintSlotLengthTest(
00614 void *theEnv,
00615 char *logicalName,
00616 void *theValue)
00617 {
00618 #if DEVELOPER
00619 struct ObjectMatchLength *hack;
00620
00621 hack = (struct ObjectMatchLength *) ValueToBitMap(theValue);
00622
00623 EnvPrintRouter(theEnv,logicalName,"(obj-slot-len ");
00624 if (hack->exactly)
00625 EnvPrintRouter(theEnv,logicalName,"= ");
00626 else
00627 EnvPrintRouter(theEnv,logicalName,">= ");
00628 PrintLongInteger(theEnv,logicalName,(long long) hack->minLength);
00629 EnvPrintRouter(theEnv,logicalName,")");
00630 #else
00631 #if MAC_MCW || WIN_MCW || MAC_XCD
00632 #pragma unused(theEnv)
00633 #pragma unused(logicalName)
00634 #pragma unused(theValue)
00635 #endif
00636 #endif
00637 }
00638
00639 static intBool SlotLengthTestFunction(
00640 void *theEnv,
00641 void *theValue,
00642 DATA_OBJECT *theResult)
00643 {
00644 struct ObjectMatchLength *hack;
00645
00646 theResult->type = SYMBOL;
00647 theResult->value = EnvFalseSymbol(theEnv);
00648 hack = (struct ObjectMatchLength *) ValueToBitMap(theValue);
00649 if (ObjectReteData(theEnv)->CurrentObjectSlotLength < hack->minLength)
00650 return(FALSE);
00651 if (hack->exactly && (ObjectReteData(theEnv)->CurrentObjectSlotLength > hack->minLength))
00652 return(FALSE);
00653 theResult->value = EnvTrueSymbol(theEnv);
00654 return(TRUE);
00655 }
00656
00657 #if WIN_BTC && (! DEVELOPER)
00658 #pragma argsused
00659 #endif
00660 static void PrintPNSimpleCompareFunction1(
00661 void *theEnv,
00662 char *logicalName,
00663 void *theValue)
00664 {
00665 #if DEVELOPER
00666 struct ObjectCmpPNSingleSlotVars1 *hack;
00667
00668 hack = (struct ObjectCmpPNSingleSlotVars1 *) ValueToBitMap(theValue);
00669
00670 EnvPrintRouter(theEnv,logicalName,"(pslot-cmp1 ");
00671 EnvPrintRouter(theEnv,logicalName,hack->pass ? "p " : "n ");
00672 EnvPrintRouter(theEnv,logicalName,ValueToString(FindIDSlotName(theEnv,(unsigned) hack->firstSlot)));
00673 EnvPrintRouter(theEnv,logicalName," ");
00674 EnvPrintRouter(theEnv,logicalName,ValueToString(FindIDSlotName(theEnv,(unsigned) hack->secondSlot)));
00675 EnvPrintRouter(theEnv,logicalName,")");
00676 #else
00677 #if MAC_MCW || WIN_MCW || MAC_XCD
00678 #pragma unused(theEnv)
00679 #pragma unused(logicalName)
00680 #pragma unused(theValue)
00681 #endif
00682 #endif
00683 }
00684
00685 static intBool PNSimpleCompareFunction1(
00686 void *theEnv,
00687 void *theValue,
00688 DATA_OBJECT *theResult)
00689 {
00690 struct ObjectCmpPNSingleSlotVars1 *hack;
00691 INSTANCE_SLOT *is1,*is2;
00692 int rv;
00693
00694 hack = (struct ObjectCmpPNSingleSlotVars1 *) ValueToBitMap(theValue);
00695 is1 = GetInsSlot(ObjectReteData(theEnv)->CurrentPatternObject,hack->firstSlot);
00696 is2 = GetInsSlot(ObjectReteData(theEnv)->CurrentPatternObject,hack->secondSlot);
00697 if (is1->type != is2->type)
00698 rv = hack->fail;
00699 else if (is1->value != is2->value)
00700 rv = hack->fail;
00701 else
00702 rv = hack->pass;
00703 theResult->type = SYMBOL;
00704 theResult->value = rv ? EnvTrueSymbol(theEnv) : EnvFalseSymbol(theEnv);
00705 return(rv);
00706 }
00707
00708 #if WIN_BTC && (! DEVELOPER)
00709 #pragma argsused
00710 #endif
00711 static void PrintPNSimpleCompareFunction2(
00712 void *theEnv,
00713 char *logicalName,
00714 void *theValue)
00715 {
00716 #if DEVELOPER
00717 struct ObjectCmpPNSingleSlotVars2 *hack;
00718
00719 hack = (struct ObjectCmpPNSingleSlotVars2 *) ValueToBitMap(theValue);
00720
00721 EnvPrintRouter(theEnv,logicalName,"(pslot-cmp2 ");
00722 EnvPrintRouter(theEnv,logicalName,hack->pass ? "p " : "n ");
00723 EnvPrintRouter(theEnv,logicalName,ValueToString(FindIDSlotName(theEnv,(unsigned) hack->firstSlot)));
00724 EnvPrintRouter(theEnv,logicalName,hack->fromBeginning ? " B" : " E");
00725 PrintLongInteger(theEnv,logicalName,(long long) hack->offset);
00726 EnvPrintRouter(theEnv,logicalName," ");
00727 EnvPrintRouter(theEnv,logicalName,ValueToString(FindIDSlotName(theEnv,(unsigned) hack->secondSlot)));
00728 EnvPrintRouter(theEnv,logicalName,")");
00729 #else
00730 #if MAC_MCW || WIN_MCW || MAC_XCD
00731 #pragma unused(theEnv)
00732 #pragma unused(logicalName)
00733 #pragma unused(theValue)
00734 #endif
00735 #endif
00736 }
00737
00738 static intBool PNSimpleCompareFunction2(
00739 void *theEnv,
00740 void *theValue,
00741 DATA_OBJECT *theResult)
00742 {
00743 struct ObjectCmpPNSingleSlotVars2 *hack;
00744 int rv;
00745 FIELD f1;
00746 INSTANCE_SLOT *is2;
00747
00748 hack = (struct ObjectCmpPNSingleSlotVars2 *) ValueToBitMap(theValue);
00749 GetInsMultiSlotField(&f1,ObjectReteData(theEnv)->CurrentPatternObject,(unsigned) hack->firstSlot,
00750 (unsigned) hack->fromBeginning,(unsigned) hack->offset);
00751 is2 = GetInsSlot(ObjectReteData(theEnv)->CurrentPatternObject,hack->secondSlot);
00752 if (f1.type != is2->type)
00753 rv = hack->fail;
00754 else if (f1.value != is2->value)
00755 rv = hack->fail;
00756 else
00757 rv = hack->pass;
00758 theResult->type = SYMBOL;
00759 theResult->value = rv ? EnvTrueSymbol(theEnv) : EnvFalseSymbol(theEnv);
00760 return(rv);
00761 }
00762
00763 #if WIN_BTC && (! DEVELOPER)
00764 #pragma argsused
00765 #endif
00766 static void PrintPNSimpleCompareFunction3(
00767 void *theEnv,
00768 char *logicalName,
00769 void *theValue)
00770 {
00771 #if DEVELOPER
00772 struct ObjectCmpPNSingleSlotVars3 *hack;
00773
00774 hack = (struct ObjectCmpPNSingleSlotVars3 *) ValueToBitMap(theValue);
00775
00776 EnvPrintRouter(theEnv,logicalName,"(pslot-cmp3 ");
00777 EnvPrintRouter(theEnv,logicalName,hack->pass ? "p " : "n ");
00778 EnvPrintRouter(theEnv,logicalName,ValueToString(FindIDSlotName(theEnv,(unsigned) hack->firstSlot)));
00779 EnvPrintRouter(theEnv,logicalName,hack->firstFromBeginning ? " B" : " E");
00780 PrintLongInteger(theEnv,logicalName,(long long) hack->firstOffset);
00781 EnvPrintRouter(theEnv,logicalName," ");
00782 EnvPrintRouter(theEnv,logicalName,ValueToString(FindIDSlotName(theEnv,(unsigned) hack->secondSlot)));
00783 EnvPrintRouter(theEnv,logicalName,hack->secondFromBeginning ? " B" : " E");
00784 PrintLongInteger(theEnv,logicalName,(long long) hack->secondOffset);
00785 EnvPrintRouter(theEnv,logicalName,")");
00786 #else
00787 #if MAC_MCW || WIN_MCW || MAC_XCD
00788 #pragma unused(theEnv)
00789 #pragma unused(logicalName)
00790 #pragma unused(theValue)
00791 #endif
00792 #endif
00793 }
00794
00795 static intBool PNSimpleCompareFunction3(
00796 void *theEnv,
00797 void *theValue,
00798 DATA_OBJECT *theResult)
00799 {
00800 struct ObjectCmpPNSingleSlotVars3 *hack;
00801 int rv;
00802 FIELD f1,f2;
00803
00804 hack = (struct ObjectCmpPNSingleSlotVars3 *) ValueToBitMap(theValue);
00805 GetInsMultiSlotField(&f1,ObjectReteData(theEnv)->CurrentPatternObject,(unsigned) hack->firstSlot,
00806 (unsigned) hack->firstFromBeginning,(unsigned) hack->firstOffset);
00807 GetInsMultiSlotField(&f2,ObjectReteData(theEnv)->CurrentPatternObject,(unsigned) hack->secondSlot,
00808 (unsigned) hack->secondFromBeginning,(unsigned) hack->secondOffset);
00809 if (f1.type != f2.type)
00810 rv = hack->fail;
00811 else if (f1.value != f2.value)
00812 rv = hack->fail;
00813 else
00814 rv = hack->pass;
00815 theResult->type = SYMBOL;
00816 theResult->value = rv ? EnvTrueSymbol(theEnv) : EnvFalseSymbol(theEnv);
00817 return(rv);
00818 }
00819
00820 #if WIN_BTC && (! DEVELOPER)
00821 #pragma argsused
00822 #endif
00823 static void PrintJNSimpleCompareFunction1(
00824 void *theEnv,
00825 char *logicalName,
00826 void *theValue)
00827 {
00828 #if DEVELOPER
00829 struct ObjectCmpJoinSingleSlotVars1 *hack;
00830
00831 hack = (struct ObjectCmpJoinSingleSlotVars1 *) ValueToBitMap(theValue);
00832
00833 EnvPrintRouter(theEnv,logicalName,"(jslot-cmp1 ");
00834 EnvPrintRouter(theEnv,logicalName,hack->pass ? "p " : "n ");
00835 PrintLongInteger(theEnv,logicalName,(long long) hack->firstPattern);
00836 EnvPrintRouter(theEnv,logicalName," ");
00837 EnvPrintRouter(theEnv,logicalName,ValueToString(FindIDSlotName(theEnv,(unsigned) hack->firstSlot)));
00838 EnvPrintRouter(theEnv,logicalName," ");
00839 PrintLongInteger(theEnv,logicalName,(long long) hack->secondPattern);
00840 EnvPrintRouter(theEnv,logicalName," ");
00841 EnvPrintRouter(theEnv,logicalName,ValueToString(FindIDSlotName(theEnv,(unsigned) hack->secondSlot)));
00842 EnvPrintRouter(theEnv,logicalName,")");
00843 #else
00844 #if MAC_MCW || WIN_MCW || MAC_XCD
00845 #pragma unused(theEnv)
00846 #pragma unused(logicalName)
00847 #pragma unused(theValue)
00848 #endif
00849 #endif
00850 }
00851
00852 static intBool JNSimpleCompareFunction1(
00853 void *theEnv,
00854 void *theValue,
00855 DATA_OBJECT *theResult)
00856 {
00857 INSTANCE_TYPE *ins1,*ins2;
00858 struct multifieldMarker *theMarks;
00859 struct ObjectCmpJoinSingleSlotVars1 *hack;
00860 int rv;
00861 INSTANCE_SLOT *is1,*is2;
00862
00863 hack = (struct ObjectCmpJoinSingleSlotVars1 *) ValueToBitMap(theValue);
00864 GetPatternObjectAndMarks(theEnv,((int) hack->firstPattern),hack->firstPatternLHS,hack->firstPatternRHS,&ins1,&theMarks);
00865 is1 = GetInsSlot(ins1,hack->firstSlot);
00866 GetPatternObjectAndMarks(theEnv,((int) hack->secondPattern),hack->secondPatternLHS,hack->secondPatternRHS,&ins2,&theMarks);
00867 is2 = GetInsSlot(ins2,hack->secondSlot);
00868 if (is1->type != is2->type)
00869 rv = hack->fail;
00870 else if (is1->value != is2->value)
00871 rv = hack->fail;
00872 else
00873 rv = hack->pass;
00874 theResult->type = SYMBOL;
00875 theResult->value = rv ? EnvTrueSymbol(theEnv) : EnvFalseSymbol(theEnv);
00876 return(rv);
00877 }
00878
00879 #if WIN_BTC && (! DEVELOPER)
00880 #pragma argsused
00881 #endif
00882 static void PrintJNSimpleCompareFunction2(
00883 void *theEnv,
00884 char *logicalName,
00885 void *theValue)
00886 {
00887 #if DEVELOPER
00888 struct ObjectCmpJoinSingleSlotVars2 *hack;
00889
00890 hack = (struct ObjectCmpJoinSingleSlotVars2 *) ValueToBitMap(theValue);
00891
00892 EnvPrintRouter(theEnv,logicalName,"(jslot-cmp2 ");
00893 EnvPrintRouter(theEnv,logicalName,hack->pass ? "p " : "n ");
00894 PrintLongInteger(theEnv,logicalName,(long long) hack->firstPattern);
00895 EnvPrintRouter(theEnv,logicalName," ");
00896 EnvPrintRouter(theEnv,logicalName,ValueToString(FindIDSlotName(theEnv,(unsigned) hack->firstSlot)));
00897 EnvPrintRouter(theEnv,logicalName,hack->fromBeginning ? " B" : " E");
00898 PrintLongInteger(theEnv,logicalName,(long long) hack->offset);
00899 EnvPrintRouter(theEnv,logicalName," ");
00900 PrintLongInteger(theEnv,logicalName,(long long) hack->secondPattern);
00901 EnvPrintRouter(theEnv,logicalName," ");
00902 EnvPrintRouter(theEnv,logicalName,ValueToString(FindIDSlotName(theEnv,(unsigned) hack->secondSlot)));
00903 EnvPrintRouter(theEnv,logicalName,")");
00904 #else
00905 #if MAC_MCW || WIN_MCW || MAC_XCD
00906 #pragma unused(theEnv)
00907 #pragma unused(logicalName)
00908 #pragma unused(theValue)
00909 #endif
00910 #endif
00911 }
00912
00913 static intBool JNSimpleCompareFunction2(
00914 void *theEnv,
00915 void *theValue,
00916 DATA_OBJECT *theResult)
00917 {
00918 INSTANCE_TYPE *ins1,*ins2;
00919 struct multifieldMarker *theMarks;
00920 struct ObjectCmpJoinSingleSlotVars2 *hack;
00921 int rv;
00922 FIELD f1;
00923 INSTANCE_SLOT *is2;
00924
00925 hack = (struct ObjectCmpJoinSingleSlotVars2 *) ValueToBitMap(theValue);
00926 GetPatternObjectAndMarks(theEnv,((int) hack->firstPattern),hack->firstPatternLHS,hack->firstPatternRHS,&ins1,&theMarks);
00927 GetInsMultiSlotField(&f1,ins1,(unsigned) hack->firstSlot,
00928 (unsigned) hack->fromBeginning,(unsigned) hack->offset);
00929 GetPatternObjectAndMarks(theEnv,((int) hack->secondPattern),hack->secondPatternLHS,hack->secondPatternRHS,&ins2,&theMarks);
00930 is2 = GetInsSlot(ins2,hack->secondSlot);
00931 if (f1.type != is2->type)
00932 rv = hack->fail;
00933 else if (f1.value != is2->value)
00934 rv = hack->fail;
00935 else
00936 rv = hack->pass;
00937 theResult->type = SYMBOL;
00938 theResult->value = rv ? EnvTrueSymbol(theEnv) : EnvFalseSymbol(theEnv);
00939 return(rv);
00940 }
00941
00942 #if WIN_BTC && (! DEVELOPER)
00943 #pragma argsused
00944 #endif
00945 static void PrintJNSimpleCompareFunction3(
00946 void *theEnv,
00947 char *logicalName,
00948 void *theValue)
00949 {
00950 #if DEVELOPER
00951 struct ObjectCmpJoinSingleSlotVars3 *hack;
00952
00953 hack = (struct ObjectCmpJoinSingleSlotVars3 *) ValueToBitMap(theValue);
00954
00955 EnvPrintRouter(theEnv,logicalName,"(jslot-cmp3 ");
00956 EnvPrintRouter(theEnv,logicalName,hack->pass ? "p " : "n ");
00957 PrintLongInteger(theEnv,logicalName,(long long) hack->firstPattern);
00958 EnvPrintRouter(theEnv,logicalName," ");
00959 EnvPrintRouter(theEnv,logicalName,ValueToString(FindIDSlotName(theEnv,(unsigned) hack->firstSlot)));
00960 EnvPrintRouter(theEnv,logicalName,hack->firstFromBeginning ? " B" : " E");
00961 PrintLongInteger(theEnv,logicalName,(long long) hack->firstOffset);
00962 EnvPrintRouter(theEnv,logicalName," ");
00963 PrintLongInteger(theEnv,logicalName,(long long) hack->secondPattern);
00964 EnvPrintRouter(theEnv,logicalName," ");
00965 EnvPrintRouter(theEnv,logicalName,ValueToString(FindIDSlotName(theEnv,(unsigned) hack->secondSlot)));
00966 EnvPrintRouter(theEnv,logicalName,hack->secondFromBeginning ? " B" : " E");
00967 PrintLongInteger(theEnv,logicalName,(long long) hack->secondOffset);
00968 EnvPrintRouter(theEnv,logicalName,")");
00969 #else
00970 #if MAC_MCW || WIN_MCW || MAC_XCD
00971 #pragma unused(theEnv)
00972 #pragma unused(logicalName)
00973 #pragma unused(theValue)
00974 #endif
00975 #endif
00976 }
00977
00978 static intBool JNSimpleCompareFunction3(
00979 void *theEnv,
00980 void *theValue,
00981 DATA_OBJECT *theResult)
00982 {
00983 INSTANCE_TYPE *ins1,*ins2;
00984 struct multifieldMarker *theMarks;
00985 struct ObjectCmpJoinSingleSlotVars3 *hack;
00986 int rv;
00987 FIELD f1,f2;
00988
00989 hack = (struct ObjectCmpJoinSingleSlotVars3 *) ValueToBitMap(theValue);
00990 GetPatternObjectAndMarks(theEnv,((int) hack->firstPattern),hack->firstPatternLHS,hack->firstPatternRHS,&ins1,&theMarks);
00991 GetInsMultiSlotField(&f1,ins1,(unsigned) hack->firstSlot,
00992 (unsigned) hack->firstFromBeginning,
00993 (unsigned) hack->firstOffset);
00994 GetPatternObjectAndMarks(theEnv,((int) hack->secondPattern),hack->secondPatternLHS,hack->secondPatternRHS,&ins2,&theMarks);
00995 GetInsMultiSlotField(&f2,ins2,(unsigned) hack->secondSlot,
00996 (unsigned) hack->secondFromBeginning,
00997 (unsigned) hack->secondOffset);
00998 if (f1.type != f2.type)
00999 rv = hack->fail;
01000 else if (f1.value != f2.value)
01001 rv = hack->fail;
01002 else
01003 rv = hack->pass;
01004 theResult->type = SYMBOL;
01005 theResult->value = rv ? EnvTrueSymbol(theEnv) : EnvFalseSymbol(theEnv);
01006 return(rv);
01007 }
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022
01023 static void GetPatternObjectAndMarks(
01024 void *theEnv,
01025 int pattern,
01026 int lhs,
01027 int rhs,
01028 INSTANCE_TYPE **theInstance,
01029 struct multifieldMarker **theMarkers)
01030 {
01031 if (lhs)
01032 {
01033 *theInstance = (INSTANCE_TYPE *)
01034 get_nth_pm_match(EngineData(theEnv)->GlobalLHSBinds,pattern)->matchingItem;
01035 *theMarkers =
01036 get_nth_pm_match(EngineData(theEnv)->GlobalLHSBinds,pattern)->markers;
01037 }
01038 else if (rhs)
01039 {
01040 *theInstance = (INSTANCE_TYPE *)
01041 get_nth_pm_match(EngineData(theEnv)->GlobalRHSBinds,pattern)->matchingItem;
01042 *theMarkers =
01043 get_nth_pm_match(EngineData(theEnv)->GlobalRHSBinds,pattern)->markers;
01044 }
01045 else if (EngineData(theEnv)->GlobalRHSBinds == NULL)
01046 {
01047 *theInstance = (INSTANCE_TYPE *)
01048 get_nth_pm_match(EngineData(theEnv)->GlobalLHSBinds,pattern)->matchingItem;
01049 *theMarkers =
01050 get_nth_pm_match(EngineData(theEnv)->GlobalLHSBinds,pattern)->markers;
01051 }
01052 else if ((((int) EngineData(theEnv)->GlobalJoin->depth) - 1) == pattern)
01053 {
01054 *theInstance = (INSTANCE_TYPE *)
01055 get_nth_pm_match(EngineData(theEnv)->GlobalRHSBinds,0)->matchingItem;
01056 *theMarkers = get_nth_pm_match(EngineData(theEnv)->GlobalRHSBinds,0)->markers;
01057 }
01058 else
01059 {
01060 *theInstance = (INSTANCE_TYPE *)
01061 get_nth_pm_match(EngineData(theEnv)->GlobalLHSBinds,pattern)->matchingItem;
01062 *theMarkers =
01063 get_nth_pm_match(EngineData(theEnv)->GlobalLHSBinds,pattern)->markers;
01064 }
01065 }
01066
01067
01068
01069
01070
01071
01072
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082 static void GetObjectValueGeneral(
01083 void *theEnv,
01084 DATA_OBJECT *result,
01085 INSTANCE_TYPE *theInstance,
01086 struct multifieldMarker *theMarks,
01087 struct ObjectMatchVar1 *matchVar)
01088 {
01089 long field, extent;
01090 INSTANCE_SLOT **insSlot,*basisSlot;
01091
01092 if (matchVar->objectAddress)
01093 {
01094 result->type = INSTANCE_ADDRESS;
01095 result->value = (void *) theInstance;
01096 return;
01097 }
01098 if (matchVar->whichSlot == ISA_ID)
01099 {
01100 result->type = SYMBOL;
01101 result->value = (void *) GetDefclassNamePointer((void *) theInstance->cls);
01102 return;
01103 }
01104 if (matchVar->whichSlot == NAME_ID)
01105 {
01106 result->type = INSTANCE_NAME;
01107 result->value = (void *) theInstance->name;
01108 return;
01109 }
01110 insSlot =
01111 &theInstance->slotAddresses
01112 [theInstance->cls->slotNameMap[matchVar->whichSlot] - 1];
01113
01114
01115
01116
01117
01118
01119
01120
01121
01122
01123
01124 if ((theInstance->basisSlots != NULL) &&
01125 (! EngineData(theEnv)->JoinOperationInProgress))
01126 {
01127 basisSlot = theInstance->basisSlots + (insSlot - theInstance->slotAddresses);
01128 if (basisSlot->value != NULL)
01129 insSlot = &basisSlot;
01130 }
01131
01132
01133
01134
01135
01136
01137 if (matchVar->allFields)
01138 {
01139 result->type = (unsigned short) (*insSlot)->type;
01140 result->value = (*insSlot)->value;
01141 if (result->type == MULTIFIELD)
01142 {
01143 result->begin = 0;
01144 SetpDOEnd(result,GetMFLength((*insSlot)->value));
01145 }
01146 return;
01147 }
01148
01149
01150
01151
01152
01153 field = CalculateSlotField(theMarks,*insSlot,matchVar->whichField,&extent);
01154 if (extent == -1)
01155 {
01156 if ((*insSlot)->desc->multiple)
01157 {
01158 result->type = GetMFType((*insSlot)->value,field);
01159 result->value = GetMFValue((*insSlot)->value,field);
01160 }
01161 else
01162 {
01163 result->type = (unsigned short) (*insSlot)->type;
01164 result->value = (*insSlot)->value;
01165 }
01166 }
01167 else
01168 {
01169 result->type = MULTIFIELD;
01170 result->value = (*insSlot)->value;
01171 result->begin = field - 1;
01172 result->end = field + extent - 2;
01173 }
01174 }
01175
01176
01177
01178
01179
01180
01181
01182
01183
01184
01185
01186
01187
01188
01189 static void GetObjectValueSimple(
01190 void *theEnv,
01191 DATA_OBJECT *result,
01192 INSTANCE_TYPE *theInstance,
01193 struct ObjectMatchVar2 *matchVar)
01194 {
01195 INSTANCE_SLOT **insSlot,*basisSlot;
01196 SEGMENT *segmentPtr;
01197 FIELD *fieldPtr;
01198
01199 insSlot =
01200 &theInstance->slotAddresses
01201 [theInstance->cls->slotNameMap[matchVar->whichSlot] - 1];
01202
01203
01204
01205
01206
01207
01208
01209
01210
01211
01212
01213 if ((theInstance->basisSlots != NULL) &&
01214 (! EngineData(theEnv)->JoinOperationInProgress))
01215 {
01216 basisSlot = theInstance->basisSlots + (insSlot - theInstance->slotAddresses);
01217 if (basisSlot->value != NULL)
01218 insSlot = &basisSlot;
01219 }
01220
01221 if ((*insSlot)->desc->multiple)
01222 {
01223 segmentPtr = (SEGMENT *) (*insSlot)->value;
01224 if (matchVar->fromBeginning)
01225 {
01226 if (matchVar->fromEnd)
01227 {
01228 result->type = MULTIFIELD;
01229 result->value = (void *) segmentPtr;
01230 result->begin = matchVar->beginningOffset;
01231 SetpDOEnd(result,GetMFLength(segmentPtr) - matchVar->endOffset);
01232 }
01233 else
01234 {
01235 fieldPtr = &segmentPtr->theFields[matchVar->beginningOffset];
01236 result->type = fieldPtr->type;
01237 result->value = fieldPtr->value;
01238 }
01239 }
01240 else
01241 {
01242 fieldPtr = &segmentPtr->theFields[segmentPtr->multifieldLength -
01243 (matchVar->endOffset + 1)];
01244 result->type = fieldPtr->type;
01245 result->value = fieldPtr->value;
01246 }
01247 }
01248 else
01249 {
01250 result->type = (unsigned short) (*insSlot)->type;
01251 result->value = (*insSlot)->value;
01252 }
01253 }
01254
01255
01256
01257
01258
01259
01260
01261
01262
01263
01264
01265
01266
01267
01268
01269
01270 static long CalculateSlotField(
01271 struct multifieldMarker *theMarkers,
01272 INSTANCE_SLOT *theSlot,
01273 long theIndex,
01274 long *extent)
01275 {
01276 register long actualIndex;
01277 void *theSlotName;
01278
01279 actualIndex = theIndex;
01280 *extent = -1;
01281 if (theSlot == NULL)
01282 return(actualIndex);
01283 theSlotName = (void *) theSlot->desc->slotName->name;
01284 while (theMarkers != NULL)
01285 {
01286 if (theMarkers->where.whichSlot == theSlotName)
01287 break;
01288 theMarkers = theMarkers->next;
01289 }
01290 while ((theMarkers != NULL) ? (theMarkers->where.whichSlot == theSlotName) : FALSE)
01291 {
01292 if (theMarkers->whichField == theIndex)
01293 {
01294 *extent = theMarkers->endPosition - theMarkers->startPosition + 1;
01295 return(actualIndex);
01296 }
01297 if (theMarkers->whichField > theIndex)
01298 return(actualIndex);
01299 actualIndex += theMarkers->endPosition - theMarkers->startPosition;
01300 theMarkers = theMarkers->next;
01301 }
01302 return(actualIndex);
01303 }
01304
01305
01306
01307
01308
01309
01310
01311
01312
01313
01314
01315
01316
01317
01318
01319
01320
01321
01322
01323
01324
01325 static void GetInsMultiSlotField(
01326 FIELD *theField,
01327 INSTANCE_TYPE *theInstance,
01328 unsigned theSlotID,
01329 unsigned fromBeginning,
01330 unsigned offset)
01331 {
01332 register INSTANCE_SLOT * insSlot;
01333 register SEGMENT *theSegment;
01334 register FIELD *tmpField;
01335
01336 insSlot = theInstance->slotAddresses
01337 [theInstance->cls->slotNameMap[theSlotID] - 1];
01338
01339
01340
01341 if (insSlot->desc->multiple)
01342 {
01343 theSegment = (SEGMENT *) insSlot->value;
01344 if (fromBeginning)
01345 tmpField = &theSegment->theFields[offset];
01346 else
01347 tmpField = &theSegment->theFields[theSegment->multifieldLength - offset - 1];
01348 theField->type = tmpField->type;
01349 theField->value = tmpField->value;
01350 }
01351 else
01352 {
01353 theField->type = (unsigned short) insSlot->type;
01354 theField->value = insSlot->value;
01355 }
01356 }
01357
01358 #endif
01359