Exemple #1
0
        public IMethod GetMethodT(string funcname, MethodParamList ttypes, MethodParamList types)
        {
            //这个实现还不完全
            //有个别重构下,判定比这个要复杂
            System.Reflection.MethodInfo _method = null;
            var ms = TypeForSystem.GetMethods();
            foreach (var m in ms)
            {
                if (m.Name == funcname && m.IsGenericMethodDefinition)
                {
                    var ts = m.GetGenericArguments();
                    var ps = m.GetParameters();
                    if (ts.Length == ttypes.Count && ps.Length == types.Count)
                    {
                        _method = m;
                        break;
                    }

                }
            }

            // _method = TypeForSystem.GetMethod(funcname, types.ToArraySystem());

            return new Method_Common_System(this, _method.MakeGenericMethod(ttypes.ToArraySystem()));
        }
Exemple #2
0
 public MethodCreatePrimitive(ICLRSharp_Environment env, ICLRType type)
 {
     this.env           = env;
     this.DeclaringType = type;
     this.ReturnType    = env.GetType(typeof(GameObject));
     ParamList          = MethodParamList.Make(env.GetType(typeof(PrimitiveType)));
 }
    void Init(ICLRSharp_Environment env, CLRSharp_Instance instance)
    {
        mRuntimeObject = instance;

        var type = instance.type;

        mGetDataModel = type.GetMethod("GetDataModel",
                                       new MethodParamList(new[] { env.GetType(typeof(string)) }));

        mClose = type.GetMethod("Close",
                                MethodParamList.constEmpty());

        mCleanUp = type.GetMethod("CleanUp",
                                  MethodParamList.constEmpty());

        mRefreshDate = type.GetMethod("RefreshData",
                                      new MethodParamList(new[] { env.GetType(typeof(UIInitArguments)) }));

        mGetState = type.GetMethod("get_State", MethodParamList.constEmpty());
        mSetState = type.GetMethod("set_State", new MethodParamList(new[] { env.GetType(typeof(FrameState)) }));

        mTick          = type.GetMethod("Tick", new MethodParamList(MethodParamList.constEmpty()));
        mOnChangeScene = type.GetMethod("OnChangeScene", new MethodParamList(new[] { env.GetType(typeof(int)) }));

        mCallFromMethod = type.GetMethod("CallFromOtherClass",
                                         new MethodParamList(new[] { env.GetType(typeof(string)), env.GetType(typeof(object[])) }));

        mOnShow = type.GetMethod("OnShow",
                                 MethodParamList.constEmpty());
    }
Exemple #4
0
 public MethodFind(ICLRSharp_Environment env, ICLRType type)
 {
     this.env           = env;
     this.DeclaringType = type;
     this.ReturnType    = env.GetType(typeof(GameObject));
     ParamList          = MethodParamList.Make(env.GetType(typeof(string)));
 }
Exemple #5
0
        public void Init(CLRSharp.ICLRSharp_Environment env)
        {
            if (bInited) return;
            if(bodyNative.HasVariables)
            {
                typelistForLoc = new MethodParamList(env, bodyNative.Variables);
 
            }
        }
 public void Notify(eMonoMessageType mType, params object[] data)
 {
     callBack.Notify(mType, data);
     if (method_notify == null)
     {
         method_notify = class_type.GetMethod("Notify", MethodParamList.Make(LSharpModule.env.GetType(typeof(eMonoMessageType))));
     }
     method_notify.Invoke(ThreadContext.activeContext, inst, new object[] { mType });
 }
    public ScriptableController(ICLRSharp_Environment env, ICLRType type, string name)
    {
        var method = type.GetMethod(".ctor", MethodParamList.constEmpty());

        mRuntimeObject = method.Invoke(ThreadContext.activeContext, null, null);

        mName = name;

        Init(env, (CLRSharp_Instance)mRuntimeObject);
    }
Exemple #8
0
 public IMethod GetMethod(string funcname, MethodParamList types)
 {
     if (funcname == ".ctor")
     {
         var con = TypeForSystem.GetConstructor(types.ToArraySystem());
         return new Method_Common_System(this, con);
     }
     var method = TypeForSystem.GetMethod(funcname, types.ToArraySystem());
     return new Method_Common_System(this, method);
 }
        private void LoadModule(string name)
        {
            string path  = name + ".dll";
            string path2 = name + ".pdb";

            byte[]       bytes     = Resources.Load <TextAsset>(path).bytes;
            byte[]       bytes2    = Resources.Load <TextAsset>(path2).bytes;
            MemoryStream dllStream = new MemoryStream(bytes);
            MemoryStream pdbStream = new MemoryStream(bytes2);

            try
            {
                this.mRunEnv.LoadModule(dllStream, pdbStream, new PdbReaderProvider());
            }
            catch (Exception var_6_59)
            {
            }
            this.mRunEnv.GetType(typeof(Dictionary <int, string>));
            this.mRunEnv.GetType(typeof(Dictionary <ShopType, UIToggle>));
            this.mRunEnv.GetType(typeof(Dictionary <int, CLRSharp_Instance>));
            this.mRunEnv.GetType(typeof(Dictionary <int, Action>));
            this.mRunEnv.GetType(typeof(Dictionary <short, Action>));
            this.mRunEnv.GetType(typeof(LinkedList <int>));
            this.mRunEnv.GetType(typeof(int[, ]));
            this.mRunEnv.GetType(typeof(List <Vector3>));
            this.mRunEnv.GetType(typeof(List <ShopData>));
            this.mRunEnv.GetType(typeof(List <EquipmentInfoData>));
            this.mRunEnv.GetType(typeof(List <HeroInfoData>));
            this.mRunEnv.GetType(typeof(List <SummSkinData>));
            this.mRunEnv.GetType(typeof(List <int>[]));
            this.mRunEnv.GetType(typeof(List <List <int> >));
            this.mRunEnv.GetType(typeof(List <List <List <int> > >));
            this.mRunEnv.GetType(typeof(Vector3[]));
            this.mRunEnv.GetType(typeof(IEnumerable <int>));
            Delegate_Binder.RegBind(typeof(Action <int>), new Delegate_BindTool <int>());
            Delegate_Binder.RegBind(typeof(Action <bool, ShopData>), new Delegate_BindTool_Ret <bool, ShopData>());
            Delegate_Binder.RegBind(typeof(Action <bool, EquipmentInfoData>), new Delegate_BindTool_Ret <bool, EquipmentInfoData>());
            Delegate_Binder.RegBind(typeof(Action <bool, SummSkinData>), new Delegate_BindTool_Ret <bool, SummSkinData>());
            Delegate_Binder.RegBind(typeof(Action <int, int>), new Delegate_BindTool <int, int>());
            Delegate_Binder.RegBind(typeof(Action <int, int, int>), new Delegate_BindTool <int, int, int>());
            Delegate_Binder.RegBind(typeof(Func <int, int, int>), new Delegate_BindTool_Ret <int, int, int>());
            Delegate_Binder.RegBind(typeof(Action <int, string>), new Delegate_BindTool <int, string>());
            Delegate_Binder.RegBind(typeof(Action <string>), new Delegate_BindTool <string>());
            Delegate_Binder.RegBind(typeof(Action <bool>), new Delegate_BindTool <bool>());
            this.mRunEnv.RegCrossBind(new IViewCrossBind());
            if (ThreadContext.activeContext == null)
            {
                this.mContext = new ThreadContext(this.mRunEnv, 2);
            }
            ICLRType type   = this.mRunEnv.GetType("GUIScript.ShellClass");
            IMethod  method = type.GetMethod("Initialize", MethodParamList.constEmpty());

            method.Invoke(this.mContext, null, null);
        }
Exemple #10
0
 public Method_Common_System(ICLRType DeclaringType, System.Reflection.MethodBase method)
 {
     if (method == null)
         throw new Exception("not allow null method.");
     method_System = method;
     this.DeclaringType = DeclaringType;
     if (method is System.Reflection.MethodInfo)
     {
         System.Reflection.MethodInfo info = method as System.Reflection.MethodInfo;
         ReturnType = DeclaringType.env.GetType(info.ReturnType);
     }
     ParamList = new MethodParamList(DeclaringType.env, method);
 }
        public void SetShopType(ShopType type)
        {
            ICLRType type2  = this.mRunEnv.GetType("GUIScript.ShopCtrl");
            IMethod  method = type2.GetMethod("SetType", MethodParamList.Make(new ICLRType[]
            {
                this.mContext.environment.GetType(typeof(ShopType))
            }));

            method.Invoke(this.mContext, null, new object[]
            {
                type
            });
        }
        public void OpenWindow(WindowID winId)
        {
            ICLRType type   = this.mRunEnv.GetType("GUIScript.ShellClass");
            IMethod  method = type.GetMethod("OpenWindow", MethodParamList.Make(new ICLRType[]
            {
                this.mContext.environment.GetType(typeof(WindowID))
            }));

            method.Invoke(this.mContext, null, new object[]
            {
                winId
            });
        }
 private void Init()
 {
     if (class_name_L == "")
     {
         class_name_L = default_class_name;
         Debug.LogWarning("传入的L#类名为空,将使用L#基类进行绑定!");
     }
     class_type = LSharpModule.env.GetType(class_name_L);
     if (inst == null)
     {
         IMethod ctor = class_type.GetMethod(".ctor", MethodParamList.Make(LSharpModule.env.GetType(typeof(GameObject))));
         inst = ctor.Invoke(ThreadContext.activeContext, null, new object[] { gameObject });
     }
 }
    public override IMethod GetMethod(string funcname, MethodParamList types)
    {
        int typehash = types.GetHashCode();

        foreach (var f in methodExt)
        {
            if (f.Name == funcname && f.ParamList.GetHashCode() == typehash)
            {
                return(f);
            }
        }

        return(base.GetMethod(funcname, types));
    }
Exemple #15
0
    public void InvokeScriptMethod(byte[] datas)
    {
        var    ot     = env.GetType("FlyModel.Proto.ClientMethod") as Type_Common_CLRSharp;
        int    opcode = BitConverter.ToInt32(datas, 0);
        string method = "";

        foreach (var f in ot.type_CLRSharp.Fields)
        {
            if (f.HasConstant && (int)f.Constant == opcode)
            {
                method = f.Name;
                break;
            }
        }
        Debug.Log("try invoke method " + method);
        var ms = commandType.GetMethods(method);

        if (ms.Length > 0)
        {
            var m = ms[0];
            if (m.Name == method)
            {
                if (m.ParamList.Count > 0)
                {
                    var pt     = m.ParamList[0];
                    var po     = new CLRSharp_Instance(pt as ICLRType_Sharp);
                    var ptctor = pt.GetMethod(".ctor", MethodParamList.constEmpty()); //取得构造函数
                    ptctor.Invoke(context, po, null);                                 //执行构造函数

                    paramArray[0] = po;
                    var ts = pt.GetMethod("ReadFrom", MethodParamList.Make(
                                              HotFixScript.env.GetType(typeof(byte[])),
                                              HotFixScript.env.GetType(typeof(int)),
                                              HotFixScript.env.GetType(typeof(int))
                                              ));
                    ts.Invoke(context, po, new object[] { datas, 4, datas.Length - 4 });

                    m.Invoke(context, null, paramArray);
                }
            }
        }
        else
        {
            Debug.LogError("Command " + method + " not found");
        }
    }
Exemple #16
0
 public static MainUIThread GetInstance()
 {
     if (ui == null)
     {
         ui = GameObject.FindObjectOfType(typeof(MainUIThread)) as MainUIThread;
         if (!ui)
         {
             GameObject obj = new GameObject("_MainUIThread");
             GameObject.DontDestroyOnLoad(obj);
             ui = obj.AddComponent <MainUIThread>();
             ICLRType program           = LSharpModule.env.GetType("GameUI.Program");
             IMethod  main              = program.GetMethod("GetInstance", MethodParamList.constEmpty());
             object   program_object    = main.Invoke(ThreadContext.activeContext, null, null);
             IMethod  method_AddNotifys = program.GetMethod("AddNotifys", MethodParamList.Make(LSharpModule.env.GetType(typeof(MainUIThread))));
             method_AddNotifys.Invoke(ThreadContext.activeContext, program_object, new object[] { ui });
         }
     }
     return(ui);
 }
Exemple #17
0
    public override IMethod GetMethod(string funcname, MethodParamList types)
    {
        int typehash = types.GetHashCode();

        {
            var __list1      = methodExt;
            var __listCount1 = __list1.Count;
            for (int __i1 = 0; __i1 < __listCount1; ++__i1)
            {
                var f = __list1[__i1];
                {
                    if (f.Name == funcname && f.ParamList.GetHashCode() == typehash)
                    {
                        return(f);
                    }
                }
            }
        }
        return(base.GetMethod(funcname, types));
    }
Exemple #18
0
            /// <summary>
            /// 构造函数只是为了把脚本实例传进来,用其他的形式也可以
            /// </summary>
            /// <param name="inst"></param>
            public Base_IMyType(CLRSharp.CLRSharp_Instance inst)
            {
                var context = ThreadContext.activeContext;

                this.inst = inst;
                //这里先把需要的脚本方法记下来,只是为了后面调用起来方便
                var ms = this.inst.type.GetMethodNames();

                foreach (string name in ms)
                {
                    if (name.Contains("GetName"))
                    {
                        _GetName = this.inst.type.GetMethod(name, MethodParamList.constEmpty());
                    }
                    if (name.Contains("GetDesc"))
                    {
                        _GetDesc = this.inst.type.GetMethod(name, MethodParamList.constEmpty());
                    }
                    if (name.Contains("SetName"))
                    {
                        _SetName = this.inst.type.GetMethod(name, MethodParamList.Make(context.environment.GetType(typeof(string))));
                    }
                }
            }
Exemple #19
0
        public IMethod GetMethod(object token)
        {
            IMethod __method = null;
            if (methodCache.TryGetValue(token.GetHashCode(), out __method))
            {
                return __method;
            }
            //??Mono.Cecil.ModuleDefinition module = null;
            string methodname = null;
            string typename = null;
            MethodParamList genlist = null;
            MethodParamList list = null;
            if (token is Mono.Cecil.MethodReference)
            {
                Mono.Cecil.MethodReference _ref = (token as Mono.Cecil.MethodReference);
                //??module = _ref.Module;
                methodname = _ref.Name;
                typename = _ref.DeclaringType.FullName;
                list = new MethodParamList(environment, _ref);
                if (_ref.IsGenericInstance)
                {
                    Mono.Cecil.GenericInstanceMethod gmethod = _ref as Mono.Cecil.GenericInstanceMethod;
                    genlist = new MethodParamList(environment, gmethod);

                }
            }
            else if (token is Mono.Cecil.MethodDefinition)
            {
                Mono.Cecil.MethodDefinition _def = token as Mono.Cecil.MethodDefinition;
                //??module = _def.Module;
                methodname = _def.Name;
                typename = _def.DeclaringType.FullName;
                list = new MethodParamList(environment, _def);
                if (_def.IsGenericInstance)
                {
                    throw new NotImplementedException();
                    //Mono.Cecil.GenericInstanceMethod gmethod = _def as Mono.Cecil.GenericInstanceMethod;
                    //genlist = new MethodParamList(environment, gmethod);
                }
            }
            else
            {
                throw new NotImplementedException();
            }
            var typesys = GetType(typename);
            if (typesys == null)
                throw new Exception("type can't find:" + typename);

            IMethod _method = null;
            if (genlist != null)
            {
                _method = typesys.GetMethodT(methodname, genlist, list);
            }
            else
            {
                _method = typesys.GetMethod(methodname, list);
            }
            methodCache[token.GetHashCode()] = _method;
            return _method;
        }
Exemple #20
0
        public Method_Common_CLRSharp(Type_Common_CLRSharp type, Mono.Cecil.MethodDefinition method)
        {
            if (method == null)
                throw new Exception("not allow null method.");
            this._DeclaringType = type;

            method_CLRSharp = method;
            ReturnType = type.env.GetType(method.ReturnType.FullName);

            ParamList = new MethodParamList(type.env, method);
        }
Exemple #21
0
 public IMethod GetMethodT(string funcname, MethodParamList ttypes, MethodParamList types)
 {
     return null;
 }
Exemple #22
0
        public IMethod GetMethodOverloaded(string funcname, MethodParamList types)
        {
            Mono.Cecil.MethodDefinition minDistanceMethod = null;
            List<int> minDistanceParameters = null;

            if (type_CLRSharp.HasMethods)
            {
                foreach (var m in type_CLRSharp.Methods)
                {
                    if (m.Name != funcname) continue;
                    if ((types == null) ? !m.HasParameters : (m.Parameters.Count == types.Count))
                    {
                        bool match = true;
                        List<int> currentDistanceParameters = new List<int>();

                        for (int i = 0; i < ((types == null) ? 0 : types.Count); i++)
                        {
                            var envtype = env.GetType(m.Parameters[i].ParameterType.FullName);
                            if (envtype.IsEnum())
                            {
                                if (envtype.TypeForSystem != types[i].TypeForSystem)
                                {
                                    match = false;
                                    break;
                                }
                            }
                            else
                            {
                                if (!(envtype.TypeForSystem.IsAssignableFrom(types[i].TypeForSystem)))
                                {
                                    match = false;
                                    break;
                                }

                                currentDistanceParameters.Add(GetInheritanceDistance(envtype.TypeForSystem, types[i].TypeForSystem));

                            }
                        }
                        if (match)
                        {
                            if (minDistanceParameters == null)
                            {
                                minDistanceMethod = m;
                                minDistanceParameters = currentDistanceParameters;
                            }
                            else
                            {
                                for (int i = 0; i < currentDistanceParameters.Count; i++)
                                {
                                    if (currentDistanceParameters[i] < minDistanceParameters[i])
                                    {
                                        minDistanceMethod = m;
                                        minDistanceParameters = currentDistanceParameters;
                                    }
                                }
                            }

                        }
                    }
                }

                if (minDistanceMethod == null)
                {
                    return null;
                }
                return new Method_Common_CLRSharp(this, minDistanceMethod);
            }

            return null;
        }
Exemple #23
0
 public IMethod GetMethod(string funcname, MethodParamList types)
 {
     if (type_CLRSharp.HasMethods)
     {
         foreach (var m in type_CLRSharp.Methods)
         {
             if (m.Name != funcname) continue;
             if ((types == null) ? !m.HasParameters : (m.Parameters.Count == types.Count))
             {
                 bool match = true;
                 for (int i = 0; i < ((types == null) ? 0 : types.Count); i++)
                 {
                     var envtype = env.GetType(m.Parameters[i].ParameterType.FullName);
                     if (envtype.IsEnum())
                     {
                         if (envtype.TypeForSystem != types[i].TypeForSystem)
                         {
                             match = false;
                             break;
                         }
                     }
                     else
                     {
                         if (envtype != types[i])
                         {
                             match = false;
                             break;
                         }
                     }
                 }
                 if (match)
                     return new Method_Common_CLRSharp(this, m);
             }
         }
     }
     return null;
 }
Exemple #24
0
 /// <summary>
 /// 实例化L#类
 /// </summary>
 /// <param name="clrType">L#类</param>
 /// <param name="paramTypes">L#类构造函数的参数类型</param>
 /// <param name="param">L#类构造函数的参数</param>
 /// <returns>实例</returns>
 public object creatCLRInstance(ICLRType clrType, MethodParamList paramTypes = null, object[] param = null)
 {
     return Invoke(clrType, CLRSharpConstant.METHOD_CTOR, null, paramTypes, param);
 }
