📄 cstrccom.c
字号:
for (theConstruct = theModuleItem->firstItem;
theConstruct != NULL;
theConstruct = theConstruct->next)
{
if (interruptable)
{
if (GetHaltExecution(theEnv) == TRUE)
{
RestoreCurrentModule(theEnv);
return(-1L);
}
}
(*actionFunction)(theEnv,theConstruct,userBuffer);
}
}
/*=============================*/
/* Restore the current module. */
/*=============================*/
RestoreCurrentModule(theEnv);
/*=========================================*/
/* Return the number of modules traversed. */
/*=========================================*/
return(moduleCount);
}
/******************************************************/
/* DoForAllConstructsInModule: Executes an action for */
/* all constructs of a specified type in a module. */
/******************************************************/
globle void DoForAllConstructsInModule(
void *theEnv,
void *theModule,
void (*actionFunction)(void *,struct constructHeader *,void *),
int moduleItemIndex,
int interruptable,
void *userBuffer)
{
struct constructHeader *theConstruct;
struct defmoduleItemHeader *theModuleItem;
/*==========================*/
/* Save the current module. */
/*==========================*/
SaveCurrentModule(theEnv);
/*=============================*/
/* Set the current module to */
/* the module we're examining. */
/*=============================*/
EnvSetCurrentModule(theEnv,(void *) theModule);
/*================================================*/
/* Perform the action for each of the constructs. */
/*================================================*/
theModuleItem = (struct defmoduleItemHeader *)
GetModuleItem(theEnv,(struct defmodule *) theModule,moduleItemIndex);
for (theConstruct = theModuleItem->firstItem;
theConstruct != NULL;
theConstruct = theConstruct->next)
{
if (interruptable)
{
if (GetHaltExecution(theEnv) == TRUE)
{
RestoreCurrentModule(theEnv);
return;
}
}
(*actionFunction)(theEnv,theConstruct,userBuffer);
}
/*=============================*/
/* Restore the current module. */
/*=============================*/
RestoreCurrentModule(theEnv);
}
/*****************************************************/
/* InitializeConstructHeader: Initializes construct */
/* header info, including to which module item the */
/* new construct belongs */
/*****************************************************/
globle void InitializeConstructHeader(
void *theEnv,
char *constructType,
struct constructHeader *theConstruct,
SYMBOL_HN *theConstructName)
{
struct moduleItem *theModuleItem;
struct defmoduleItemHeader *theItemHeader;
theModuleItem = FindModuleItem(theEnv,constructType);
theItemHeader = (struct defmoduleItemHeader *)
GetModuleItem(theEnv,NULL,theModuleItem->moduleIndex);
theConstruct->whichModule = theItemHeader;
theConstruct->name = theConstructName;
theConstruct->ppForm = NULL;
theConstruct->bsaveID = 0L;
theConstruct->next = NULL;
theConstruct->usrData = NULL;
}
/*************************************************/
/* SetConstructPPForm: Sets a construct's pretty */
/* print form and deletes the old one. */
/*************************************************/
globle void SetConstructPPForm(
void *theEnv,
struct constructHeader *theConstruct,
char *ppForm)
{
if (theConstruct->ppForm != NULL)
{
rm(theEnv,(void *) theConstruct->ppForm,
((strlen(theConstruct->ppForm) + 1) * sizeof(char)));
}
theConstruct->ppForm = ppForm;
}
#if DEBUGGING_FUNCTIONS
/******************************************************/
/* ConstructPrintWatchAccess: Provides an interface */
/* to the list-watch-items function for a construct */
/******************************************************/
globle unsigned ConstructPrintWatchAccess(
void *theEnv,
struct construct *constructClass,
char *logName,
EXPRESSION *argExprs,
unsigned (*getWatchFunc)(void *,void *),
void (*setWatchFunc)(void *,unsigned,void *))
{
return(ConstructWatchSupport(theEnv,constructClass,"list-watch-items",logName,argExprs,
FALSE,FALSE,getWatchFunc,setWatchFunc));
}
/**************************************************/
/* ConstructSetWatchAccess: Provides an interface */
/* to the watch function for a construct */
/**************************************************/
globle unsigned ConstructSetWatchAccess(
void *theEnv,
struct construct *constructClass,
unsigned newState,
EXPRESSION *argExprs,
unsigned (*getWatchFunc)(void *,void *),
void (*setWatchFunc)(void *,unsigned,void *))
{
return(ConstructWatchSupport(theEnv,constructClass,"watch",WERROR,argExprs,
TRUE,newState,getWatchFunc,setWatchFunc));
}
/******************************************************/
/* ConstructWatchSupport: Generic construct interface */
/* into watch and list-watch-items. */
/******************************************************/
static unsigned ConstructWatchSupport(
void *theEnv,
struct construct *constructClass,
char *funcName,
char *logName,
EXPRESSION *argExprs,
intBool setFlag,
unsigned newState,
unsigned (*getWatchFunc)(void *,void *),
void (*setWatchFunc)(void *,unsigned,void *))
{
struct defmodule *theModule;
void *theConstruct;
DATA_OBJECT constructName;
int argIndex = 2;
/*========================================*/
/* If no constructs are specified, then */
/* show/set the trace for all constructs. */
/*========================================*/
if (argExprs == NULL)
{
/*==========================*/
/* Save the current module. */
/*==========================*/
SaveCurrentModule(theEnv);
/*===========================*/
/* Loop through each module. */
/*===========================*/
for (theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,NULL);
theModule != NULL;
theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,(void *) theModule))
{
/*============================*/
/* Set the current module to */
/* the module being examined. */
/*============================*/
EnvSetCurrentModule(theEnv,(void *) theModule);
/*====================================================*/
/* If we're displaying the names of constructs with */
/* watch flags enabled, then preface each module */
/* listing of constructs with the name of the module. */
/*====================================================*/
if (setFlag == FALSE)
{
EnvPrintRouter(theEnv,logName,EnvGetDefmoduleName(theEnv,(void *) theModule));
EnvPrintRouter(theEnv,logName,":\n");
}
/*============================================*/
/* Loop through each construct in the module. */
/*============================================*/
for (theConstruct = (*constructClass->getNextItemFunction)(theEnv,NULL);
theConstruct != NULL;
theConstruct = (*constructClass->getNextItemFunction)(theEnv,theConstruct))
{
/*=============================================*/
/* Either set the watch flag for the construct */
/* or display its current state. */
/*=============================================*/
if (setFlag)
{ (*setWatchFunc)(theEnv,newState,theConstruct); }
else
{
EnvPrintRouter(theEnv,logName," ");
ConstructPrintWatch(theEnv,logName,constructClass,theConstruct,getWatchFunc);
}
}
}
/*=============================*/
/* Restore the current module. */
/*=============================*/
RestoreCurrentModule(theEnv);
/*====================================*/
/* Return TRUE to indicate successful */
/* completion of the command. */
/*====================================*/
return(TRUE);
}
/*==================================================*/
/* Show/set the trace for each specified construct. */
/*==================================================*/
while (argExprs != NULL)
{
/*==========================================*/
/* Evaluate the argument that should be a */
/* construct name. Return FALSE is an error */
/* occurs when evaluating the argument. */
/*==========================================*/
if (EvaluateExpression(theEnv,argExprs,&constructName))
{ return(FALSE); }
/*================================================*/
/* Check to see that it's a valid construct name. */
/*================================================*/
if ((constructName.type != SYMBOL) ? TRUE :
((theConstruct = LookupConstruct(theEnv,constructClass,
DOToString(constructName),TRUE)) == NULL))
{
ExpectedTypeError1(theEnv,funcName,argIndex,constructClass->constructName);
return(FALSE);
}
/*=============================================*/
/* Either set the watch flag for the construct */
/* or display its current state. */
/*=============================================*/
if (setFlag)
{ (*setWatchFunc)(theEnv,newState,theConstruct); }
else
{ ConstructPrintWatch(theEnv,logName,constructClass,theConstruct,getWatchFunc); }
/*===============================*/
/* Move on to the next argument. */
/*===============================*/
argIndex++;
argExprs = GetNextArgument(argExprs);
}
/*====================================*/
/* Return TRUE to indicate successful */
/* completion of the command. */
/*====================================*/
return(TRUE);
}
/*************************************************/
/* ConstructPrintWatch: Displays the trace value */
/* of a construct for list-watch-items */
/*************************************************/
static void ConstructPrintWatch(
void *theEnv,
char *logName,
struct construct *constructClass,
void *theConstruct,
unsigned (*getWatchFunc)(void *,void *))
{
EnvPrintRouter(theEnv,logName,ValueToString((*constructClass->getConstructNameFunction)((struct constructHeader *) theConstruct)));
EnvPrintRouter(theEnv,logName,(char *) ((*getWatchFunc)(theEnv,theConstruct) ? " = on\n" : " = off\n"));
}
#endif /* DEBUGGING_FUNCTIONS */
/*****************************************************/
/* LookupConstruct: Finds a construct in the current */
/* or imported modules. If specified, will also */
/* look for construct in a non-imported module. */
/*****************************************************/
globle void *LookupConstruct(
void *theEnv,
struct construct *constructClass,
char *constructName,
intBool moduleNameAllowed)
{
void *theConstruct;
char *constructType;
int moduleCount;
/*============================================*/
/* Look for the specified construct in the */
/* current module or in any imported modules. */
/*============================================*/
constructType = constructClass->constructName;
theConstruct = FindImportedConstruct(theEnv,constructType,NULL,constructName,
&moduleCount,TRUE,NULL);
/*===========================================*/
/* Return NULL if the reference is ambiguous */
/* (it was found in more than one module). */
/*===========================================*/
if (theConstruct != NULL)
{
if (moduleCount > 1)
{
AmbiguousReferenceErrorMessage(theEnv,constructType,constructName);
return(NULL);
}
return(theConstruct);
}
/*=============================================*/
/* If specified, check to see if the construct */
/* is in a non-imported module. */
/*=============================================*/
if (moduleNameAllowed && FindModuleSeparator(constructName))
{ theConstruct = (*constructClass->findFunction)(theEnv,constructName); }
/*====================================*/
/* Return a pointer to the construct. */
/*====================================*/
return(theConstruct);
}
/***********************************************************/
/* ConstructsDeletable: Returns a boolean value indicating */
/* whether constructs in general can be deleted. */
/***********************************************************/
#if IBM_TBC
#pragma argsused
#endif
globle intBool ConstructsDeletable(
void *theEnv)
{
#if BLOAD_ONLY || RUN_TIME || ((! BLOAD) && (! BLOAD_AND_BSAVE))
#if MAC_MCW || IBM_MCW || MAC_XCD
#pragma unused(theEnv)
#endif
#endif
#if BLOAD_ONLY || RUN_TIME
return(FALSE);
#elif BLOAD || BLOAD_AND_BSAVE
if (Bloaded(theEnv))
return(FALSE);
return TRUE;
#else
return(TRUE);
#endif
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -