// Depreciated VVV public object ExecuteFunction(string funcname, object[] args, InputContext context) { switch (funcname) { case "f:sin": return(Sin(ExCasts.GetObjectAsDouble(args[0]))); case "f:cos": return(Cos(ExCasts.GetObjectAsDouble(args[0]))); case "f:tan": return(Tan(ExCasts.GetObjectAsDouble(args[0]))); case "f:abs": return(Abs(ExCasts.GetObjectAsDouble(args[0]))); case "f:min": return(Min(ExCasts.GetObjectsAsDoubleUnwrapping(args))); case "f:max": return(Max(ExCasts.GetObjectsAsDoubleUnwrapping(args))); case "f:avg": return(Avg(ExCasts.GetObjectsAsDoubleUnwrapping(args))); default: throw new Exception("Func '" + funcname + "' not found in library '" + GetLibraryName() + "'"); } }
public object ExecuteFunction(string funcname, object[] args, InputContext context) { switch (funcname) { case "f:substring": if (args.Length > 2) { return(Substring(ExCasts.GetObjectAsString(args[0]), ExCasts.GetObjectAsInt(args[1]), ExCasts.GetObjectAsInt(args[2]))); } return(Substring(ExCasts.GetObjectAsString(args[0]), ExCasts.GetObjectAsInt(args[1]))); case "f:length": return(Length(ExCasts.GetObjectAsString(args[0]))); case "f:comma": return(Comma(ExCasts.UnwrapStringArray(args))); case "f:commaand": return(CommaAnd(ExCasts.UnwrapStringArray(args))); case "f:replace": return(Replace(ExCasts.GetObjectAsString(args[0]), ExCasts.GetObjectAsString(args[1]), ExCasts.GetObjectAsString(args[2]))); default: throw new Exception("Func '" + funcname + "' not found in library '" + GetLibraryName() + "'"); } }
public Expression GetFunctionExpression(string funcname, Expression argexp, Expression argParams, ParameterExpression inputParams, Expression inputContextParam, List <InputVar> compiledInputVarsList) { switch (funcname) { case "f:substring": if (argexp is NewArrayExpression) { if ((argexp as NewArrayExpression).Expressions.Count > 2) { return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Substring", new[] { typeof(string), typeof(int), typeof(int) }), ExFuncs.GetArgAsString(ExFuncs.GetArgIndex(argexp, 0)), ExFuncs.GetArgAsInt(ExFuncs.GetArgIndex(argexp, 1)), ExFuncs.GetArgAsInt(ExFuncs.GetArgIndex(argexp, 2)))); } return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Substring", new[] { typeof(string), typeof(int) }), ExFuncs.GetArgAsString(ExFuncs.GetArgIndex(argexp, 0)), ExFuncs.GetArgAsInt(ExFuncs.GetArgIndex(argexp, 1)))); } // otherwise we need to inspect the number of args at runtime return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("SubstringRuntime", new[] { typeof(object[]) }), ExCasts.WrapArguments(argexp))); case "f:length": return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Length", new[] { typeof(string) }), ExFuncs.GetArgAsString(ExFuncs.GetArgIndex(argexp, 0)))); case "f:comma": return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Comma", new[] { typeof(string[]) }), Expression.Call(typeof(ExCasts).GetTypeInfo().GetDeclaredMethod("UnwrapStringArray"), ExCasts.WrapArguments(argexp)))); case "f:commaand": return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("CommaAnd", new[] { typeof(string[]) }), Expression.Call(typeof(ExCasts).GetTypeInfo().GetDeclaredMethod("UnwrapStringArray"), ExCasts.WrapArguments(argexp)))); case "f:replace": return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Replace", new[] { typeof(string), typeof(string), typeof(string) }), ExFuncs.GetArgAsString(ExFuncs.GetArgIndex(argexp, 0)), ExFuncs.GetArgAsString(ExFuncs.GetArgIndex(argexp, 1)), ExFuncs.GetArgAsString(ExFuncs.GetArgIndex(argexp, 2)))); default: throw new Exception("Func '" + funcname + "' not found in library '" + GetLibraryName() + "'"); } }
public Expression GetFunctionExpression(string funcname, Expression argexp, Expression argParams, ParameterExpression inputParams, Expression inputContextParam, List <InputVar> compiledInputVarsList) { switch (funcname) { case "f:subset": if (argexp is NewArrayExpression) { if ((argexp as NewArrayExpression).Expressions.Count > 2) { return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Subset", new[] { typeof(object[]), typeof(int), typeof(int) }), ExCasts.WrapArguments(ExFuncs.GetArgIndex(argexp, 0)), ExFuncs.GetArgAsInt(ExFuncs.GetArgIndex(argexp, 1)), ExFuncs.GetArgAsInt(ExFuncs.GetArgIndex(argexp, 2)))); } return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Subset", new[] { typeof(object[]), typeof(int) }), ExCasts.WrapArguments(ExFuncs.GetArgIndex(argexp, 0)), ExFuncs.GetArgAsInt(ExFuncs.GetArgIndex(argexp, 1)))); } return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("SubsetRuntime", new[] { typeof(object[]) }), ExCasts.WrapArguments(argexp))); case "f:length": return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Length", new[] { typeof(object[]) }), ExCasts.WrapArguments(argexp))); case "f:append": return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Append", new[] { typeof(object[]), typeof(object) }), ExCasts.WrapArguments(ExFuncs.GetArgIndex(argexp, 0)), ExFuncs.GetArgAsObject(ExFuncs.GetArgIndex(argexp, 1)))); case "f:insert": return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Insert", new[] { typeof(object[]), typeof(object), typeof(int) }), ExCasts.WrapArguments(ExFuncs.GetArgIndex(argexp, 0)), ExFuncs.GetArgAsObject(ExFuncs.GetArgIndex(argexp, 1)), ExFuncs.GetArgAsInt(ExFuncs.GetArgIndex(argexp, 2)))); case "f:remove": return(Expression.Call(Expression.Constant(this), this.GetType().GetRuntimeMethod("Remove", new[] { typeof(object[]), typeof(int) }), ExCasts.WrapArguments(ExFuncs.GetArgIndex(argexp, 0)), ExFuncs.GetArgAsInt(ExFuncs.GetArgIndex(argexp, 1)))); default: throw new Exception("Func '" + funcname + "' not found in library '" + GetLibraryName() + "'"); } }
public string SubstringRuntime(object[] args) { if (args.Length > 2) { return(Substring( ExCasts.GetObjectAsString(args[0]), ExCasts.GetObjectAsInt(args[1]), ExCasts.GetObjectAsInt(args[2]))); } return(Substring( ExCasts.GetObjectAsString(args[0]), ExCasts.GetObjectAsInt(args[1]))); }
public object[] SubsetRuntime(object[] args) { if (args.Length > 2) { return(Subset( (object[])args[0], ExCasts.GetObjectAsInt(args[1]), ExCasts.GetObjectAsInt(args[2]))); } return(Subset( (object[])args[0], ExCasts.GetObjectAsInt(args[1]))); }
public object ExecuteFunction(string funcname, object[] args, InputContext context) { switch (funcname) { case "f:random": return(RandomDouble(ExCasts.GetObjectAsDouble(args[0]), ExCasts.GetObjectAsDouble(args[1]), context.Random)); case "f:randomint": return(RandomInt(ExCasts.GetObjectAsInt(args[0]), ExCasts.GetObjectAsInt(args[1]), context.Random)); case "f:roll": return(Roll(ExCasts.GetObjectAsInt(args[0]), ExCasts.GetObjectAsInt(args[1]), context.Random)); default: throw new Exception("Func '" + funcname + "' not found in library '" + GetLibraryName() + "'"); } }
public object ExecuteFunction(string funcname, object[] args, InputContext context) { switch (funcname) { case "f:subset": if (args.Length > 2) { return(Subset( ExCasts.InspectObjectForObjectArray(args[0]), ExCasts.GetObjectAsInt(args[1]), ExCasts.GetObjectAsInt(args[2]))); } return(Subset( ExCasts.InspectObjectForObjectArray(args[0]), ExCasts.GetObjectAsInt(args[1]))); case "f:length": return(Length(args)); case "f:append": return(Append( ExCasts.InspectObjectForObjectArray(args[0]), ExCasts.UnwrapAtRuntime(args[1]) )); case "f:insert": return(Insert( ExCasts.InspectObjectForObjectArray(args[0]), ExCasts.UnwrapAtRuntime(args[1]), ExCasts.GetObjectAsInt(args[2]) )); case "f:remove": return(Remove( ExCasts.InspectObjectForObjectArray(args[0]), ExCasts.GetObjectAsInt(args[1]) )); default: throw new Exception("Func '" + funcname + "' not found in library '" + GetLibraryName() + "'"); } }