globle void PrintDataObject( 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 #if FUZZY_DEFTEMPLATES case FUZZY_VALUE: #endif PrintAtom(fileid,argPtr->type,argPtr->value); break; case MULTIFIELD: PrintMultifield(fileid,(struct multifield *) argPtr->value, argPtr->begin,argPtr->end,TRUE); break; default: if (PrimitivesArray[argPtr->type] != NULL) { if (PrimitivesArray[argPtr->type]->longPrintFunction) { (*PrimitivesArray[argPtr->type]->longPrintFunction)(fileid,argPtr->value); break; } else if (PrimitivesArray[argPtr->type]->shortPrintFunction) { (*PrimitivesArray[argPtr->type]->shortPrintFunction)(fileid,argPtr->value); break; } } PrintRouter(fileid,"<UnknownPrintType"); PrintLongInteger(fileid,(long int) argPtr->type); PrintRouter(fileid,">"); SetHaltExecution(TRUE); SetEvaluationError(TRUE); break; } }
globle void PrintDataObject( void *theEnv, const char *fileid, DATA_OBJECT_PTR argPtr) { switch(argPtr->type) { case RVOID: case SYMBOL: case STRING: case INTEGER: case FLOAT: case EXTERNAL_ADDRESS: case DATA_OBJECT_ARRAY: // TBD Remove with AddPrimitive 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; } }
static void PrintTemplateSlot( void *theEnv, const char *logicalName, struct templateSlot *slotPtr, struct field *slotValue) { EnvPrintRouter(theEnv,logicalName,"("); EnvPrintRouter(theEnv,logicalName,slotPtr->slotName->contents); /*======================================================*/ /* Print the value of the slot for a single field slot. */ /*======================================================*/ if (slotPtr->multislot == false) { EnvPrintRouter(theEnv,logicalName," "); PrintAtom(theEnv,logicalName,slotValue->type,slotValue->value); } /*==========================================================*/ /* Else print the value of the slot for a multi field slot. */ /*==========================================================*/ else { struct multifield *theSegment; theSegment = (struct multifield *) slotValue->value; if (theSegment->multifieldLength > 0) { EnvPrintRouter(theEnv,logicalName," "); PrintMultifield(theEnv,logicalName,theSegment, 0,(long) theSegment->multifieldLength-1,false); } } /*============================================*/ /* Print the closing parenthesis of the slot. */ /*============================================*/ EnvPrintRouter(theEnv,logicalName,")"); }
globle void PrintFact( char *logicalName, struct fact *factPtr) { struct multifield *theMultifield; /*=========================================*/ /* Print a deftemplate (non-ordered) fact. */ /*=========================================*/ if (factPtr->whichDeftemplate->implied == FALSE) { PrintTemplateFact(logicalName,factPtr); return; } /*==============================*/ /* Print an ordered fact (which */ /* has an implied deftemplate). */ /*==============================*/ PrintRouter(logicalName,"("); PrintRouter(logicalName,factPtr->whichDeftemplate->header.name->contents); theMultifield = (struct multifield *) factPtr->theProposition.theFields[0].value; if (theMultifield->multifieldLength != 0) { PrintRouter(logicalName," "); PrintMultifield(logicalName,theMultifield,0, theMultifield->multifieldLength - 1, FALSE); } PrintRouter(logicalName,")"); }
globle void PrintTemplateFact( char *logicalName, struct fact *theFact) { struct field *sublist; int i; struct deftemplate *theDeftemplate; struct templateSlot *slotPtr; /*==============================*/ /* Initialize some information. */ /*==============================*/ theDeftemplate = theFact->whichDeftemplate; sublist = theFact->theProposition.theFields; /*=============================================*/ /* Print the relation name of the deftemplate. */ /*=============================================*/ PrintRouter(logicalName,"("); PrintRouter(logicalName,theDeftemplate->header.name->contents); #if FUZZY_DEFTEMPLATES if (theDeftemplate->fuzzyTemplate != NULL) /* fuzzy template */ { PrintFuzzyTemplateFact(logicalName, (struct fuzzy_value *)ValueToFuzzyValue((sublist[0].value)) #if CERTAINTY_FACTORS ,theFact->factCF #endif ); return; } #endif if (theDeftemplate->slotList != NULL) PrintRouter(logicalName," "); /*===================================================*/ /* Print each of the field slots of the deftemplate. */ /*===================================================*/ slotPtr = theDeftemplate->slotList; i = 0; while (slotPtr != NULL) { /*===========================================*/ /* Print the closing parenthesis of the slot */ /* and the slot name. */ /*===========================================*/ PrintRouter(logicalName,"("); PrintRouter(logicalName,slotPtr->slotName->contents); /*======================================================*/ /* Print the value of the slot for a single field slot. */ /*======================================================*/ if (slotPtr->multislot == FALSE) { PrintRouter(logicalName," "); #if FUZZY_DEFTEMPLATES /* for a fuzzy value printed during a fact save we need to look for the 'xxx' linguistic value -- if it is xxx then print the set as singletons */ if (saveFactsInProgress && sublist[i].type == FUZZY_VALUE ) { struct fuzzy_value *fv; fv = ValueToFuzzyValue(sublist[i].value); if (strcmp("???", fv->name) == 0) PrintFuzzySet(logicalName, fv); else PrintRouter(logicalName, fv->name); } else #endif PrintAtom(logicalName,sublist[i].type,sublist[i].value); } /*==========================================================*/ /* Else print the value of the slot for a multi field slot. */ /*==========================================================*/ else { struct multifield *theSegment; theSegment = (struct multifield *) sublist[i].value; if (theSegment->multifieldLength > 0) { PrintRouter(logicalName," "); PrintMultifield(logicalName,(struct multifield *) sublist[i].value, 0,theSegment->multifieldLength-1,FALSE); } } /*============================================*/ /* Print the closing parenthesis of the slot. */ /*============================================*/ i++; PrintRouter(logicalName,")"); slotPtr = slotPtr->next; if (slotPtr != NULL) PrintRouter(logicalName," "); } PrintRouter(logicalName,")"); #if CERTAINTY_FACTORS printCF(logicalName,theFact->factCF); #endif #if FUZZY_DEFTEMPLATES /* There may be some fuzzy value slots in the fact -- if so just print out the fuzzy sets for them on next lines ... UNLESS we are doing a fact save operation! */ if (!saveFactsInProgress) for (i=0; i<(unsigned int)theDeftemplate->numberOfSlots; i++) { if (sublist[i].type == FUZZY_VALUE) { PrintRouter(logicalName,"\n\t( "); PrintFuzzySet(logicalName, ValueToFuzzyValue(sublist[i].value)); PrintRouter(logicalName," )"); } } #endif }