Example #1
0
        public Delegate CreateDelegate(ICLS_Environment env, DeleFunction delefunc)
        {
            DeleFunction _func = delefunc;

            NonVoidDelegate dele = delegate() {
                var func = _func.calltype.functions[_func.function];
                if (func.expr_runtime != null)
                {
                    CLS_Content content = new CLS_Content(env);

                    content.DepthAdd();
                    content.CallThis = _func.callthis;
                    content.CallType = _func.calltype;
                    content.function = _func.function;

                    CLS_Content.Value retValue = func.expr_runtime.ComputeValue(content);
                    content.DepthRemove();
                    return((ReturnType)retValue.value);
                }
                return(default(ReturnType));
            };

            Delegate d = dele;

            return(Delegate.CreateDelegate(this.type, d.Target, d.Method));
        }
Example #2
0
        public Delegate CreateDelegate(ICLS_Environment env, DeleFunction delefunc)
        {
            CLS_Content        content = new CLS_Content(env);
            DeleFunction       _func   = delefunc;
            Action <T, T1, T2> dele    = (T param0, T1 param1, T2 param2) =>
            {
                content.DepthAdd();
                content.CallThis = _func.callthis;
                content.CallType = _func.calltype;
                content.function = _func.function;
                var func = _func.calltype.functions[_func.function];

                content.DefineAndSet(func._paramnames[0], func._paramtypes[0].type, param0);
                content.DefineAndSet(func._paramnames[1], func._paramtypes[1].type, param1);
                content.DefineAndSet(func._paramnames[2], func._paramtypes[2].type, param2);

                func.expr_runtime.ComputeValue(content);
                content.DepthRemove();
            };
            Delegate d = dele as Delegate;

            if ((Type)this.type != typeof(Action <T, T1, T2>))
            {
                return(Delegate.CreateDelegate(this.type, d.Target, d.Method));
            }
            else
            {
                return(dele);
            }
        }
        public Delegate CreateDelegate(ICLS_Environment env, DeleFunction delefunc)
        {
            DeleFunction _func = delefunc;
            Delegate     _dele = delefunc.cacheFunction(null);

            if (_dele != null)
            {
                return(_dele);
            }
            NonVoidDelegate dele = delegate(T param0, T1 param1, T2 param2) {
                var func = _func.calltype.functions[_func.function];
                if (func.expr_runtime != null)
                {
                    CLS_Content content = new CLS_Content(env);

                    content.DepthAdd();
                    content.CallThis = _func.callthis;
                    content.CallType = _func.calltype;
                    content.function = _func.function;

                    content.DefineAndSet(func._paramnames[0], func._paramtypes[0].type, param0);
                    content.DefineAndSet(func._paramnames[1], func._paramtypes[1].type, param1);
                    content.DefineAndSet(func._paramnames[2], func._paramtypes[2].type, param2);

                    CLS_Content.Value retValue = func.expr_runtime.ComputeValue(content);
                    content.DepthRemove();

                    return((ReturnType)retValue.value);
                }
                return(default(ReturnType));
            };

            _dele = Delegate.CreateDelegate(this.type, dele.Target, dele.Method);
            return(delefunc.cacheFunction(_dele));
        }
        public Delegate CreateDelegate(ICLS_Environment env, DeleFunction delefunc)
        {
            CLS_Content content = new CLS_Content(env);
            DeleFunction _func = delefunc;
            Action dele = () =>
            {

                content.DepthAdd();
                content.CallThis = _func.callthis;
                content.CallType = _func.calltype;
                content.function = _func.function;
                var func = _func.calltype.functions[_func.function];

                //content.DefineAndSet(function._paramnames[0], function._paramtypes[0].type, param0);

                func.expr_runtime.ComputeValue(content);
                content.DepthRemove();
            };
            Delegate d = dele as Delegate;
            if ((Type)this.type != typeof(Action))
            {
                return Delegate.CreateDelegate(this.type, d.Target, d.Method);
            }
            else
            {
                return dele;
            }
        }
        public CLS_Content.Value ComputeValue(CLS_Content content)
        {
            content.InStack(this);
            BetterList <CLS_Content.Value> _params = CLS_Content.NewParamList();

            for (int i = 0, count = listParam.Count; i < count; i++)
            {
                _params.Add(listParam[i].ComputeValue(content));
            }

            CLS_Content.Value retVal;
            SType.Function    fun;

            if (content.CallType != null && content.CallType.functions.TryGetValue(funcname, out fun))
            {
                if (fun.bStatic)
                {
                    retVal = content.CallType.StaticCall(content, funcname, _params);
                }
                else
                {
                    retVal = content.CallType.MemberCall(content, content.CallThis, funcname, _params);
                }
            }
            else
            {
                retVal = content.Get(funcname);
                Delegate sysDele = retVal.value as Delegate;
                if (sysDele != null)
                {
                    object[] args = CLS_Content.ParamObjsArray[_params.size];
                    for (int i = 0; i < _params.size; i++)
                    {
                        args[i] = _params[i].value;
                    }
                    retVal       = new CLS_Content.Value();
                    retVal.value = sysDele.DynamicInvoke(args);
                    if (retVal.value != null)
                    {
                        retVal.type = retVal.value.GetType();
                    }
                }
                else
                {
                    DeleFunction csleDele = retVal.value as DeleFunction;
                    if (csleDele.callthis != null)
                    {
                        retVal = csleDele.calltype.MemberCall(content, csleDele.callthis, csleDele.function, _params);
                    }
                    else
                    {
                        retVal = csleDele.calltype.StaticCall(content, csleDele.function, _params);
                    }
                }
            }
            CLS_Content.PoolParamList(_params);
            content.OutStack(this);
            return(retVal);
        }
