📄 extnfunc.c
字号:
globle char *GetArgumentTypeName(theRestriction) int theRestriction; { switch ((char) theRestriction) { case 'a': return("external address"); case 'e': return("instance address, instance name, or symbol"); case 'd': case 'f': return("float"); case 'g': return("integer, float, or symbol"); case 'h': return("instance address, instance name, fact address, integer, or symbol"); case 'j': return("symbol, string, or instance name"); case 'k': return("symbol or string"); case 'i': case 'l': return("integer"); case 'm': return("multifield"); case 'n': return("integer or float"); case 'o': return("instance name"); case 'p': return("instance name or symbol"); case 'q': return("multifield, symbol, or string"); case 's': return("string"); case 'w': return("symbol"); case 'x': return("instance address"); case 'y': return("fact-address"); case 'z': return("fact-address, integer, or symbol"); case 'u': return("non-void return value"); } return("unknown argument type"); } /***************************************************//* GetNthRestriction: Returns the restriction type *//* for the nth parameter of a function. *//***************************************************/globle int GetNthRestriction(theFunction,position) struct FunctionDefinition *theFunction; int position; { int defaultRestriction = (int) 'u', theLength; int i = 2; /*===========================================================*/ /* If no restrictions at all are specified for the function, */ /* then return 'u' to indicate that any value is suitable as */ /* an argument to the function. */ /*===========================================================*/ if (theFunction == NULL) return(defaultRestriction); if (theFunction->restrictions == NULL) return(defaultRestriction); /*===========================================================*/ /* If no type restrictions are specified for the function, */ /* then return 'u' to indicate that any value is suitable as */ /* an argument to the function. */ /*===========================================================*/ theLength = strlen(theFunction->restrictions); if (theLength < 3) return(defaultRestriction); /*==============================================*/ /* Determine the functions default restriction. */ /*==============================================*/ defaultRestriction = (int) theFunction->restrictions[i]; if (defaultRestriction == '*') defaultRestriction = (int) 'u'; /*=======================================================*/ /* If the requested position does not have a restriction */ /* specified, then return the default restriction. */ /*=======================================================*/ if (theLength < (position + 3)) return(defaultRestriction); /*=========================================================*/ /* Return the restriction specified for the nth parameter. */ /*=========================================================*/ return((int) theFunction->restrictions[position + 2]); } /*************************************************//* GetFunctionList: Returns the ListOfFunctions. *//*************************************************/globle struct FunctionDefinition *GetFunctionList() { return(ListOfFunctions); }/**************************************************************//* InstallFunctionList: Sets the ListOfFunctions and adds all *//* the function entries to the FunctionHashTable. *//**************************************************************/globle VOID InstallFunctionList(value) struct FunctionDefinition *value; { int i; struct FunctionHash *fhPtr, *nextPtr; if (FunctionHashtable != NULL) { for (i = 0; i < SIZE_FUNCTION_HASH; i++) { fhPtr = FunctionHashtable[i]; while (fhPtr != NULL) { nextPtr = fhPtr->next; rtn_struct(FunctionHash,fhPtr); fhPtr = nextPtr; } FunctionHashtable[i] = NULL; } } ListOfFunctions = value; while (value != NULL) { AddHashFunction(value); value = value->next; } }/********************************************************//* FindFunction: Returns a pointer to the corresponding *//* FunctionDefinition structure if a function name is *//* in the function list, otherwise returns NULL. *//********************************************************/globle struct FunctionDefinition *FindFunction(functionName) char *functionName; { struct FunctionHash *fhPtr; int hashValue; SYMBOL_HN *findValue; hashValue = HashSymbol(functionName,SIZE_FUNCTION_HASH); findValue = (SYMBOL_HN *) FindSymbol(functionName); for (fhPtr = FunctionHashtable[hashValue]; fhPtr != NULL; fhPtr = fhPtr->next) { if (fhPtr->fdPtr->callFunctionName == findValue) { return(fhPtr->fdPtr); } } return(NULL); }/*********************************************************//* InitializeFunctionHashTable: Purpose is to initialize *//* the function hash table to NULL. *//*********************************************************/static VOID InitializeFunctionHashTable() { int i; FunctionHashtable = (struct FunctionHash **) gm2((int) sizeof (struct FunctionHash *) * SIZE_FUNCTION_HASH); for (i = 0; i < SIZE_FUNCTION_HASH; i++) FunctionHashtable[i] = NULL; }/****************************************************************//* AddHashFunction: Adds a function to the function hash table. *//****************************************************************/static VOID AddHashFunction(fdPtr) struct FunctionDefinition *fdPtr; { struct FunctionHash *newhash, *temp; int hashValue; if (FunctionHashtable == NULL) InitializeFunctionHashTable(); newhash = get_struct(FunctionHash); newhash->fdPtr = fdPtr; hashValue = HashSymbol(fdPtr->callFunctionName->contents,SIZE_FUNCTION_HASH); temp = FunctionHashtable[hashValue]; FunctionHashtable[hashValue] = newhash; newhash->next = temp; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -