Example #1
0
        /// <summary>Performs evaluation of a function</summary>

        /// <param name="caller">The tracking object calling the function</param>
        /// <param name="name">The function name</param>
        /// <param name="param">The function parameters</param>
        /// <returns></returns>
        public Val RunFunction(ITracker caller, string name, Val[] param)
        {
            IValFunc vfs = ValFuncs.Get(new Pair <string, int>(name, param.Length));

            if (vfs == null)
            {
                if (ValFuncRef.Contains(name))
                {
                    vfs = ValFuncs.Get(new Pair <string, int>(name, -1)); // Val[]
                    if (vfs == null)
                    {
                        throw new EvalException(caller, Resource.Strings.Error_EvalException_IncorrectParameters.F(name));
                    }
                }
                else
                {
                    throw new EvalException(caller, Resource.Strings.Error_EvalException_FunctionNotFound.F(name));
                }
            }

            return(vfs.Execute(caller, name, this, param));
        }
Example #2
0
 /// <summary>Retrieves a function from the function list</summary>
 /// <param name="name">The function name</param>
 /// <param name="argnum">The number of arguments for the function</param>
 /// <returns></returns>
 public object GetFunction(string name, int argnum)
 {
     return(ValFuncs.Get(new Pair <string, int>(name, argnum)));
 }