Example #6
0
        public Delegate CreateDelegate(ICLS_Environment env, DeleFunction delefunc)
        {
            DeleFunction _func = delefunc;
            Delegate     _dele = delefunc.cacheFunction(this._type, null);

            if (_dele != null)
            {
                return(_dele);
            }
            Action <T, T1, T2> dele = (T param0, T1 param1, T2 param2) =>
            {
                var func = _func.calltype.functions[_func.function];
                if (func.expr_runtime != null)
                {
                    CLS_Content content = new CLS_Content(env, true);
                    try
                    {
                        content.DepthAdd();
                        content.CallThis = _func.callthis;
                        content.CallType = _func.calltype;
                        content.function = _func.function;


                        content.DefineAndSet(func._paramnames[0], func._paramtypes[0].type, param0);
                        content.DefineAndSet(func._paramnames[1], func._paramtypes[1].type, param1);
                        content.DefineAndSet(func._paramnames[2], func._paramtypes[2].type, param2);

                        func.expr_runtime.ComputeValue(content);
                        content.DepthRemove();
                    }
                    catch (Exception err)
                    {
                        string errinfo = "Dump Call in:";
                        if (_func.calltype != null)
                        {
                            errinfo += _func.calltype.Name + "::";
                        }
                        if (_func.function != null)
                        {
                            errinfo += _func.function;
                        }
                        errinfo += "\n";
                        env.logger.Log(errinfo + content.Dump());
                        throw err;
                    }
                }
            };
            Delegate d = dele as Delegate;

            if ((Type)this.type != typeof(Action))
            {
                _dele = Delegate.CreateDelegate(this.type, d.Target, d.Method);
            }
            else
            {
                _dele = dele;
            }
            return(delefunc.cacheFunction(this._type, _dele));
        }
        public Delegate CreateDelegate(ICLS_Environment env, DeleFunction delefunc)
        {
            DeleFunction _func = delefunc;
            Delegate     _dele = delefunc.cacheFunction(this._type, null);

            if (_dele != null)
            {
                return(_dele);
            }
            NonVoidDelegate dele = delegate(T param0, T1 param1, T2 param2)
            {
                var func = _func.calltype.functions[_func.function];
                if (func.expr_runtime != null)
                {
                    CLS_Content content = new CLS_Content(env, true);
                    try
                    {
                        content.DepthAdd();
                        content.CallThis = _func.callthis;
                        content.CallType = _func.calltype;
                        content.function = _func.function;

                        content.DefineAndSet(func._paramnames[0], func._paramtypes[0].type, param0);
                        content.DefineAndSet(func._paramnames[1], func._paramtypes[1].type, param1);
                        content.DefineAndSet(func._paramnames[2], func._paramtypes[2].type, param2);

                        CLS_Content.Value retValue = func.expr_runtime.ComputeValue(content);
                        content.DepthRemove();

                        return((ReturnType)retValue.value);
                    }
                    catch (Exception err)
                    {
                        string errinfo = "Dump Call in:";
                        if (_func.calltype != null)
                        {
                            errinfo += _func.calltype.Name + "::";
                        }
                        if (_func.function != null)
                        {
                            errinfo += _func.function;
                        }
                        errinfo += "\n";
                        env.logger.Log(errinfo + content.Dump());
                        throw err;
                    }
                }
                return(default(ReturnType));
            };

            _dele = Delegate.CreateDelegate(this.type, dele.Target, dele.Method);
            return(delefunc.cacheFunction(this._type, _dele));
        }
Example #8
0
        public Value GetQuiet(string name)
        {
            if (name == "this")
            {
                Value v = new Value();
                v.type  = CallType;
                v.value = CallThis;
                return(v);
            }

            Value retV  = null;
            bool  bFind = values.TryGetValue(name, out retV);

            if (bFind)//优先上下文变量
            {
                return(retV);
            }

            if (CallType != null)
            {
                SType.Member retM = null;
                bFind = CallType.members.TryGetValue(name, out retM);
                if (bFind)
                {
                    if (retM.bStatic)
                    {
                        return(CallType.staticMemberInstance[name]);
                    }
                    else
                    {
                        return(CallThis.member[name]);
                    }
                }
                if (CallType.functions.ContainsKey(name))
                {
                    Value v = new Value();
                    //如果直接得到代理实例,
                    DeleFunction dele = new DeleFunction(CallType, this.CallThis, name);


                    //DeleScript dele =new DeleScript();
                    //dele.function = name;
                    //dele.calltype = CallType;
                    //dele.callthis = CallThis;
                    v.value = dele;
                    v.type  = typeof(DeleFunction);
                    return(v);
                }
            }
            return(null);
        }
Example #9
0
        public override Delegate CreateDelegate(ICLS_Environment env, DeleFunction delefunc)
        {
            Delegate _dele = delefunc.cacheFunction(null);

            if (_dele != null)
            {
                return(_dele);
            }

            var func = delefunc.calltype.functions[delefunc.function];
            Action <T, T1, T2> dele;

            if (func.expr_runtime != null)
            {
                dele = (T param0, T1 param1, T2 param2) =>
                {
                    CLS_Content content = CLS_Content.NewContent(env);
#if UNITY_EDITOR
                    try{
#endif
                    content.CallThis = delefunc.callthis;
                    content.CallType = delefunc.calltype;
                    content.DefineAndSet(func._paramnames[0], func._paramtypes[0].type, param0);
                    content.DefineAndSet(func._paramnames[1], func._paramtypes[1].type, param1);
                    content.DefineAndSet(func._paramnames[2], func._paramtypes[2].type, param2);
                    func.expr_runtime.ComputeValue(content);
                    CLS_Content.PoolContent(content);
#if UNITY_EDITOR
                }catch (System.Exception ex) { content.environment.logger.Log_Error(ex.Message + "\n" + content.DumpStack() + ex); }
#endif
                };
            }
            else
            {
                dele = (T param0, T1 param1, T2 param2) => { };
            }

            if (this.sysType != typeof(Action <T, T1, T2>))
            {
                _dele = Delegate.CreateDelegate(this.sysType, dele.Target, dele.Method);
            }
            else
            {
                _dele = dele;
            }
            return(delefunc.cacheFunction(_dele));
        }
        public Delegate CreateDelegate(ICLS_Environment env, DeleFunction delefunc)
        {
            DeleFunction _func = delefunc;
            Delegate     _dele = delefunc.cacheFunction(null);

            if (_dele != null)
            {
                return(_dele);
            }
            Action <T> dele = (T param0) =>
            {
                var func = _func.calltype.functions[_func.function];
                if (func.expr_runtime != null)
                {
                    CLS_Content content = new CLS_Content(env);
                    try
                    {
                        content.DepthAdd();
                        content.CallThis = _func.callthis;
                        content.CallType = _func.calltype;
                        content.function = _func.function;

                        content.DefineAndSet(func._paramnames[0], func._paramtypes[0].type, param0);

                        func.expr_runtime.ComputeValue(content);
                        content.DepthRemove();
                    }
                    catch (Exception err)
                    {
                        env.logger.Log(content.Dump());
                        throw err;
                    }
                }
            };
            Delegate d = dele as Delegate;

            if ((Type)this.type != typeof(Action))
            {
                _dele = Delegate.CreateDelegate(this.type, d.Target, d.Method);
            }
            else
            {
                _dele = dele;
            }
            return(delefunc.cacheFunction(_dele));
        }
Example #11
0
        public Value GetQuiet(string name)
        {
            if (name == "this")
            {
                Value v = new Value();
                v.type  = CallType;
                v.value = CallThis;
                return(v);
            }

            if (values.ContainsKey(name))//优先上下文变量
            {
                return(values[name]);
            }

            if (CallType != null)
            {
                if (CallType.members.ContainsKey(name))
                {
                    if (CallType.members[name].bStatic)
                    {
                        return(CallType.staticMemberInstance[name]);
                    }
                    else
                    {
                        return(CallThis.member[name]);
                    }
                }
                if (CallType.functions.ContainsKey(name))
                {
                    Value v = new Value();
                    //如果直接得到代理实例,
                    DeleFunction dele = new DeleFunction(CallType, this.CallThis, name);


                    //DeleScript dele =new DeleScript();
                    //dele.function = name;
                    //dele.calltype = CallType;
                    //dele.callthis = CallThis;
                    v.value = dele;
                    v.type  = typeof(DeleFunction);
                    return(v);
                }
            }
            return(null);
        }
        public override Delegate CreateDelegate(ICLS_Environment env, DeleFunction delefunc)
        {
            Delegate _dele = delefunc.cacheFunction(null);

            if (_dele != null)
            {
                return(_dele);
            }

            var             func = delefunc.calltype.functions[delefunc.function];
            NonVoidDelegate dele;

            if (func.expr_runtime != null)
            {
                dele = delegate(T param, T1 param1)
                {
                    CLS_Content content = CLS_Content.NewContent(env);
#if UNITY_EDITOR
                    try{
#endif
                    content.CallThis = delefunc.callthis;
                    content.CallType = delefunc.calltype;
                    content.DefineAndSet(func._paramnames[0], func._paramtypes[0].type, param);
                    content.DefineAndSet(func._paramnames[1], func._paramtypes[1].type, param1);
                    CLS_Content.Value retValue = func.expr_runtime.ComputeValue(content);
                    CLS_Content.PoolContent(content);
                    return((ReturnType)retValue.value);

#if UNITY_EDITOR
                }catch (System.Exception ex) { content.environment.logger.Log_Error(ex.Message + "\n" + content.DumpStack() + ex); return(default(ReturnType)); }
#endif
                };
            }
            else
            {
                dele = delegate(T param, T1 param1) { return(default(ReturnType)); };
            }

            _dele = Delegate.CreateDelegate(this.type, dele.Target, dele.Method);
            return(delefunc.cacheFunction(_dele));
        }
        public override Delegate CreateDelegate(ICLS_Environment env, DeleFunction delefunc)
        {
            Delegate _dele = delefunc.cacheFunction(null);
            if (_dele != null)
                return _dele;

            var func = delefunc.calltype.functions[delefunc.function];
            Action dele;
            if (func.expr_runtime != null)
            {
                dele = () =>
                {
                    CLS_Content content = CLS_Content.NewContent(env);
            #if UNITY_EDITOR
                    try{
            #endif
                    content.CallThis = delefunc.callthis;
                    content.CallType = delefunc.calltype;
                    func.expr_runtime.ComputeValue(content);
                    CLS_Content.PoolContent(content);
            #if UNITY_EDITOR
                    }catch (System.Exception ex) { content.environment.logger.Log_Error(ex.Message + "\n" + content.DumpStack() + ex); }
            #endif
                };
            }
            else
            {
                dele = () => { };
            }

            if (this.sysType != typeof(Action))
            {
                _dele = Delegate.CreateDelegate(this.sysType, dele.Target, dele.Method);
            }
            else
            {
                _dele = dele;
            }
            return delefunc.cacheFunction(_dele);
        }
        public Delegate CreateDelegate(ICLS_Environment env, DeleFunction delefunc)
        {
            DeleFunction _func = delefunc;
            Delegate     _dele = delefunc.cacheFunction(null);

            if (_dele != null)
            {
                return(_dele);
            }
            NonVoidDelegate dele = delegate()
            {
                var func = _func.calltype.functions[_func.function];
                if (func.expr_runtime != null)
                {
                    CLS_Content content = new CLS_Content(env);
                    try
                    {
                        content.DepthAdd();
                        content.CallThis = _func.callthis;
                        content.CallType = _func.calltype;
                        content.function = _func.function;

                        CLS_Content.Value retValue = func.expr_runtime.ComputeValue(content);
                        content.DepthRemove();
                        return((ReturnType)retValue.value);
                    }
                    catch (Exception err)
                    {
                        env.logger.Log(content.Dump());
                        throw err;
                    }
                }
                return(default(ReturnType));
            };

            _dele = Delegate.CreateDelegate(this.type, dele.Target, dele.Method);
            return(delefunc.cacheFunction(_dele));
        }
