📄 prcdrfun.c
字号:
/*===================================================*/ /* Otherwise if the symbol evaluated to a non-FALSE */ /* value, evaluate the "then" portion and return it. */ /*===================================================*/ else if ((returnValue->value != EnvFalseSymbol(theEnv)) || (returnValue->type != SYMBOL)) { theExpr = EvaluationData(theEnv)->CurrentExpression->argList->nextArg; switch (theExpr->type) { case INTEGER: case FLOAT: case SYMBOL: case STRING:#if OBJECT_SYSTEM case INSTANCE_NAME: case INSTANCE_ADDRESS:#endif case EXTERNAL_ADDRESS: returnValue->type = theExpr->type; returnValue->value = theExpr->value; break; default: EvaluateExpression(theEnv,theExpr,returnValue); break; } return; } /*=========================================*/ /* Return FALSE if the condition evaluated */ /* to FALSE and there is no "else" portion */ /* of the if statement. */ /*=========================================*/ returnValue->type = SYMBOL; returnValue->value = EnvFalseSymbol(theEnv); return; }/**************************************//* BindFunction: H/L access routine *//* for the bind function. *//**************************************/globle void BindFunction( void *theEnv, DATA_OBJECT_PTR returnValue) { DATA_OBJECT *theBind, *lastBind; int found = FALSE, unbindVar = FALSE; SYMBOL_HN *variableName = NULL;#if DEFGLOBAL_CONSTRUCT struct defglobal *theGlobal = NULL;#endif /*===============================================*/ /* Determine the name of the variable to be set. */ /*===============================================*/#if DEFGLOBAL_CONSTRUCT if (GetFirstArgument()->type == DEFGLOBAL_PTR) { theGlobal = (struct defglobal *) GetFirstArgument()->value; } else#endif { EvaluateExpression(theEnv,GetFirstArgument(),returnValue); variableName = (SYMBOL_HN *) DOPToPointer(returnValue); } /*===========================================*/ /* Determine the new value for the variable. */ /*===========================================*/ if (GetFirstArgument()->nextArg == NULL) { unbindVar = TRUE; } else if (GetFirstArgument()->nextArg->nextArg == NULL) { EvaluateExpression(theEnv,GetFirstArgument()->nextArg,returnValue); } else { StoreInMultifield(theEnv,returnValue,GetFirstArgument()->nextArg,TRUE); } /*==================================*/ /* Bind a defglobal if appropriate. */ /*==================================*/#if DEFGLOBAL_CONSTRUCT if (theGlobal != NULL) { QSetDefglobalValue(theEnv,theGlobal,returnValue,unbindVar); return; }#endif /*===============================================*/ /* Search for the variable in the list of binds. */ /*===============================================*/ theBind = ProcedureFunctionData(theEnv)->BindList; lastBind = NULL; while ((theBind != NULL) && (found == FALSE)) { if (theBind->supplementalInfo == (void *) variableName) { found = TRUE; } else { lastBind = theBind; theBind = theBind->next; } } /*========================================================*/ /* If variable was not in the list of binds, then add it. */ /* Make sure that this operation preserves the bind list */ /* as a stack. */ /*========================================================*/ if (found == FALSE) { if (unbindVar == FALSE) { theBind = get_struct(theEnv,dataObject); theBind->supplementalInfo = (void *) variableName; theBind->next = NULL; if (lastBind == NULL) { ProcedureFunctionData(theEnv)->BindList = theBind; } else { lastBind->next = theBind; } } else { returnValue->type = SYMBOL; returnValue->value = EnvFalseSymbol(theEnv); return; } } else { ValueDeinstall(theEnv,theBind); } /*================================*/ /* Set the value of the variable. */ /*================================*/ if (unbindVar == FALSE) { theBind->type = returnValue->type; theBind->value = returnValue->value; theBind->begin = returnValue->begin; theBind->end = returnValue->end; ValueInstall(theEnv,returnValue); } else { if (lastBind == NULL) ProcedureFunctionData(theEnv)->BindList = theBind->next; else lastBind->next = theBind->next; rtn_struct(theEnv,dataObject,theBind); returnValue->type = SYMBOL; returnValue->value = EnvFalseSymbol(theEnv); } }/*******************************************//* GetBoundVariable: Searches the BindList *//* for a specified variable. *//*******************************************/globle intBool GetBoundVariable( void *theEnv, DATA_OBJECT_PTR vPtr, SYMBOL_HN *varName) { DATA_OBJECT_PTR bindPtr; for (bindPtr = ProcedureFunctionData(theEnv)->BindList; bindPtr != NULL; bindPtr = bindPtr->next) { if (bindPtr->supplementalInfo == (void *) varName) { vPtr->type = bindPtr->type; vPtr->value = bindPtr->value; vPtr->begin = bindPtr->begin; vPtr->end = bindPtr->end; return(TRUE); } } return(FALSE); }/*************************************************//* FlushBindList: Removes all variables from the *//* list of currently bound local variables. *//*************************************************/globle void FlushBindList( void *theEnv) { ReturnValues(theEnv,ProcedureFunctionData(theEnv)->BindList); ProcedureFunctionData(theEnv)->BindList = NULL; }/***************************************//* PrognFunction: H/L access routine *//* for the progn function. *//***************************************/globle void PrognFunction( void *theEnv, DATA_OBJECT_PTR returnValue) { struct expr *argPtr; argPtr = EvaluationData(theEnv)->CurrentExpression->argList; if (argPtr == NULL) { returnValue->type = SYMBOL; returnValue->value = EnvFalseSymbol(theEnv); return; } while ((argPtr != NULL) && (GetHaltExecution(theEnv) != TRUE)) { EvaluateExpression(theEnv,argPtr,returnValue); if ((ProcedureFunctionData(theEnv)->BreakFlag == TRUE) || (ProcedureFunctionData(theEnv)->ReturnFlag == TRUE)) break; argPtr = argPtr->nextArg; } if (GetHaltExecution(theEnv) == TRUE) { returnValue->type = SYMBOL; returnValue->value = EnvFalseSymbol(theEnv); return; } return; }/*****************************************************************//* ReturnFunction: H/L access routine for the return function. *//*****************************************************************/globle void ReturnFunction( void *theEnv, DATA_OBJECT_PTR result) { if (EnvRtnArgCount(theEnv) == 0) { result->type = RVOID; result->value = EnvFalseSymbol(theEnv); } else EnvRtnUnknown(theEnv,1,result); ProcedureFunctionData(theEnv)->ReturnFlag = TRUE; }/***************************************************************//* BreakFunction: H/L access routine for the break function. *//***************************************************************/globle void BreakFunction( void *theEnv) { ProcedureFunctionData(theEnv)->BreakFlag = TRUE; }/*****************************************************************//* SwitchFunction: H/L access routine for the switch function. *//*****************************************************************/globle void SwitchFunction( void *theEnv, DATA_OBJECT_PTR result) { DATA_OBJECT switch_val,case_val; EXPRESSION *theExp; result->type = SYMBOL; result->value = EnvFalseSymbol(theEnv); /* ========================== Get the value to switch on ========================== */ EvaluateExpression(theEnv,GetFirstArgument(),&switch_val); if (EvaluationData(theEnv)->EvaluationError) return; for (theExp = GetFirstArgument()->nextArg ; theExp != NULL ; theExp = theExp->nextArg->nextArg) { /* ================================================= RVOID is the default case (if any) for the switch ================================================= */ if (theExp->type == RVOID) { EvaluateExpression(theEnv,theExp->nextArg,result); return; } /* ==================================================== If the case matches, evaluate the actions and return ==================================================== */ EvaluateExpression(theEnv,theExp,&case_val); if (EvaluationData(theEnv)->EvaluationError) return; if (switch_val.type == case_val.type) { if ((case_val.type == MULTIFIELD) ? MultifieldDOsEqual(&switch_val,&case_val) : (switch_val.value == case_val.value)) { EvaluateExpression(theEnv,theExp->nextArg,result); return; } } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -