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 value = CQ_Value.Null; //这几行是为了快速获取Unity的静态变量,而不需要反射 if (!Wrap.StaticCall(type.typeBridge.type, functionName, parameters, out value)) { if (cache == null || cache.cachefail) { cache = new MethodCache(); value = type._class.StaticCall(content, functionName, parameters, cache); } else { value = type._class.StaticCallCache(content, parameters, cache); } } #if CQUARK_DEBUG content.OutStack(this); #endif CQ_ObjPool.PushArray(parameters); return(value); }
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 value = CQ_Value.Null; //这几行是为了快速获取Unity的静态变量,而不需要反射 if (!Wrap.New(type.typeBridge.type, parameters, out value)) { value = type._class.New(content, parameters); } #if CQUARK_DEBUG content.OutStack(this); #endif CQ_ObjPool.PushArray(parameters); return(value); }
public CQ_Value ComputeValue(CQ_Content content) { #if CQUARK_DEBUG content.InStack(this); #endif CQ_Value parent = _expressions[0].ComputeValue(content); #if CQUARK_DEBUG if (parent == CQ_Value.Null) { throw new Exception("调用空对象的方法:" + _expressions[0].ToString() + ":" + ToString()); } #endif CQ_Value[] parameters = CQ_ObjPool.PopArray(_expressions.Count - 1); for (int i = 0; i < _expressions.Count - 1; i++) { parameters[i] = _expressions[i + 1].ComputeValue(content); } CQ_Value value = CQ_Value.Null; //这几行是为了快速获取Unity的静态变量,而不需要反射 object obj = parent.GetObject(); if (!Wrap.MemberCall(parent.m_type, obj, functionName, parameters, out value)) { //TODO 要么注册所有基本类型(bool,int,string...)要么这里特殊处理 if (functionName == "ToString" && parameters.Length == 0) { CQ_Value ret = new CQ_Value(); ret.SetObject(typeof(string), obj.ToString()); return(ret); } else if (obj is UnityEngine.MonoBehaviour && functionName == "StartCoroutine" && parameters.Length >= 1 && parameters[0].GetObject() is CQ_Expression_Block) { //从西瓜调用的ClassSystem.StartCoroutine(CquarkMethod());不需要走cache UnityEngine.MonoBehaviour mb = obj as UnityEngine.MonoBehaviour; CQ_Expression_Block call = parameters[0].GetObject() as CQ_Expression_Block; CQ_Value ret = new CQ_Value(); ret.SetObject(typeof(UnityEngine.Coroutine), mb.StartCoroutine(call.callObj.CallType.CoroutineCall(call, call.callObj, mb))); return(ret); } else { var iclass = CQuark.AppDomain.GetITypeByCQValue(parent)._class; if (cache == null || cache.cachefail) { cache = new MethodCache(); value = iclass.MemberCall(content, obj, functionName, parameters, cache); } else { value = iclass.MemberCallCache(content, obj, parameters, cache); } } } #if CQUARK_DEBUG content.OutStack(this); #endif CQ_ObjPool.PushArray(parameters); return(value); }
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); }