/// <summary> /// Check the match of parameters between the functionCall and the attached function code. /// the matching of the type of each parameter will be checked later at the execution stage. /// </summary> /// <param name="functionCallUsed"></param> /// <param name="functionToCall"></param> /// <returns></returns> private bool CheckParamsCountMatching(ExprFunctionCallUsed functionCallUsed, FunctionToCallMapper functionToCall) { // the function code has any parameter if (functionToCall.Param1Type == DataType.NotDefined) { if (functionCallUsed.ParameterCount != 0) { // error, the parameter count mismatch between the function call and the function code _expressionData.ExprExecResult.AddErrorExec(ErrorCode.FunctionCallParamCountWrong, "FunctionCallName", functionCallUsed.Name); return(false); } // ok, the parameter count match return(true); } // one parameter at least is present if (functionToCall.Param2Type == DataType.NotDefined) { if (functionCallUsed.ParameterCount != 1) { // error, the parameter count mismatch between the function call and the function code _expressionData.ExprExecResult.AddErrorExec(ErrorCode.FunctionCallParamCountWrong, "FunctionCallName", functionCallUsed.Name); return(false); } // ok, the parameter count match return(true); } // one parameter at least is present if (functionToCall.Param3Type == DataType.NotDefined) { if (functionCallUsed.ParameterCount != 2) { // error, the parameter count mismatch between the function call and the function code _expressionData.ExprExecResult.AddErrorExec(ErrorCode.FunctionCallParamCountWrong, "FunctionCallName", functionCallUsed.Name); return(false); } // ok, the parameter count match return(true); } // the function call has three parameters if (functionCallUsed.ParameterCount != 3) { // error, the parameter count mismatch between the function call and the function code _expressionData.ExprExecResult.AddErrorExec(ErrorCode.FunctionCallParamCountWrong, "FunctionCallName", functionCallUsed.Name); return(false); } // ok, the parameter count match return(true); // todo: enlever code de check count param dans la methode ExprExecutorFunctionCallRetBase.CheckParam() }
/// <summary> /// save the objectName (variable). /// ExprFunctionCallUsed is an object representing a functionCall used/defined/found in the expression. /// (not an internal object). /// </summary> /// <param name="objectName"></param> public void AddFunctionCall(string objectName, int paramCount) //List<string> listParams) { ExprFunctionCallUsed exprFunctionCall = new ExprFunctionCallUsed(); exprFunctionCall.Name = objectName; exprFunctionCall.ParameterCount = paramCount; // check that the name is not already present in the list if (ListExprFunctionCallUsed.Find(n => n.Name.Equals(objectName, StringComparison.InvariantCultureIgnoreCase)) != null) { return; } // save the functionCall ListExprFunctionCallUsed.Add(exprFunctionCall); }