public static VAL HostTypeFunction(VAL proc, VALL parameters) { VAL ret = VAL.VOID; if (proc.ty == VALTYPE.hostcon && (proc.value is MethodInfo || proc.value is MethodInfo[])) { HostOffset temp = (HostOffset)proc.temp; object host = temp.host; object offset = temp.offset; if (offset is MethodInfo) { ret = VAL.Boxing1(((MethodInfo)proc.value).Invoke(host, parameters.ObjectArray)); } else { HostFunction hFunc = new HostFunction(host, (string)offset, parameters); if (proc.value is MethodInfo[]) { ret = hFunc.RunFunction((MethodInfo[])proc.value); } else { MethodInfo method = (MethodInfo)proc.value; if (method.IsGenericMethod) { ret = hFunc.RunFunction(new MethodInfo[] { method }); } else { ret = hFunc.RunFunction(); } } } } else if (proc.value is Delegate) { Delegate d = (Delegate)proc.value; MethodInfo method = d.Method; object[] arguments = parameters.ObjectArray; return(HostFunction.InvokeMethod(method, d.Target, arguments)); } return(ret); }
public static VAL OperatorOverloading(Operator opr, VAL v1, VAL v2, bool silent) { VALL L = new VALL(); L.Add(v1); if ((object)v2 != null) { L.Add(v2); } HostFunction hFunc = new HostFunction(v1.value, opr.ToString(), L); if (silent) { return(hFunc.RunFunctionSilently(null)); } else { return(hFunc.RunFunction(null)); } }