Example #15
0
        public Value GetQuiet(string name)
        {
            if (name == "this")
            {
                Value v = new Value();
                v.type = CallType;
                v.value = CallThis;
                return v;
            }

            Value retV = null;
            bool bFind = values.TryGetValue(name, out retV);
            if (bFind)//优先上下文变量
                return retV;

            if (CallType != null)
            {
                SType.Member retM = null;
                bFind = CallType.members.TryGetValue(name, out retM);
                if (bFind)
                {
                    if (retM.bStatic)
                    {
                        return CallType.staticMemberInstance[name];
                    }
                    else
                    {
                        return CallThis.member[name];
                    }
                }
                if (CallType.functions.ContainsKey(name))
                {
                    Value v = new Value();
                    //如果直接得到代理实例,
                    DeleFunction dele = new DeleFunction(CallType,this.CallThis,name);


                    //DeleScript dele =new DeleScript();
                    //dele.function = name;
                    //dele.calltype = CallType;
                    //dele.callthis = CallThis;
                    v.value = dele;
                    v.type = typeof(DeleFunction);
                    return v;

                }
            }
            return null;
        }
Example #16
0
 public virtual Delegate CreateDelegate(ICLS_Environment env, DeleFunction delefunc)
 {
     throw new Exception("请重载实现功能");
 }
Example #17
0
 public virtual Delegate CreateDelegate(ICLS_Environment env, DeleFunction delefunc)
 {
     throw new Exception("请重载实现功能");
 }
        public Delegate CreateDelegate(ICLS_Environment env, DeleFunction delefunc)
        {
            DeleFunction _func = delefunc;
            Delegate _dele = delefunc.cacheFunction(null);
            if (_dele != null) return _dele;
            Action dele = () =>
            {
                var func = _func.calltype.functions[_func.function];
                if (func.expr_runtime != null)
                {
                    CLS_Content content = new CLS_Content(env);
                    try
                    {

                        content.DepthAdd();
                        content.CallThis = _func.callthis;
                        content.CallType = _func.calltype;
                        content.function = _func.function;

                        //content.DefineAndSet(function._paramnames[0], function._paramtypes[0].type, param0);

                        func.expr_runtime.ComputeValue(content);
                        content.DepthRemove();
                    }
                    catch (Exception err)
                    {
                        env.logger.Log(content.Dump());
                        throw err;
                    }
                }
            };
            Delegate d = dele as Delegate;
            if ((Type)this.type != typeof(Action))
            {
                _dele = Delegate.CreateDelegate(this.type, d.Target, d.Method);
            }
            else
            {
                _dele = dele;
            }
            return delefunc.cacheFunction(_dele);
        }
Example #19
0
        public Value GetQuiet(string name)
        {
            if (name == "this")
            {
                Value v = new Value();
                v.type = CallType;
                v.value = CallThis;
                return v;
            }

            if (values.ContainsKey(name))//优先上下文变量
                return values[name];

            if (CallType != null)
            {
                if (CallType.members.ContainsKey(name))
                {
                    if (CallType.members[name].bStatic)
                    {
                        return CallType.staticMemberInstance[name];
                    }
                    else
                    {
                        return CallThis.member[name];
                    }
                }
                if (CallType.functions.ContainsKey(name))
                {
                    Value v = new Value();
                    //如果直接得到代理实例,
                    DeleFunction dele = new DeleFunction(CallType,this.CallThis,name);


                    //DeleScript dele =new DeleScript();
                    //dele.function = name;
                    //dele.calltype = CallType;
                    //dele.callthis = CallThis;
                    v.value = dele;
                    v.type = typeof(DeleFunction);
                    return v;

                }
            }
            return null;
        }