📄 tmpltdef.c
字号:
/* EnvFindDeftemplate: Searches for a deftemplate in */
/* the list of deftemplates. Returns a pointer to */
/* the deftemplate if found, otherwise NULL. */
/*****************************************************/
globle void *EnvFindDeftemplate(
void *theEnv,
char *deftemplateName)
{
return(FindNamedConstruct(theEnv,deftemplateName,DeftemplateData(theEnv)->DeftemplateConstruct));
}
/***********************************************************************/
/* EnvGetNextDeftemplate: If passed a NULL pointer, returns the first */
/* deftemplate in the ListOfDeftemplates. Otherwise returns the next */
/* deftemplate following the deftemplate passed as an argument. */
/***********************************************************************/
globle void *EnvGetNextDeftemplate(
void *theEnv,
void *deftemplatePtr)
{
return((void *) GetNextConstructItem(theEnv,(struct constructHeader *) deftemplatePtr,DeftemplateData(theEnv)->DeftemplateModuleIndex));
}
/***********************************************************/
/* EnvIsDeftemplateDeletable: Returns TRUE if a particular */
/* deftemplate can be deleted, otherwise returns FALSE. */
/***********************************************************/
globle intBool EnvIsDeftemplateDeletable(
void *theEnv,
void *vTheDeftemplate)
{
struct deftemplate *theDeftemplate = (struct deftemplate *) vTheDeftemplate;
if (! ConstructsDeletable(theEnv))
{ return FALSE; }
if (theDeftemplate->busyCount > 0) return(FALSE);
if (theDeftemplate->patternNetwork != NULL) return(FALSE);
return(TRUE);
}
/**************************************************************/
/* ReturnDeftemplate: Returns the data structures associated */
/* with a deftemplate construct to the pool of free memory. */
/**************************************************************/
static void ReturnDeftemplate(
void *theEnv,
void *vTheConstruct)
{
#if (MAC_MCW || IBM_MCW) && (RUN_TIME || BLOAD_ONLY)
#pragma unused(theEnv,vTheConstruct)
#endif
#if (! BLOAD_ONLY) && (! RUN_TIME)
struct deftemplate *theConstruct = (struct deftemplate *) vTheConstruct;
struct templateSlot *slotPtr;
if (theConstruct == NULL) return;
/*====================================================================*/
/* If a template is redefined, then we want to save its debug status. */
/*====================================================================*/
#if DEBUGGING_FUNCTIONS
DeftemplateData(theEnv)->DeletedTemplateDebugFlags = 0;
if (theConstruct->watch) BitwiseSet(DeftemplateData(theEnv)->DeletedTemplateDebugFlags,0);
#endif
/*===========================================*/
/* Free storage used by the templates slots. */
/*===========================================*/
slotPtr = theConstruct->slotList;
while (slotPtr != NULL)
{
DecrementSymbolCount(theEnv,slotPtr->slotName);
RemoveHashedExpression(theEnv,slotPtr->defaultList);
slotPtr->defaultList = NULL;
RemoveConstraint(theEnv,slotPtr->constraints);
slotPtr->constraints = NULL;
slotPtr = slotPtr->next;
}
ReturnSlots(theEnv,theConstruct->slotList);
/*==================================*/
/* Free storage used by the header. */
/*==================================*/
DeinstallConstructHeader(theEnv,&theConstruct->header);
rtn_struct(theEnv,deftemplate,theConstruct);
#endif
}
/**************************************************************/
/* DestroyDeftemplate: Returns the data structures associated */
/* with a deftemplate construct to the pool of free memory. */
/**************************************************************/
static void DestroyDeftemplate(
void *theEnv,
void *vTheConstruct)
{
#if (MAC_MCW || IBM_MCW) && (RUN_TIME || BLOAD_ONLY)
#pragma unused(vTheConstruct)
#endif
struct deftemplate *theConstruct = (struct deftemplate *) vTheConstruct;
#if (! BLOAD_ONLY) && (! RUN_TIME)
struct templateSlot *slotPtr, *nextSlot;
#endif
if (theConstruct == NULL) return;
#if (! BLOAD_ONLY) && (! RUN_TIME)
slotPtr = theConstruct->slotList;
while (slotPtr != NULL)
{
nextSlot = slotPtr->next;
rtn_struct(theEnv,templateSlot,slotPtr);
slotPtr = nextSlot;
}
#endif
DestroyFactPatternNetwork(theEnv,theConstruct->patternNetwork);
/*==================================*/
/* Free storage used by the header. */
/*==================================*/
#if (! BLOAD_ONLY) && (! RUN_TIME)
DeinstallConstructHeader(theEnv,&theConstruct->header);
rtn_struct(theEnv,deftemplate,theConstruct);
#endif
}
/***********************************************/
/* ReturnSlots: Returns the slot structures of */
/* a deftemplate to free memory. */
/***********************************************/
globle void ReturnSlots(
void *theEnv,
struct templateSlot *slotPtr)
{
#if (MAC_MCW || IBM_MCW) && (RUN_TIME || BLOAD_ONLY)
#pragma unused(theEnv,slotPtr)
#endif
#if (! BLOAD_ONLY) && (! RUN_TIME)
struct templateSlot *nextSlot;
while (slotPtr != NULL)
{
nextSlot = slotPtr->next;
ReturnExpression(theEnv,slotPtr->defaultList);
RemoveConstraint(theEnv,slotPtr->constraints);
rtn_struct(theEnv,templateSlot,slotPtr);
slotPtr = nextSlot;
}
#endif
}
/*************************************************/
/* DecrementDeftemplateBusyCount: Decrements the */
/* busy count of a deftemplate data structure. */
/*************************************************/
globle void DecrementDeftemplateBusyCount(
void *theEnv,
void *vTheTemplate)
{
struct deftemplate *theTemplate = (struct deftemplate *) vTheTemplate;
if (! ConstructData(theEnv)->ClearInProgress) theTemplate->busyCount--;
}
/*************************************************/
/* IncrementDeftemplateBusyCount: Increments the */
/* busy count of a deftemplate data structure. */
/*************************************************/
#if IBM_TBC
#pragma argsused
#endif
globle void IncrementDeftemplateBusyCount(
void *theEnv,
void *vTheTemplate)
{
struct deftemplate *theTemplate = (struct deftemplate *) vTheTemplate;
#if MAC_MCW || IBM_MCW || MAC_XCD
#pragma unused(theEnv)
#endif
theTemplate->busyCount++;
}
/*******************************************************************/
/* EnvGetNextFactInTemplate: If passed a NULL pointer, returns the */
/* first fact in the template's fact-list. Otherwise returns the */
/* next template fact following the fact passed as an argument. */
/*******************************************************************/
#if IBM_TBC
#pragma argsused
#endif
globle void *EnvGetNextFactInTemplate(
void *theEnv,
void *theTemplate,
void *factPtr)
{
#if MAC_MCW || IBM_MCW || MAC_XCD
#pragma unused(theEnv)
#endif
if (factPtr == NULL)
{ return((void *) ((struct deftemplate *) theTemplate)->factList); }
if (((struct fact *) factPtr)->garbage) return(NULL);
return((void *) ((struct fact *) factPtr)->nextTemplateFact);
}
#endif /* DEFTEMPLATE_CONSTRUCT */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -