public CLS_Content.Value MemberCall(CLS_Content contentParent, object object_this, string func, BetterList <CLS_Content.Value> _params, bool isBaseCall = false) { SInstance callThis = object_this as SInstance; // 成员函数判断 Function fun; if (this.functions.TryGetValue(func, out fun)) { #if UNITY_EDITOR if (fun.bStatic) { throw new Exception("不能通过实例来调用静态函数: " + this.Name + "." + func); } #endif CLS_Content.Value value = null; SType callType = this; if (isBaseCall) { SType tempType = contentParent.CallType.BaseType; SType.Function tempFun; while (tempType != null) { if (tempType.functions.TryGetValue(func, out tempFun)) { if (tempFun.ownerType == null || tempFun.ownerType == tempType) { callType = tempType; fun = tempFun; break; } } tempType = tempType.BaseType; } } else { if (callType != callThis.type) { SType tempType = callThis.type; Function tempFun; while (tempType != null) { if (tempType.functions.TryGetValue(func, out tempFun)) { if (tempFun.ownerType == null || tempFun.ownerType == tempType) { callType = tempType; fun = tempFun; break; } } tempType = tempType.BaseType; } } else if (fun.ownerType != null && fun.ownerType != callType) { callType = fun.ownerType; } } if (fun.expr_runtime != null) { CLS_Content content = CLS_Content.NewContent(contentParent.environment); #if UNITY_EDITOR contentParent.InStackContent(content);//把这个上下文推给上层的上下文,这样如果崩溃是可以一层层找到原因的 #endif content.CallType = callType; content.CallThis = callThis; for (int i = 0, count = fun._paramtypes.Count; i < count; i++) { content.DefineAndSet(fun._paramnames[i], fun._paramtypes[i].type, _params[i].value); } value = fun.expr_runtime.ComputeValue(content); if (value != null) { value.breakBlock = 0; } #if UNITY_EDITOR contentParent.OutStackContent(content); #endif CLS_Content.PoolContent(content); } return(value); } // 委托判断 CLS_Content.Value mDeleVal; if (callThis.member.TryGetValue(func, out mDeleVal)) { Delegate dele = mDeleVal.value as Delegate; if (dele != null) { CLS_Content.Value value = new CLS_Content.Value(); value.type = null; object[] objs = CLS_Content.ParamObjsArray[_params.size]; for (int i = 0; i < _params.size; 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("未实现成员函数: " + this.Name + "." + func); }
public CLS_Content.Value StaticCall(CLS_Content contentParent, string func, BetterList<CLS_Content.Value> _params) { if (staticMemberContent == null) NewStatic(contentParent.environment); // 静态函数判断 Function fun; if (this.functions.TryGetValue(func, out fun)) { #if UNITY_EDITOR if (!fun.bStatic) throw new Exception("成员函数必须通过实例来调用: " + this.Name + "." + func); #endif CLS_Content.Value value = null; if (fun.expr_runtime != null) { CLS_Content content = CLS_Content.NewContent(contentParent.environment); #if UNITY_EDITOR contentParent.InStackContent(content);//把这个上下文推给上层的上下文,这样如果崩溃是可以一层层找到原因的 #endif content.CallType = this; content.CallThis = null; for (int i = 0, count = fun._paramtypes.Count; i < count; i++) { content.DefineAndSet(fun._paramnames[i], fun._paramtypes[i].type, _params[i].value); } value = fun.expr_runtime.ComputeValue(content); if (value != null) value.breakBlock = 0; #if UNITY_EDITOR contentParent.OutStackContent(content); #endif CLS_Content.PoolContent(content); } return value; } // 委托判断 CLS_Content.Value smDeleVal; if (this.staticMemberValues.TryGetValue(func, out smDeleVal)) { Delegate dele = smDeleVal.value as Delegate; if (dele != null) { CLS_Content.Value value = new CLS_Content.Value(); value.type = null; object[] objs = CLS_Content.ParamObjsArray[_params.size]; for (int i = 0; i < _params.size; 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("未实现静态函数: " + this.Name + "." + func); }
public CLS_Content.Value StaticCall(CLS_Content contentParent, string func, BetterList <CLS_Content.Value> _params) { if (staticMemberContent == null) { NewStatic(contentParent.environment); } // 静态函数判断 Function fun; if (this.functions.TryGetValue(func, out fun)) { #if UNITY_EDITOR if (!fun.bStatic) { throw new Exception("成员函数必须通过实例来调用: " + this.Name + "." + func); } #endif CLS_Content.Value value = null; if (fun.expr_runtime != null) { CLS_Content content = CLS_Content.NewContent(contentParent.environment); #if UNITY_EDITOR contentParent.InStackContent(content);//把这个上下文推给上层的上下文,这样如果崩溃是可以一层层找到原因的 #endif content.CallType = this; content.CallThis = null; for (int i = 0, count = fun._paramtypes.Count; i < count; i++) { content.DefineAndSet(fun._paramnames[i], fun._paramtypes[i].type, _params[i].value); } value = fun.expr_runtime.ComputeValue(content); if (value != null) { value.breakBlock = 0; } #if UNITY_EDITOR contentParent.OutStackContent(content); #endif CLS_Content.PoolContent(content); } return(value); } // 委托判断 CLS_Content.Value smDeleVal; if (this.staticMemberValues.TryGetValue(func, out smDeleVal)) { Delegate dele = smDeleVal.value as Delegate; if (dele != null) { CLS_Content.Value value = new CLS_Content.Value(); value.type = null; object[] objs = CLS_Content.ParamObjsArray[_params.size]; for (int i = 0; i < _params.size; 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("未实现静态函数: " + this.Name + "." + func); }
public CLS_Content.Value MemberCall(CLS_Content contentParent, object object_this, string func, BetterList<CLS_Content.Value> _params, bool isBaseCall = false) { SInstance callThis = object_this as SInstance; // 成员函数判断 Function fun; if (this.functions.TryGetValue(func, out fun)) { #if UNITY_EDITOR if (fun.bStatic) throw new Exception("不能通过实例来调用静态函数: " + this.Name + "." + func); #endif CLS_Content.Value value = null; SType callType = this; if (isBaseCall) { SType tempType = contentParent.CallType.BaseType; SType.Function tempFun; while (tempType != null) { if (tempType.functions.TryGetValue(func, out tempFun)) { if (tempFun.ownerType == null || tempFun.ownerType == tempType) { callType = tempType; fun = tempFun; break; } } tempType = tempType.BaseType; } } else { if (callType != callThis.type) { SType tempType = callThis.type; Function tempFun; while (tempType != null) { if (tempType.functions.TryGetValue(func, out tempFun)) { if (tempFun.ownerType == null || tempFun.ownerType == tempType) { callType = tempType; fun = tempFun; break; } } tempType = tempType.BaseType; } } else if (fun.ownerType != null && fun.ownerType != callType) { callType = fun.ownerType; } } if (fun.expr_runtime != null) { CLS_Content content = CLS_Content.NewContent(contentParent.environment); #if UNITY_EDITOR contentParent.InStackContent(content);//把这个上下文推给上层的上下文,这样如果崩溃是可以一层层找到原因的 #endif content.CallType = callType; content.CallThis = callThis; for (int i = 0, count = fun._paramtypes.Count; i < count; i++) { content.DefineAndSet(fun._paramnames[i], fun._paramtypes[i].type, _params[i].value); } value = fun.expr_runtime.ComputeValue(content); if (value != null) value.breakBlock = 0; #if UNITY_EDITOR contentParent.OutStackContent(content); #endif CLS_Content.PoolContent(content); } return value; } // 委托判断 CLS_Content.Value mDeleVal; if (callThis.member.TryGetValue(func, out mDeleVal)) { Delegate dele = mDeleVal.value as Delegate; if (dele != null) { CLS_Content.Value value = new CLS_Content.Value(); value.type = null; object[] objs = CLS_Content.ParamObjsArray[_params.size]; for (int i = 0; i < _params.size; 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("未实现成员函数: " + this.Name + "." + func); }