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)); }
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); }
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); }
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)); }