/********************************************************************** NAME : WatchMethod DESCRIPTION : Prints out a trace of the beginning or end of the execution of a generic function method INPUTS : A string to indicate beginning or end of execution RETURNS : Nothing useful SIDE EFFECTS : None NOTES : Uses the globals CurrentGeneric, CurrentMethod, ProcParamArraySize and ProcParamArray for other trace info **********************************************************************/ static void WatchMethod( Environment *theEnv, const char *tstring) { if (ConstructData(theEnv)->ClearReadyInProgress || ConstructData(theEnv)->ClearInProgress) { return; } WriteString(theEnv,STDOUT,"MTH "); WriteString(theEnv,STDOUT,tstring); WriteString(theEnv,STDOUT," "); if (DefgenericData(theEnv)->CurrentGeneric->header.whichModule->theModule != GetCurrentModule(theEnv)) { WriteString(theEnv,STDOUT,DefgenericModule(DefgenericData(theEnv)->CurrentGeneric)); WriteString(theEnv,STDOUT,"::"); } WriteString(theEnv,STDOUT,DefgenericData(theEnv)->CurrentGeneric->header.name->contents); WriteString(theEnv,STDOUT,":#"); if (DefgenericData(theEnv)->CurrentMethod->system) WriteString(theEnv,STDOUT,"SYS"); PrintUnsignedInteger(theEnv,STDOUT,DefgenericData(theEnv)->CurrentMethod->index); WriteString(theEnv,STDOUT," "); WriteString(theEnv,STDOUT," ED:"); WriteInteger(theEnv,STDOUT,EvaluationData(theEnv)->CurrentEvaluationDepth); PrintProcParamArray(theEnv,STDOUT); }
bool RemoveConstruct( Environment *theEnv, const char *name) { Construct *currentPtr, *lastPtr = NULL; for (currentPtr = ConstructData(theEnv)->ListOfConstructs; currentPtr != NULL; currentPtr = currentPtr->next) { if (strcmp(name,currentPtr->constructName) == 0) { if (lastPtr == NULL) { ConstructData(theEnv)->ListOfConstructs = currentPtr->next; } else { lastPtr->next = currentPtr->next; } rtn_struct(theEnv,construct,currentPtr); return true; } lastPtr = currentPtr; } return false; }
/*************************************************** NAME : ReplaceClassNameWithReference DESCRIPTION : In parsing a make instance call, this function replaces a constant class name with an actual pointer to the class INPUTS : The expression RETURNS : TRUE if all OK, FALSE if class cannot be found SIDE EFFECTS : The expression type and value are modified if class is found NOTES : Searches current nd imported modules for reference CHANGES : It's now possible to create an instance of a class that's not in scope if the module name is specified. ***************************************************/ static intBool ReplaceClassNameWithReference( void *theEnv, EXPRESSION *theExp) { const char *theClassName; void *theDefclass; if (theExp->type == SYMBOL) { theClassName = ValueToString(theExp->value); //theDefclass = (void *) LookupDefclassInScope(theEnv,theClassName); theDefclass = (void *) LookupDefclassByMdlOrScope(theEnv,theClassName); // Module or scope is now allowed if (theDefclass == NULL) { CantFindItemErrorMessage(theEnv,"class",theClassName); return(FALSE); } if (EnvClassAbstractP(theEnv,theDefclass)) { PrintErrorID(theEnv,"INSMNGR",3,FALSE); EnvPrintRouter(theEnv,WERROR,"Cannot create instances of abstract class "); EnvPrintRouter(theEnv,WERROR,theClassName); EnvPrintRouter(theEnv,WERROR,".\n"); return(FALSE); } theExp->type = DEFCLASS_PTR; theExp->value = theDefclass; #if (! RUN_TIME) && (! BLOAD_ONLY) if (! ConstructData(theEnv)->ParsingConstruct) { ConstructData(theEnv)->DanglingConstructs++; } #endif } return(TRUE); }
globle BOOLEAN AddSaveFunction( void *theEnv, char *name, void (*functionPtr)(void *,void *,char *), int priority) { #if (MAC_MCW || IBM_MCW) && (RUN_TIME || BLOAD_ONLY) #pragma unused(name) #pragma unused(functionPtr) #pragma unused(priority) #endif #if (! RUN_TIME) && (! BLOAD_ONLY) ConstructData(theEnv)->ListOfSaveFunctions = AddFunctionToCallList(theEnv,name,priority, (void (*)(void *)) functionPtr, ConstructData(theEnv)->ListOfSaveFunctions,TRUE); #else #if MAC_MCW || IBM_MCW #pragma unused(theEnv) #endif #endif return(1); }
globle int RemoveConstruct( void *theEnv, const char *name) { struct construct *currentPtr, *lastPtr = NULL; for (currentPtr = ConstructData(theEnv)->ListOfConstructs; currentPtr != NULL; currentPtr = currentPtr->next) { if (strcmp(name,currentPtr->constructName) == 0) { if (lastPtr == NULL) { ConstructData(theEnv)->ListOfConstructs = currentPtr->next; } else { lastPtr->next = currentPtr->next; } rtn_struct(theEnv,construct,currentPtr); return(TRUE); } lastPtr = currentPtr; } return(FALSE); }
globle intBool AddSaveFunction( void *theEnv, EXEC_STATUS, char *name, void (*functionPtr)(void *,EXEC_STATUS,void *,char *), int priority) { #if (MAC_MCW || WIN_MCW) && (RUN_TIME || BLOAD_ONLY) #pragma unused(name) #pragma unused(functionPtr) #pragma unused(priority) #endif #if (! RUN_TIME) && (! BLOAD_ONLY) ConstructData(theEnv,execStatus)->ListOfSaveFunctions = AddFunctionToCallList(theEnv,execStatus,name,priority, (void (*)(void *,EXEC_STATUS)) functionPtr, ConstructData(theEnv,execStatus)->ListOfSaveFunctions,TRUE); #else #if MAC_MCW || WIN_MCW || MAC_XCD #pragma unused(theEnv,execStatus) #endif #endif return(1); }
globle int (*SetBeforeResetFunction(void *theEnv, int (*theFunction)(void *)))(void *) { int (*tempFunction)(void *); tempFunction = ConstructData(theEnv)->BeforeResetFunction; ConstructData(theEnv)->BeforeResetFunction = theFunction; return(tempFunction); }
BeforeResetFunction *SetBeforeResetFunction( Environment *theEnv, BeforeResetFunction *theFunction) { BeforeResetFunction *tempFunction; tempFunction = ConstructData(theEnv)->BeforeResetCallback; ConstructData(theEnv)->BeforeResetCallback = theFunction; return tempFunction; }
globle void (*EnvSetParserErrorCallback(void *theEnv, void (*functionPtr)(void *,const char *,const char *,const char *,long))) (void *,const char *,const char *,const char*,long) { void (*tmpPtr)(void *,const char *,const char *,const char *,long); tmpPtr = ConstructData(theEnv)->ParserErrorCallback; ConstructData(theEnv)->ParserErrorCallback = functionPtr; return(tmpPtr); }
globle int ParseConstruct( void *theEnv, char *name, char *logicalName) { struct construct *currentPtr; int rv, ov; /*=================================*/ /* Look for a valid construct name */ /* (e.g. defrule, deffacts). */ /*=================================*/ currentPtr = FindConstruct(theEnv,name); if (currentPtr == NULL) return(-1); /*==================================*/ /* Prepare the parsing environment. */ /*==================================*/ ov = GetHaltExecution(theEnv); SetEvaluationError(theEnv,FALSE); SetHaltExecution(theEnv,FALSE); ClearParsedBindNames(theEnv); PushRtnBrkContexts(theEnv); ExpressionData(theEnv)->ReturnContext = FALSE; ExpressionData(theEnv)->BreakContext = FALSE; EvaluationData(theEnv)->CurrentEvaluationDepth++; /*=======================================*/ /* Call the construct's parsing routine. */ /*=======================================*/ ConstructData(theEnv)->ParsingConstruct = TRUE; rv = (*currentPtr->parseFunction)(theEnv,logicalName); ConstructData(theEnv)->ParsingConstruct = FALSE; /*===============================*/ /* Restore environment settings. */ /*===============================*/ EvaluationData(theEnv)->CurrentEvaluationDepth--; PopRtnBrkContexts(theEnv); ClearParsedBindNames(theEnv); SetPPBufferStatus(theEnv,OFF); SetHaltExecution(theEnv,ov); /*==============================*/ /* Return the status of parsing */ /* the construct. */ /*==============================*/ return(rv); }
bool EnvRemoveResetFunction( void *theEnv, const char *name) { bool found; ConstructData(theEnv)->ListOfResetFunctions = RemoveFunctionFromCallList(theEnv,name,ConstructData(theEnv)->ListOfResetFunctions,&found); return found; }
bool RemoveResetFunction( Environment *theEnv, const char *name) { bool found; ConstructData(theEnv)->ListOfResetFunctions = RemoveVoidFunctionFromCallList(theEnv,name,ConstructData(theEnv)->ListOfResetFunctions,&found); return found; }
globle int (*SetBeforeResetFunction( void *theEnv, EXEC_STATUS, int (*theFunction)(void *,EXEC_STATUS)))(void *,EXEC_STATUS) { int (*tempFunction)(void *,EXEC_STATUS); tempFunction = ConstructData(theEnv,execStatus)->BeforeResetFunction; ConstructData(theEnv,execStatus)->BeforeResetFunction = theFunction; return(tempFunction); }
globle intBool EnvAddResetFunction( void *theEnv, const char *name, void (*functionPtr)(void *), int priority) { ConstructData(theEnv)->ListOfResetFunctions = AddFunctionToCallList(theEnv,name,priority, functionPtr, ConstructData(theEnv)->ListOfResetFunctions,TRUE); return(TRUE); }
globle intBool EnvAddResetFunction( void *theEnv, EXEC_STATUS, char *name, void (*functionPtr)(void *,EXEC_STATUS), int priority) { ConstructData(theEnv,execStatus)->ListOfResetFunctions = AddFunctionToCallList(theEnv,execStatus,name,priority, functionPtr, ConstructData(theEnv,execStatus)->ListOfResetFunctions,TRUE); return(TRUE); }
globle BOOLEAN EnvAddClearFunction( void *theEnv, char *name, void (*functionPtr)(void *), int priority) { ConstructData(theEnv)->ListOfClearFunctions = AddFunctionToCallList(theEnv,name,priority, (void (*)(void *)) functionPtr, ConstructData(theEnv)->ListOfClearFunctions,TRUE); return(1); }
ParserErrorFunction *SetParserErrorCallback( Environment *theEnv, ParserErrorFunction *functionPtr, void *context) { ParserErrorFunction *tmpPtr; tmpPtr = ConstructData(theEnv)->ParserErrorCallback; ConstructData(theEnv)->ParserErrorCallback = functionPtr; ConstructData(theEnv)->ParserErrorContext = context; return tmpPtr; }
bool EnvAddClearFunction( void *theEnv, const char *name, void (*functionPtr)(void *), int priority) { ConstructData(theEnv)->ListOfClearFunctions = AddFunctionToCallList(theEnv,name,priority, (void (*)(void *)) functionPtr, ConstructData(theEnv)->ListOfClearFunctions); return(true); }
globle intBool AddClearReadyFunction( void *theEnv, const char *name, int (*functionPtr)(void *), int priority) { ConstructData(theEnv)->ListOfClearReadyFunctions = AddFunctionToCallList(theEnv,name,priority, (void (*)(void *)) functionPtr, ConstructData(theEnv)->ListOfClearReadyFunctions,TRUE); return(1); }
bool AddClearFunction( Environment *theEnv, const char *name, VoidCallFunction *functionPtr, int priority, void *context) { ConstructData(theEnv)->ListOfClearFunctions = AddVoidFunctionToCallList(theEnv,name,priority,functionPtr, ConstructData(theEnv)->ListOfClearFunctions,context); return true; }
bool EnvRemoveClearFunction( void *theEnv, const char *name) { bool found; ConstructData(theEnv)->ListOfClearFunctions = RemoveFunctionFromCallList(theEnv,name,ConstructData(theEnv)->ListOfClearFunctions,&found); if (found) return(true); return(false); }
globle intBool AddClearReadyFunction( void *theEnv, EXEC_STATUS, char *name, int (*functionPtr)(void *,EXEC_STATUS), int priority) { ConstructData(theEnv,execStatus)->ListOfClearReadyFunctions = AddFunctionToCallList(theEnv,execStatus,name,priority, (void (*)(void *,EXEC_STATUS)) functionPtr, ConstructData(theEnv,execStatus)->ListOfClearReadyFunctions,TRUE); return(1); }
globle intBool AddResetFunction( char *name, void (*functionPtr)(void), int priority) { void *theEnv = GetCurrentEnvironment(); EXEC_STATUS = GetCurrentExecutionStatus(); ConstructData(theEnv,execStatus)->ListOfResetFunctions = AddFunctionToCallList(theEnv,execStatus,name,priority,(void (*)(void *,EXEC_STATUS)) functionPtr, ConstructData(theEnv,execStatus)->ListOfResetFunctions,FALSE); return(TRUE); }
bool RemoveClearFunction( Environment *theEnv, const char *name) { bool found; ConstructData(theEnv)->ListOfClearFunctions = RemoveVoidFunctionFromCallList(theEnv,name,ConstructData(theEnv)->ListOfClearFunctions,&found); if (found) return true; return false; }
globle BOOLEAN EnvRemoveResetFunction( void *theEnv, char *name) { int found; ConstructData(theEnv)->ListOfResetFunctions = RemoveFunctionFromCallList(theEnv,name,ConstructData(theEnv)->ListOfResetFunctions,&found); if (found) return(TRUE); return(FALSE); }
globle intBool EnvRemoveClearFunction( void *theEnv, const char *name) { int found; ConstructData(theEnv)->ListOfClearFunctions = RemoveFunctionFromCallList(theEnv,name,ConstructData(theEnv)->ListOfClearFunctions,&found); if (found) return(TRUE); return(FALSE); }
globle intBool AddResetFunction( const char *name, void (*functionPtr)(void), int priority) { void *theEnv; theEnv = GetCurrentEnvironment(); ConstructData(theEnv)->ListOfResetFunctions = AddFunctionToCallList(theEnv,name,priority,(void (*)(void *)) functionPtr, ConstructData(theEnv)->ListOfResetFunctions,FALSE); return(TRUE); }
globle intBool EnvRemoveClearFunction( void *theEnv, EXEC_STATUS, char *name) { int found; ConstructData(theEnv,execStatus)->ListOfClearFunctions = RemoveFunctionFromCallList(theEnv,execStatus,name,ConstructData(theEnv,execStatus)->ListOfClearFunctions,&found); if (found) return(TRUE); return(FALSE); }
globle BOOLEAN AddClearFunction( char *name, void (*functionPtr)(void), int priority) { void *theEnv; theEnv = GetCurrentEnvironment(); ConstructData(theEnv)->ListOfClearFunctions = AddFunctionToCallList(theEnv,name,priority, (void (*)(void *)) functionPtr, ConstructData(theEnv)->ListOfClearFunctions,FALSE); return(1); }
/*************************************************** NAME : DecrementDefclassBusyCount DESCRIPTION : Decrements use count of defclass INPUTS : The class RETURNS : Nothing useful SIDE EFFECTS : Busy count decremented NOTES : Since use counts are ignored on a clear and defclasses might be deleted already anyway, this is a no-op on a clear ***************************************************/ globle void DecrementDefclassBusyCount( void *theEnv, void *theDefclass) { if (! ConstructData(theEnv)->ClearInProgress) ((DEFCLASS *) theDefclass)->busy--; }