Exemple #25
0
 /// <summary>
 /// 获取方法,可以获取继承的方法
 /// </summary>
 /// <param name="clrType">类型</param>
 /// <param name="funName">方法名</param>
 /// <param name="paramTypes">参数类型</param>
 /// <returns></returns>
 public IMethod GetMethod(ICLRType clrType, string funName, MethodParamList paramTypes = null)
 {
     if (paramTypes == null)
     {
         paramTypes = MethodParamList.constEmpty();
     }
     IMethod fun = clrType.GetMethod(funName, paramTypes);
     if (fun == null)
     {
         Type_Common_CLRSharp subType = clrType as Type_Common_CLRSharp;
         if (subType != null && subType.BaseType != null)
         {
             fun = GetMethod(subType.BaseType, funName, paramTypes);
         }
     }
     return fun;
 }
Exemple #26
0
 /// <summary>
 /// 调用L#的函数
 /// </summary>
 /// <param name="clrType">L#类</param>
 /// <param name="methodName">L#方法名称</param>
 /// <param name="methodName">L#类的实例,如果为null,则调用的是静态函数</param>
 /// <param name="paramTypes">参数类型数组</param>
 /// <param name="param">参数数组</param>
 /// <returns>返回值</returns>
 public object Invoke(ICLRType clrType, string methodName,
     object inst = null, MethodParamList paramTypes = null, object[] param = null)
 {
     if (paramTypes == null)
     {
         paramTypes = MethodParamList.constEmpty();
     }
     IMethod method = GetMethod(clrType, methodName, paramTypes);
     return method.Invoke(context, inst, param);
 }
Exemple #27
0
 /// <summary>
 /// 执行L#对应的方法
 /// </summary>
 /// <param name="funName">方法</param>
 /// <param name="paramTypes">参数类型列表</param>
 /// <param name="param">参数列表</param>
 protected void doFun(GMBEventMethod method, MethodParamList paramTypes = null, object[] param = null)
 {
     if (funDic == null)
     {
         init();
     }
     if (!funDic.ContainsKey(method))
     {
         funDic.Add(method, GMBManager.instance.getGMBEventMethod(clrInst.type, method, paramTypes));
     }
     if (funDic[method] != null)
     {
         funDic[method].Invoke(CLRSharpManager.instance.context, clrInst, param);
     }
 }
            public Base_IMyType(CLRSharp_Instance inst)
            {
                ThreadContext activeContext = ThreadContext.activeContext;

                this.inst = inst;
                string[] methodNames = this.inst.type.GetMethodNames();
                string[] array       = methodNames;
                for (int i = 0; i < array.Length; i++)
                {
                    string text = array[i];
                    if (text.Contains("get_transform"))
                    {
                        this._get_transform = this.inst.type.GetMethod(text, MethodParamList.constEmpty());
                    }
                    if (text.Contains("get_gameObject"))
                    {
                        this._get_gameobject = this.inst.type.GetMethod(text, MethodParamList.constEmpty());
                    }
                    if (text.Contains("get_WinResCfg"))
                    {
                        this._get_WinResCfg = this.inst.type.GetMethod(text, MethodParamList.constEmpty());
                    }
                    if (text.Contains("get_uiWindow"))
                    {
                        this._get_uiWindow = this.inst.type.GetMethod(text, MethodParamList.constEmpty());
                    }
                    if (text.Contains("set_uiWindow"))
                    {
                        this._set_uiWindow = this.inst.type.GetMethod(text, MethodParamList.Make(new ICLRType[]
                        {
                            activeContext.environment.GetType(typeof(TUIWindow))
                        }));
                    }
                    if (text.Contains("Init"))
                    {
                        this._Init = this.inst.type.GetMethod(text, MethodParamList.constEmpty());
                    }
                    if (text.Contains("Destroy"))
                    {
                        this._Destroy = this.inst.type.GetMethod(text, MethodParamList.constEmpty());
                    }
                    if (text.Contains("HandleAfterOpenView"))
                    {
                        this._HandleAfterOpenView = this.inst.type.GetMethod(text, MethodParamList.constEmpty());
                    }
                    if (text.Contains("HandleBeforeCloseView"))
                    {
                        this._HandleBeforeCloseView = this.inst.type.GetMethod(text, MethodParamList.constEmpty());
                    }
                    if (text.Contains("RegisterUpdateHandler"))
                    {
                        this._RegisterUpdateHandler = this.inst.type.GetMethod(text, MethodParamList.constEmpty());
                    }
                    if (text.Contains("CancelUpdateHandler"))
                    {
                        this._CancelUpdateHandler = this.inst.type.GetMethod(text, MethodParamList.constEmpty());
                    }
                    if (text.Contains("RefreshUI"))
                    {
                        this._RefreshUI = this.inst.type.GetMethod(text, MethodParamList.constEmpty());
                    }
                    if (text.Contains("DataUpdated"))
                    {
                        this._DataUpdated = this.inst.type.GetMethod(text, MethodParamList.Make(new ICLRType[]
                        {
                            activeContext.environment.GetType(typeof(object))
                        }));
                    }
                    if (text.Contains("Initialize"))
                    {
                        this._Initialize = this.inst.type.GetMethod(text, MethodParamList.constEmpty());
                    }
                    if (text.Contains("HandleHideEvent"))
                    {
                        this._HandleHideEvent = this.inst.type.GetMethod(text, MethodParamList.constEmpty());
                    }
                    if (text.Contains("HandleDestroyEvent"))
                    {
                        this._HandleDestroyEvent = this.inst.type.GetMethod(text, MethodParamList.constEmpty());
                    }
                }
            }
