public CQ_Value ComputeValue(CQ_Content content) { #if CQUARK_DEBUG content.InStack(this); #endif List <CQ_Value> _params = new List <CQ_Value>(); for (int i = 0; i < _expressions.Count; i++) { _params.Add(_expressions[i].ComputeValue(content)); } CQ_Value value = null; //这几行是为了快速获取Unity的静态变量,而不需要反射 if (!Wrap.StaticCall(type.typeBridge.type, functionName, _params, out value)) { if (cache == null || cache.cachefail) { cache = new MethodCache(); value = type._class.StaticCall(content, functionName, _params, cache); } else { value = type._class.StaticCallCache(content, _params, cache); } } #if CQUARK_DEBUG content.OutStack(this); #endif 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.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_Content.Value ComputeValue(CQ_Content content) { content.InStack(this); //var parent = listParam[0].ComputeValue(content); //var type = content.environment.GetType(parent.type); List <CQ_Content.Value> _params = new List <CQ_Content.Value>(); for (int i = 0; i < listParam.Count; i++) { _params.Add(listParam[i].ComputeValue(content)); } CQ_Content.Value value = null; if (cache == null || cache.cachefail) { cache = new MethodCache(); value = type.function.StaticCall(content, functionName, _params, cache); } else { value = type.function.StaticCallCache(content, _params, cache); } content.OutStack(this); return(value); //做数学计算 //从上下文取值 //_value = null; //return null; }
public CQ_Value StaticCallCache(CQ_Content content, CQ_Value[] _params, MethodCache cache) { List <object> _oparams = new List <object>(); foreach (var p in _params) { _oparams.Add(p.GetObject()); } System.Reflection.MethodInfo methodInfo = cache.info; if (cache.needConvert) { var pp = methodInfo.GetParameters(); for (int i = 0; i < pp.Length; i++) { if (i >= _params.Length) { _oparams.Add(pp[i].DefaultValue); } else { if (pp[i].ParameterType != _params[i].m_type) { _oparams[i] = _params[i].ConvertTo(pp[i].ParameterType); } } } } CQ_Value v = new CQ_Value(); v.SetObject(methodInfo.ReturnType, methodInfo.Invoke(null, _oparams.ToArray())); return(v); }
public CQ_Value ComputeValue(CQ_Content content) { #if CQUARK_DEBUG content.InStack(this); #endif var parent = _expressions[0].ComputeValue(content); if (parent == null) { throw new Exception("调用空对象的方法:" + _expressions[0].ToString() + ":" + ToString()); } // CQClassInstance s = parent.value as CQClassInstance; // if(s != null) { // iclass = s.type; // } List <CQ_Value> _params = new List <CQ_Value>(); for (int i = 1; i < _expressions.Count; i++) { _params.Add(_expressions[i].ComputeValue(content)); } CQ_Value value = null; //这几行是为了快速获取Unity的静态变量,而不需要反射 if (!Wrap.MemberCall(parent.type.type, parent.value, functionName, _params, out value)) { var iclass = CQuark.AppDomain.GetType(parent.type)._class; if (cache == null || cache.cachefail) { cache = new MethodCache(); value = iclass.MemberCall(content, parent.value, functionName, _params, cache); } else { value = iclass.MemberCallCache(content, parent.value, _params, cache); } } #if CQUARK_DEBUG content.OutStack(this); #endif return(value); }
public CQ_Content.Value ComputeValue(CQ_Content content) { content.InStack(this); var parent = listParam[0].ComputeValue(content); if (parent == null) { throw new Exception("调用空对象的方法:" + listParam[0].ToString() + ":" + ToString()); } var typefunction = content.environment.GetType(parent.type).function; if (parent.type is object) { SInstance s = parent.value as SInstance; if (s != null) { typefunction = s.type; } } List <CQ_Content.Value> _params = new List <CQ_Content.Value>(); for (int i = 1; i < listParam.Count; i++) { _params.Add(listParam[i].ComputeValue(content)); } CQ_Content.Value value = null; if (cache == null || cache.cachefail) { cache = new MethodCache(); value = typefunction.MemberCall(content, parent.value, functionName, _params, cache); } else { value = typefunction.MemberCallCache(content, parent.value, _params, cache); } content.OutStack(this); return(value); //做数学计算 //从上下文取值 //_value = null; //return null; }
public CQ_Value MemberCall(CQ_Content contentParent, object object_this, string func, CQ_Value[] _params, MethodCache cache) { if (cache != null) { cache.cachefail = true; } Function funccache = null; if (this.functions.TryGetValue(func, out funccache)) { if (funccache.bStatic == false) { CQ_Content content = CQ_ObjPool.PopContent(); content.CallType = this; content.CallThis = object_this as CQ_ClassInstance; #if CQUARK_DEBUG content.function = func; contentParent.InStack(content);//把这个上下文推给上层的上下文,这样如果崩溃是可以一层层找到原因的 #endif for (int i = 0; i < funccache._paramtypes.Count; i++) { //content.DefineAndSet(funccache._paramnames[i], funccache._paramtypes[i].typeBridge, _params[i].GetValue()); content.DefineAndSet(funccache._paramnames[i], _params[i].typeBridge, _params[i]); } //如果返回值是IEnumerator的话,这里把方法返回出来 if (funccache._returntype != null && funccache._returntype.typeBridge.type == typeof(IEnumerator)) { CQ_Value ienumerator = new CQ_Value(); CQ_Expression_Block funcCQ = funccache.expr_runtime as CQ_Expression_Block; funcCQ.callObj = content; ienumerator.SetObject(typeof(CQ_Expression_Block), funcCQ); return(ienumerator); } CQ_Value value = CQ_Value.Null; var funcobj = funccache; if (this.bInterface) { content.CallType = (object_this as CQ_ClassInstance).type; funcobj = (object_this as CQ_ClassInstance).type.functions[func]; } if (funcobj.expr_runtime != null) { value = funcobj.expr_runtime.ComputeValue(content); } #if CQUARK_DEBUG contentParent.OutStack(content); #endif CQ_ObjPool.PushContent(content); return(value); } } else if (this.members.ContainsKey(func)) { if (this.members[func].bStatic == false) { Delegate dele = (object_this as CQ_ClassInstance).member[func].GetObject() as Delegate; if (dele != null) { CQ_Value value = new CQ_Value(); object[] objs = new object[_params.Length]; for (int i = 0; i < _params.Length; i++) { objs[i] = _params[i].GetObject(); } object obj = dele.DynamicInvoke(objs); if (obj == null) { return(CQ_Value.Null); } else { value.SetObject(obj.GetType(), obj); return(value); } } } } throw new NotImplementedException(); }
public CQ_Value StaticCall(CQ_Content contentParent, string function, CQ_Value[] _params, MethodCache cache) { if (cache != null) { cache.cachefail = true; } NewStatic(); if (this.functions.ContainsKey(function)) { if (this.functions[function].bStatic == true) { CQ_Content content = CQ_ObjPool.PopContent(); content.CallType = this; content.CallThis = null; #if CQUARK_DEBUG content.function = function; contentParent.InStack(content);//把这个上下文推给上层的上下文,这样如果崩溃是可以一层层找到原因的 #endif // int i = 0; for (int i = 0; i < functions[function]._paramtypes.Count; i++) { //content.DefineAndSet(functions[function]._paramnames[i], functions[function]._paramtypes[i].typeBridge, _params[i].GetValue()); content.DefineAndSet(functions[function]._paramnames[i], _params[i].typeBridge, _params[i]); } CQ_Value value = CQ_Value.Null; if (this.functions[function].expr_runtime != null) { value = this.functions[function].expr_runtime.ComputeValue(content); } #if CQUARK_DEBUG contentParent.OutStack(content); #endif CQ_ObjPool.PushContent(content); return(value); } } else if (this.members.ContainsKey(function)) { if (this.members[function].bStatic == true) { Delegate dele = this.staticMemberInstance[function].GetObject() as Delegate; if (dele != null) { CQ_Value value = new CQ_Value(); object[] objs = new object[_params.Length]; for (int i = 0; i < _params.Length; i++) { objs[i] = _params[i].GetObject(); } object obj = dele.DynamicInvoke(objs); if (obj == null) { return(CQ_Value.Null); } else { value.SetObject(obj.GetType(), obj); return(value); } //value.breakBlock = BreakType.None; } } } throw new NotImplementedException(); }
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 StaticCallCache(CQ_Content content, IList <CQ_Value> _params, MethodCache cache) { throw new NotImplementedException(); }
public virtual CQ_Content.Value StaticCall(CQ_Content environment, string function, IList <CQ_Content.Value> _params, MethodCache cache) { bool needConvert = false; List <object> _oparams = new List <object>(); List <Type> types = new List <Type>(); bool bEm = false; foreach (CQ_Content.Value p in _params) { _oparams.Add(p.value); if ((SType)p.type != null) { types.Add(typeof(object)); } else { if (p.type == null) { bEm = true; } types.Add(p.type); } } System.Reflection.MethodInfo targetop = null; if (!bEm) { targetop = type.GetMethod(function, types.ToArray()); } //if (targetop == null && type.BaseType != null)//加上父类型静态函数查找,典型的现象是 GameObject.Destory //{ // targetop = type.BaseType.GetMethod(function, types.ToArray()); //} if (targetop == null) { if (function[function.Length - 1] == '>')//这是一个临时的模板函数调用 { int sppos = function.IndexOf('<', 0); string tfunc = function.Substring(0, sppos); string strparam = function.Substring(sppos + 1, function.Length - sppos - 2); string[] sf = strparam.Split(','); //string tfunc = sf[0]; Type[] gtypes = new Type[sf.Length]; for (int i = 0; i < sf.Length; i++) { gtypes[i] = environment.environment.GetTypeByKeyword(sf[i]).type; } targetop = FindTMethod(type, tfunc, _params, gtypes); } if (targetop == null) { Type ptype = type.BaseType; while (ptype != null) { targetop = ptype.GetMethod(function, types.ToArray()); if (targetop != null) { break; } var t = environment.environment.GetType(ptype); try { return(t.function.StaticCall(environment, function, _params, cache)); } catch { } ptype = ptype.BaseType; } } } if (targetop == null) { //因为有cache的存在,可以更慢更多的查找啦,哈哈哈哈 targetop = GetMethodSlow(environment, true, function, types, _oparams); needConvert = true; } if (targetop == null) { throw new Exception("函数不存在function:" + type.ToString() + "." + function); } if (cache != null) { cache.info = targetop; cache.slow = needConvert; } CQ_Content.Value v = new CQ_Content.Value(); v.value = targetop.Invoke(null, _oparams.ToArray()); v.type = targetop.ReturnType; return(v); }
public virtual CQ_Content.Value MemberCall(CQ_Content environment, object object_this, string function, IList <CQ_Content.Value> _params, MethodCache cache) { bool needConvert = false; List <Type> types = new List <Type>(); List <object> _oparams = new List <object>(); bool bEm = false; foreach (CQ_Content.Value p in _params) { { _oparams.Add(p.value); } if ((SType)p.type != null) { types.Add(typeof(object)); } else { if (p.type == null) { bEm = true; } types.Add(p.type); } } System.Reflection.MethodInfo targetop = null; if (!bEm) { targetop = type.GetMethod(function, types.ToArray()); } CQ_Content.Value v = new CQ_Content.Value(); if (targetop == null) { if (function[function.Length - 1] == '>')//这是一个临时的模板函数调用 { int sppos = function.IndexOf('<', 0); string tfunc = function.Substring(0, sppos); string strparam = function.Substring(sppos + 1, function.Length - sppos - 2); string[] sf = strparam.Split(','); //string tfunc = sf[0]; Type[] gtypes = new Type[sf.Length]; for (int i = 0; i < sf.Length; i++) { gtypes[i] = environment.environment.GetTypeByKeyword(sf[i]).type; } targetop = FindTMethod(type, tfunc, _params, gtypes); var ps = targetop.GetParameters(); for (int i = 0; i < Math.Min(ps.Length, _oparams.Count); i++) { if (ps[i].ParameterType != (Type)_params[i].type) { _oparams[i] = environment.environment.GetType(_params[i].type).ConvertTo(environment, _oparams[i], ps[i].ParameterType); } } } else { if (!bEm) { foreach (var s in type.GetInterfaces()) { targetop = s.GetMethod(function, types.ToArray()); if (targetop != null) { break; } } } if (targetop == null) {//因为有cache的存在,可以更慢更多的查找啦,哈哈哈哈 targetop = GetMethodSlow(environment, false, function, types, _oparams); needConvert = true; } if (targetop == null) { throw new Exception("函数不存在function:" + type.ToString() + "." + function); } } } if (cache != null) { cache.info = targetop; cache.slow = needConvert; } if (targetop == null) { throw new Exception("函数不存在function:" + type.ToString() + "." + function); } v.value = targetop.Invoke(object_this, _oparams.ToArray()); v.type = targetop.ReturnType; return(v); }
public CQ_Value StaticCall(CQ_Content content, string function, CQ_Value[] _params, MethodCache cache) { //TODO 这里应该优先匹配类型完全相同(含默认参),没有的话再匹配隐式 bool needConvert = false; List <object> _oparams = new List <object>(); List <Type> types = new List <Type>(); bool pIsEmpty = false; foreach (CQ_Value p in _params) { _oparams.Add(p.GetObject()); if (p.m_stype != null) { types.Add(typeof(object)); } else { if (p.m_type == null) { pIsEmpty = true; } types.Add(p.m_type); } } System.Reflection.MethodInfo methodInfo = null; if (!pIsEmpty) { methodInfo = type.GetMethod(function, types.ToArray()); } //if (methodInfo == null && type.BaseType != null)//加上父类型静态函数查找,典型的现象是 GameObject.Destory //{ // methodInfo = type.BaseType.GetMethod(function, types.ToArray()); //} if (methodInfo == null) { if (function[function.Length - 1] == '>')//这是一个临时的模板函数调用 { int sppos = function.IndexOf('<', 0); string tfunc = function.Substring(0, sppos); string strparam = function.Substring(sppos + 1, function.Length - sppos - 2); string[] sf = strparam.Split(','); //string tfunc = sf[0]; Type[] gtypes = new Type[sf.Length]; for (int i = 0; i < sf.Length; i++) { gtypes[i] = CQuark.AppDomain.GetTypeByKeyword(sf[i]).typeBridge; } methodInfo = FindMethod(type, tfunc, _params, gtypes); } if (methodInfo == null) { Type ptype = type.BaseType; while (ptype != null) { methodInfo = ptype.GetMethod(function, types.ToArray()); if (methodInfo != null) { break; } var t = CQuark.AppDomain.GetITypeByType(ptype); try { return(t._class.StaticCall(content, function, _params, cache)); } catch { } ptype = ptype.BaseType; } } } if (methodInfo == null) { methodInfo = GetMethodSlow(content, true, function, types, _oparams); needConvert = true; } if (methodInfo == null) { throw new Exception("函数不存在function:" + type.ToString() + "." + function); } if (cache != null) { cache.info = methodInfo; cache.needConvert = needConvert; } CQ_Value v = new CQ_Value(); v.SetObject(methodInfo.ReturnType, methodInfo.Invoke(null, _oparams.ToArray())); return(v); }
public CQ_Value MemberCall(CQ_Content content, object object_this, string function, CQ_Value[] _params, MethodCache cache) { //TODO 这里应该优先匹配类型完全相同(含默认参),没有的话再匹配隐式 bool needConvert = false; List <Type> types = new List <Type>(); List <object> _oparams = new List <object>(); bool pIsEmpty = false; foreach (CQ_Value p in _params) { _oparams.Add(p.GetObject()); if (p.m_stype != null) { types.Add(typeof(object)); } else { if (p.m_type == null) { pIsEmpty = true; } types.Add(p.m_type); } } System.Reflection.MethodInfo methodInfo = null; if (!pIsEmpty) { methodInfo = type.GetMethod(function, types.ToArray()); } CQ_Value v = new CQ_Value(); if (methodInfo == null) { if (function[function.Length - 1] == '>')//这是一个临时的模板函数调用 { int sppos = function.IndexOf('<', 0); string tfunc = function.Substring(0, sppos); string strparam = function.Substring(sppos + 1, function.Length - sppos - 2); string[] sf = strparam.Split(','); //string tfunc = sf[0]; Type[] gtypes = new Type[sf.Length]; for (int i = 0; i < sf.Length; i++) { gtypes[i] = CQuark.AppDomain.GetTypeByKeyword(sf[i]).typeBridge; } methodInfo = FindMethod(type, tfunc, _params, gtypes); var ps = methodInfo.GetParameters(); for (int i = 0; i < Math.Min(ps.Length, _oparams.Count); i++) { if (ps[i].ParameterType != _params[i].m_type) { _oparams[i] = _params[i].ConvertTo(ps[i].ParameterType); } } } else { if (!pIsEmpty) { foreach (var s in type.GetInterfaces()) { methodInfo = s.GetMethod(function, types.ToArray()); if (methodInfo != null) { break; } } } if (methodInfo == null) //因为有cache的存在,可以更慢更多的查找啦,哈哈哈哈 { methodInfo = GetMethodSlow(content, false, function, types, _oparams); needConvert = true; } if (methodInfo == null) { throw new Exception("函数不存在function:" + type.ToString() + "." + function); } } } if (cache != null) { cache.info = methodInfo; cache.needConvert = needConvert; } if (methodInfo == null) { throw new Exception("函数不存在function:" + type.ToString() + "." + function); } v.SetObject(methodInfo.ReturnType, methodInfo.Invoke(object_this, _oparams.ToArray())); return(v); }
public CQ_Value StaticCall(CQ_Content contentParent, string function, IList <CQ_Value> _params, MethodCache cache) { if (cache != null) { cache.cachefail = true; } NewStatic(); if (this.functions.ContainsKey(function)) { if (this.functions[function].bStatic == true) { CQ_Content content = new CQ_Content(); content.CallType = this; content.CallThis = null; #if CQUARK_DEBUG content.function = function; contentParent.InStack(content);//把这个上下文推给上层的上下文,这样如果崩溃是可以一层层找到原因的 #endif // int i = 0; for (int i = 0; i < functions[function]._paramtypes.Count; i++) //foreach (var p in this.functions[function]._params) { content.DefineAndSet(functions[function]._paramnames[i], functions[function]._paramtypes[i].typeBridge, _params[i].value); //i++; } //var value = this.functions[function].expr_runtime.ComputeValue(content); CQ_Value value = null; if (this.functions[function].expr_runtime != null) { value = this.functions[function].expr_runtime.ComputeValue(content); if (value != null) { value.breakBlock = 0; } } #if CQUARK_DEBUG contentParent.OutStack(content); #endif return(value); } } else if (this.members.ContainsKey(function)) { if (this.members[function].bStatic == true) { Delegate dele = this.staticMemberInstance[function].value as Delegate; if (dele != null) { CQ_Value value = new CQ_Value(); value.type = null; object[] objs = new object[_params.Count]; for (int i = 0; i < _params.Count; i++) { objs[i] = _params[i].value; } value.value = dele.DynamicInvoke(objs); if (value.value != null) { value.type = value.value.GetType(); } value.breakBlock = 0; return(value); } } } throw new NotImplementedException(); }
public CQ_Value MemberCall(CQ_Content contentParent, object object_this, string func, IList <CQ_Value> _params, MethodCache cache) { if (cache != null) { cache.cachefail = true; } Function funccache = null; if (this.functions.TryGetValue(func, out funccache)) { if (funccache.bStatic == false) { CQ_Content content = new CQ_Content(); content.CallType = this; content.CallThis = object_this as CQClassInstance; #if CQUARK_DEBUG content.function = func; contentParent.InStack(content);//把这个上下文推给上层的上下文,这样如果崩溃是可以一层层找到原因的 #endif for (int i = 0; i < funccache._paramtypes.Count; i++) { content.DefineAndSet(funccache._paramnames[i], funccache._paramtypes[i].typeBridge, _params[i].value); } CQ_Value value = null; var funcobj = funccache; if (this.bInterface) { content.CallType = (object_this as CQClassInstance).type; funcobj = (object_this as CQClassInstance).type.functions[func]; } if (funcobj.expr_runtime != null) { value = funcobj.expr_runtime.ComputeValue(content); if (value != null) { value.breakBlock = 0; } } #if CQUARK_DEBUG contentParent.OutStack(content); #endif return(value); } } else if (this.members.ContainsKey(func)) { if (this.members[func].bStatic == false) { Delegate dele = (object_this as CQClassInstance).member[func].value as Delegate; if (dele != null) { CQ_Value value = new CQ_Value(); value.type = null; object[] objs = new object[_params.Count]; for (int i = 0; i < _params.Count; i++) { objs[i] = _params[i].value; } value.value = dele.DynamicInvoke(objs); if (value.value != null) { value.type = value.value.GetType(); } value.breakBlock = 0; return(value); } } } throw new NotImplementedException(); }
public virtual CQ_Content.Value MemberCallCache(CQ_Content content, object object_this, IList <CQ_Content.Value> _params, MethodCache cache) { List <Type> types = new List <Type>(); List <object> _oparams = new List <object>(); foreach (var p in _params) { { _oparams.Add(p.value); } if ((SType)p.type != null) { types.Add(typeof(object)); } else { types.Add(p.type); } } var targetop = cache.info; CQ_Content.Value v = new CQ_Content.Value(); if (cache.slow) { var pp = targetop.GetParameters(); for (int i = 0; i < pp.Length; i++) { if (i >= _params.Count) { _oparams.Add(pp[i].DefaultValue); } else { if (pp[i].ParameterType != (Type)_params[i].type) { _oparams[i] = content.environment.GetType(_params[i].type).ConvertTo(content, _oparams[i], pp[i].ParameterType); } } } } v.value = targetop.Invoke(object_this, _oparams.ToArray()); v.type = targetop.ReturnType; return(v); }
public CQ_Value MemberCallCache(CQ_Content content, object object_this, IList <CQ_Value> _params, MethodCache cache) { throw new NotImplementedException(); }
//TODO 函数调用优先级需要重写。优先类型全等,再是隐式转换 public CQ_Value MemberCallCache(CQ_Content content, object object_this, IList <CQ_Value> _params, MethodCache cache) { System.Reflection.MethodInfo methodInfo = cache.info; CQ_Value v = new CQ_Value(); if (cache.needConvert) { List <object> _oparams = new List <object>(); foreach (var p in _params) { _oparams.Add(p.value); } var pp = methodInfo.GetParameters(); for (int i = 0; i < pp.Length; i++) { if (i >= _params.Count) { _oparams.Add(pp[i].DefaultValue); } else { if (pp[i].ParameterType != (Type)_params[i].type) { _oparams[i] = CQuark.AppDomain.GetType(_params[i].type).ConvertTo(_oparams[i], pp[i].ParameterType); } } } v.value = methodInfo.Invoke(object_this, _oparams.ToArray()); v.type = methodInfo.ReturnType; } else { object[] _oparams = new object[_params.Count]; for (int i = 0; i < _params.Count; i++) { _oparams[i] = _params[i].value; } v.value = methodInfo.Invoke(object_this, _oparams); v.type = methodInfo.ReturnType; } return(v); }