public override Delegate CreateDelegate(DeleFunction delefunc) { DeleFunction _func = delefunc; Delegate _dele = delefunc.cacheFunction(this._type, null); if (_dele != null) { return(_dele); } Action <T, T1, T2> dele = (T param0, T1 param1, T2 param2) => { var func = _func.calltype.functions[_func.function]; if (func.expr_runtime != null) { CQ_Content content = new CQ_Content(); try { content.DepthAdd(); content.CallThis = _func.callthis; content.CallType = _func.calltype; #if CQUARK_DEBUG content.function = _func.function; #endif content.DefineAndSet(func._paramnames[0], func._paramtypes[0].typeBridge, param0); content.DefineAndSet(func._paramnames[1], func._paramtypes[1].typeBridge, param1); content.DefineAndSet(func._paramnames[2], func._paramtypes[2].typeBridge, param2); func.expr_runtime.ComputeValue(content); content.DepthRemove(); } catch (Exception err) { string errinfo = "Dump Call in:"; if (_func.calltype != null) { errinfo += _func.calltype.Name + "::"; } if (_func.function != null) { errinfo += _func.function; } errinfo += "\n"; DebugUtil.Log(errinfo + content.Dump()); throw err; } } }; Delegate d = dele as Delegate; if ((Type)this.typeBridge != typeof(Action)) { _dele = Delegate.CreateDelegate(this.typeBridge, d.Target, d.Method); } else { _dele = dele; } return(delefunc.cacheFunction(this._type, _dele)); }
public override Delegate CreateDelegate(DeleFunction delefunc) { DeleFunction _func = delefunc; Delegate _dele = delefunc.cacheFunction(this._type, null); if (_dele != null) { return(_dele); } NonVoidDelegate dele = delegate(T param, T1 param1) { var func = _func.calltype.functions[_func.function]; if (func.expr_runtime != null) { CQ_Content content = CQ_ObjPool.PopContent(); try { content.CallThis = _func.callthis; content.CallType = _func.calltype; #if CQUARK_DEBUG content.function = _func.function; #endif CQ_Value p0 = new CQ_Value(); p0.SetObject(func._paramtypes[0].typeBridge, param); content.DefineAndSet(func._paramnames[0], typeof(T), p0); CQ_Value p1 = new CQ_Value(); p1.SetObject(func._paramtypes[0].typeBridge, param1); content.DefineAndSet(func._paramnames[1], typeof(T1), p1); CQ_Value retValue = func.expr_runtime.ComputeValue(content); content.DepthRemove(); CQ_ObjPool.PushContent(content); return((ReturnType)retValue.GetObject()); } catch (Exception err) { string errinfo = "Dump Call in:"; if (_func.calltype != null) { errinfo += _func.calltype.Name + "::"; } if (_func.function != null) { errinfo += _func.function; } errinfo += "\n"; DebugUtil.Log(errinfo + content.Dump()); throw err; } } return(default(ReturnType)); }; _dele = Delegate.CreateDelegate(this.typeBridge, dele.Target, dele.Method); return(delefunc.cacheFunction(this._type, _dele)); }
public Delegate CreateDelegate(ICQ_Environment env, DeleFunction delefunc) { DeleFunction _func = delefunc; Delegate _dele = delefunc.cacheFunction(this._type, null); if (_dele != null) { return(_dele); } Action <T> dele = (T param0) => { var func = _func.calltype.functions[_func.function]; if (func.expr_runtime != null) { CQ_Content content = new CQ_Content(env, true); try { content.DepthAdd(); content.CallThis = _func.callthis; content.CallType = _func.calltype; content.function = _func.function; content.DefineAndSet(func._paramnames[0], func._paramtypes[0].type, param0); func.expr_runtime.ComputeValue(content); content.DepthRemove(); } catch (Exception err) { string errinfo = "Dump Call in:"; if (_func.calltype != null) { errinfo += _func.calltype.Name + "::"; } if (_func.function != null) { errinfo += _func.function; } errinfo += "\n"; env.logger.Log(errinfo + content.Dump()); throw err; } } }; Delegate d = dele as Delegate; if ((Type)this.type != typeof(Action)) { _dele = Delegate.CreateDelegate(this.type, d.Target, d.Method); } else { _dele = dele; } return(delefunc.cacheFunction(this._type, _dele)); }
public CQ_Value GetQuiet(string name) { if (name == "this") { CQ_Value v = new CQ_Value(); v.type = CallType; v.value = CallThis; return(v); } CQ_Value retV = null; bool bFind = false; if (values != null) { bFind = values.TryGetValue(name, out retV); if (bFind)//优先上下文变量 { return(retV); } } if (CallType != null) { Class_CQuark.Member retM = null; bFind = CallType.members.TryGetValue(name, out retM); if (bFind) { if (retM.bStatic) { return(CallType.staticMemberInstance[name]); } else { return(CallThis.member[name]); } } if (CallType.functions.ContainsKey(name)) { CQ_Value v = new CQ_Value(); //如果直接得到代理实例, DeleFunction dele = new DeleFunction(CallType, this.CallThis, name); //DeleScript dele =new DeleScript(); //dele.function = name; //dele.calltype = CallType; //dele.callthis = CallThis; v.value = dele; v.type = typeof(DeleFunction); return(v); } } return(null); }
public Delegate CreateDelegate(ICQ_Environment env, DeleFunction delefunc) { DeleFunction _func = delefunc; Delegate _dele = delefunc.cacheFunction(this._type, null); if (_dele != null) { return(_dele); } NonVoidDelegate dele = delegate(T param0, T1 param1, T2 param2) { var func = _func.calltype.functions[_func.function]; if (func.expr_runtime != null) { CQ_Content content = new CQ_Content(env, true); try { content.DepthAdd(); content.CallThis = _func.callthis; content.CallType = _func.calltype; content.function = _func.function; content.DefineAndSet(func._paramnames[0], func._paramtypes[0].type, param0); content.DefineAndSet(func._paramnames[1], func._paramtypes[1].type, param1); content.DefineAndSet(func._paramnames[2], func._paramtypes[2].type, param2); CQ_Content.Value retValue = func.expr_runtime.ComputeValue(content); content.DepthRemove(); return((ReturnType)retValue.value); } catch (Exception err) { string errinfo = "Dump Call in:"; if (_func.calltype != null) { errinfo += _func.calltype.Name + "::"; } if (_func.function != null) { errinfo += _func.function; } errinfo += "\n"; env.logger.Log(errinfo + content.Dump()); throw err; } } return(default(ReturnType)); }; _dele = Delegate.CreateDelegate(this.type, dele.Target, dele.Method); return(delefunc.cacheFunction(this._type, _dele)); }
public override Delegate CreateDelegate(DeleFunction delefunc) { DeleFunction _func = delefunc; Delegate _dele = delefunc.cacheFunction(this._type, null); if (_dele != null) { return(_dele); } NonVoidDelegate dele = delegate() { var func = _func.calltype.functions[_func.function]; if (func.expr_runtime != null) { CQ_Content content = new CQ_Content(); try { content.DepthAdd(); content.CallThis = _func.callthis; content.CallType = _func.calltype; #if CQUARK_DEBUG content.function = _func.function; #endif CQ_Value retValue = func.expr_runtime.ComputeValue(content); content.DepthRemove(); return((ReturnType)retValue.value); } catch (Exception err) { string errinfo = "Dump Call in:"; if (_func.calltype != null) { errinfo += _func.calltype.Name + "::"; } if (_func.function != null) { errinfo += _func.function; } errinfo += "\n"; DebugUtil.Log(errinfo + content.Dump()); throw err; } } return(default(ReturnType)); }; _dele = Delegate.CreateDelegate(this.typeBridge, dele.Target, dele.Method); return(delefunc.cacheFunction(this._type, _dele)); }
public CQ_Value GetQuiet(string name) { CQ_Value retV = new CQ_Value(); if (name == "this") { retV.SetObject(CallType, CallThis); return(retV); } if (values != null) { if (values.TryGetValue(name, out retV))//优先上下文变量 { return(retV); } } if (CallType != null) { Class_CQuark.Member retM = Class_CQuark.Member.Null; if (CallType.members.TryGetValue(name, out retM)) { if (retM.bStatic) { return(CallType.staticMemberInstance[name]); } else { return(CallThis.member[name]); } } if (CallType.functions.ContainsKey(name)) { //如果直接得到代理实例, DeleFunction dele = new DeleFunction(CallType, this.CallThis, name); retV.SetObject(typeof(DeleFunction), dele); return(retV); } } return(retV);//null }
public virtual Delegate CreateDelegate(DeleFunction lambda) { throw new Exception("方法没有被重载"); }