Exemple #29
0
        public void Init(CLRSharp.ICLRSharp_Environment env)
        {
            if (bInited) return;
            if (bodyNative.HasVariables)
            {
                typelistForLoc = new MethodParamList(env, bodyNative.Variables);
            }
            for (int i = 0; i < bodyNative.Instructions.Count; i++)
            {
                var code = bodyNative.Instructions[i];
                OpCode c = new OpCode();
                c.code = (CodeEx)(int)code.OpCode.Code;
                c.addr = code.Offset;
                if (code.SequencePoint != null)
                {
                    if (debugDoc == null)
                        debugDoc = new Dictionary<string, int>();
                    if (debugDoc.ContainsKey(code.SequencePoint.Document.Url) == false)
                    {
                        debugDoc.Add(code.SequencePoint.Document.Url, code.SequencePoint.StartLine);
                    }
                    c.debugline = code.SequencePoint.StartLine;

                }

                this.opCodes.Add(c);
                addr[c.addr] = i; ;
            }
            var context = ThreadContext.activeContext;
            for (int i = 0; i < bodyNative.Instructions.Count; i++)
            {
                OpCode c = opCodes[i];
                var code = bodyNative.Instructions[i];
                c.InitToken(context, this, code.Operand);
            }
            bInited = true;
        }
Exemple #30
0
        //============================================================
        /// <summary>
        /// 获取GMonoBehaviour事件的方法
        /// </summary>
        /// <param name="clrType"></param>
        /// <param name="method"></param>
        /// <param name="paramTypes"></param>
        /// <returns></returns>
        public IMethod getGMBEventMethod(ICLRType clrType, GMBEventMethod method, MethodParamList paramTypes = null)
        {
            if (paramTypes == null)
            {
                paramTypes = MethodParamList.constEmpty();
            }

            if (clrType == null || clrType.FullName == "Freamwork.GMB")
            {
                return null;
            }

            Dictionary<string, IMethod> methodDic;
            if (!dic.ContainsKey(clrType.FullName))
            {
                methodDic = new Dictionary<string, IMethod>();
                dic.Add(clrType.FullName, methodDic);
            }
            else
            {
                methodDic = dic[clrType.FullName];
            }

            string methodName = totalMethodNameList[(int)method];
            if (methodDic.ContainsKey(methodName))
            {
                return methodDic[methodName];
            }

            IMethod eventMethod = clrType.GetMethod(methodName, paramTypes);
            if (eventMethod == null)
            {
                Type_Common_CLRSharp type = clrType as Type_Common_CLRSharp;
                if (type != null)
                {
                    eventMethod = getGMBEventMethod(type.BaseType, method, paramTypes);
                }
            }
            methodDic[methodName] = eventMethod;
            return eventMethod;
        }