Esempio n. 1
0
        protected object EvaluateNativeFunction(Environment env, NativeFunction function)
        {
            if (function == null)
            {
                throw new ArgumentNullException(nameof(function), "null function");
            }

            int pcount = function.ParametersCount;

            if (Count != pcount)
            {
                throw new LepException("bad number of arguments", this);
            }

            object[] arguments = new object[pcount];

            int count = 0;

            foreach (IAstNode node in this)
            {
                arguments[count++] = node.Evaluate(env);
            }

            return(function.Invoke(arguments, this));
        }
Esempio n. 2
0
        protected object EvaluateNativeFunction(Environment env, NativeFunction function)
        {
            if (function == null) throw new ArgumentNullException(nameof(function), "null function");

            int pcount = function.ParametersCount;

            Tuple arguments = Evaluate(env) as Tuple;
            if (arguments == null) throw new LepException("bad expression argument", this);

            if (arguments.Count != pcount) throw new LepException("bad number of argument", this);

            return function.Invoke(arguments.GetArray(), this);
        }
Esempio n. 3
0
        protected object EvaluateNativeFunction(Environment env, NativeFunction function)
        {
            if (function == null) throw new ArgumentNullException(nameof(function), "null function");

            int pcount = function.ParametersCount;
            if (Count != pcount) throw new LepException("bad number of arguments", this);

            object[] arguments = new object[pcount];

            int count = 0;
            foreach (IAstNode node in this) arguments[count++] = node.Evaluate(env);

            return function.Invoke(arguments, this);
        }
Esempio n. 4
0
        protected object EvaluateNativeFunction(Environment env, NativeFunction function)
        {
            if (function == null)
            {
                throw new ArgumentNullException(nameof(function), "null function");
            }

            int pcount = function.ParametersCount;

            Tuple arguments = Evaluate(env) as Tuple;

            if (arguments == null)
            {
                throw new LepException("bad expression argument", this);
            }

            if (arguments.Count != pcount)
            {
                throw new LepException("bad number of argument", this);
            }

            return(function.Invoke(arguments.GetArray(), this));
        }