public override CQ_Value Math2Value(char code, CQ_Value left, CQ_Value right) { if (left.GetObject() is DeleEvent) { DeleEvent info = left.GetObject() as DeleEvent; Delegate calldele = null; //!--exist bug. /*if (right.value is DeleFunction) calldele = CreateDelegate(right.value as DeleFunction); * else if (right.value is DeleLambda) calldele = CreateDelegate(right.value as DeleLambda); * else if (right.value is Delegate) calldele = right.value as Delegate;*/ object rightValue = right.GetObject(); if (rightValue is DeleFunction) { if (code == '+') { calldele = CreateDelegate(rightValue as DeleFunction); } else if (code == '-') { calldele = CreateDelegate(rightValue as DeleFunction); } } else if (rightValue is DeleLambda) { if (code == '+') { calldele = CreateDelegate(rightValue as DeleLambda); } else if (code == '-') { calldele = CreateDelegate(rightValue as DeleLambda); } } else if (rightValue is Delegate) { calldele = rightValue as Delegate; } if (code == '+') { info._event.AddEventHandler(info.source, calldele); //if (!(rightValue is Delegate)) { // Dele_Map_Delegate.Map(rightValue as IDeleBase, calldele); //} CQ_Value ret = new CQ_Value();//type保持null ret.SetNoneTypeObject(info); return(ret); } else if (code == '-') { info._event.RemoveEventHandler(info.source, calldele); //if (!(rightValue is Delegate)) { // Dele_Map_Delegate.Destroy(rightValue as IDeleBase); //} CQ_Value ret = new CQ_Value();//type保持null ret.SetNoneTypeObject(info); return(ret); } } else if (left.GetObject() is Delegate || left.GetObject() == null) { Delegate info = left.GetObject() as Delegate; Delegate calldele = null; if (right.GetObject() is DeleFunction) { calldele = CreateDelegate(right.GetObject() as DeleFunction); } else if (right.GetObject() is DeleLambda) { calldele = CreateDelegate(right.GetObject() as DeleLambda); } else if (right.GetObject() is Delegate) { calldele = right.GetObject() as Delegate; } if (code == '+') { CQ_Value ret = new CQ_Value();//type保持null ret.SetNoneTypeObject(Delegate.Combine(info, calldele)); return(ret); } else if (code == '-') { CQ_Value ret = new CQ_Value();//type保持null ret.SetNoneTypeObject(Delegate.Remove(info, calldele)); return(ret); } } throw new NotSupportedException(); }
public CQ_Value ComputeValue(CQ_Content content) { #if CQUARK_DEBUG content.InStack(this); #endif CQ_Value[] parameters = CQ_ObjPool.PopArray(_expressions.Count); for (int i = 0; i < _expressions.Count; i++) { parameters[i] = _expressions[i].ComputeValue(content); } CQ_Value v = CQ_Value.Null; Class_CQuark.Function retFunc = null; bool bFind = false; if (content.CallType != null) { bFind = content.CallType.functions.TryGetValue(funcname, out retFunc); } if (bFind) { if (retFunc.bStatic) { v = content.CallType.StaticCall(content, funcname, parameters); } else { v = content.CallType.MemberCall(content, content.CallThis, funcname, parameters); } } else { v = content.GetQuiet(funcname); if (v.IsDelegate) { Delegate d = v.GetObject() as Delegate; v = new CQ_Value(); object[] obja = new object[parameters.Length]; for (int i = 0; i < parameters.Length; i++) { obja[i] = parameters[i].GetObject(); } object obj = d.DynamicInvoke(obja); if (obj == null) { v.SetNoneTypeObject(null); } else { v.SetObject(obj.GetType(), obj); } } else { throw new Exception(funcname + "没有这样的方法"); //v = CQuark.AppDomain.GetMethod(funcname).Call(content, list); } } //操作变量之 //做数学计算 //从上下文取值 //_value = null; #if CQUARK_DEBUG content.OutStack(this); #endif CQ_ObjPool.PushArray(parameters); return(v); }