public Delegate CreateDelegate(ICLS_Environment env, DeleLambda lambda)
        {
            var pnames = lambda.paramNames;
            var expr   = lambda.expr_func;

            NonVoidDelegate dele = delegate(T param0, T1 param1, T2 param2) {
                if (expr != null)
                {
                    CLS_Content content = lambda.content.Clone();

                    content.DepthAdd();

                    content.DefineAndSet(pnames[0], typeof(T), param0);
                    content.DefineAndSet(pnames[1], typeof(T1), param1);
                    content.DefineAndSet(pnames[2], typeof(T2), param2);
                    CLS_Content.Value retValue = expr.ComputeValue(content);

                    content.DepthRemove();

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

            Delegate d = dele as Delegate;

            return(Delegate.CreateDelegate(this.type, d.Target, d.Method));
        }
Ejemplo n.º 2
0
        public Delegate CreateDelegate(ICLS_Environment env, DeleLambda lambda)
        {
            CLS_Content content = lambda.content.Clone();
            var         pnames  = lambda.paramNames;
            var         expr    = lambda.expr_func;

            NonVoidDelegate dele = delegate(T param)
            {
                if (expr != null)
                {
                    try
                    {
                        content.DepthAdd();

                        content.DefineAndSet(pnames[0], typeof(T), param);
                        CLS_Content.Value retValue = expr.ComputeValue(content);

                        content.DepthRemove();
                        return((ReturnType)retValue.value);
                    }
                    catch (Exception err)
                    {
                        env.logger.Log(content.Dump());
                        throw err;
                    }
                }
                return(default(ReturnType));
            };

            Delegate d = dele as Delegate;

            return(Delegate.CreateDelegate(this.type, d.Target, d.Method));
        }
        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));
        }
Ejemplo n.º 4
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));
        }
        public override Delegate CreateDelegate(DeleFunction delefunc)
        {
            DeleFunction _func = delefunc;
            Delegate     _dele = delefunc.cacheFunction(this._type, null);

            if (_dele != null)
            {
                return(_dele);
            }
            NonVoidDelegate dele = delegate(T param, T1 param1)
            {
                var func = _func.calltype.functions[_func.function];
                if (func.expr_runtime != null)
                {
                    CQ_Content content = CQ_ObjPool.PopContent();
                    try
                    {
                        content.CallThis = _func.callthis;
                        content.CallType = _func.calltype;
                                                #if CQUARK_DEBUG
                        content.function = _func.function;
                                                #endif

                        CQ_Value p0 = new CQ_Value();
                        p0.SetObject(func._paramtypes[0].typeBridge, param);
                        content.DefineAndSet(func._paramnames[0], typeof(T), p0);

                        CQ_Value p1 = new CQ_Value();
                        p1.SetObject(func._paramtypes[0].typeBridge, param1);
                        content.DefineAndSet(func._paramnames[1], typeof(T1), p1);

                        CQ_Value retValue = func.expr_runtime.ComputeValue(content);
                        content.DepthRemove();
                        CQ_ObjPool.PushContent(content);
                        return((ReturnType)retValue.GetObject());
                    }
                    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";
                        DebugUtil.Log(errinfo + content.Dump());
                        throw err;
                    }
                }
                return(default(ReturnType));
            };

            _dele = Delegate.CreateDelegate(this.typeBridge, dele.Target, dele.Method);
            return(delefunc.cacheFunction(this._type, _dele));
        }
        public override Delegate CreateDelegate(DeleLambda lambda)
        {
            CQ_Content content = lambda.content.Clone();
            var        pnames  = lambda.paramNames;
            var        expr    = lambda.expr_func;

            NonVoidDelegate dele = delegate(T param0, T1 param1, T2 param2)
            {
                if (expr != null)
                {
                    try
                    {
                        content.DepthAdd();

                        CQ_Value p0 = new CQ_Value();
                        p0.SetObject(typeof(T), param0);
                        content.DefineAndSet(pnames[0], typeof(T), p0);

                        CQ_Value p1 = new CQ_Value();
                        p1.SetObject(typeof(T1), param1);
                        content.DefineAndSet(pnames[1], typeof(T1), p1);

                        CQ_Value p2 = new CQ_Value();
                        p2.SetObject(typeof(T2), param2);
                        content.DefineAndSet(pnames[2], typeof(T2), p2);

                        CQ_Value retValue = expr.ComputeValue(content);

                        content.DepthRemove();

                        return((ReturnType)retValue.GetObject());
                    }
                    catch (Exception err)
                    {
                        string errinfo = "Dump Call lambda in:";
                        if (content.CallType != null)
                        {
                            errinfo += content.CallType.Name + "::";
                        }
                                                #if CQUARK_DEBUG
                        if (content.function != null)
                        {
                            errinfo += content.function;
                        }
                                                #endif

                        errinfo += "\n";
                        DebugUtil.Log(errinfo + content.Dump());
                        throw err;
                    }
                }
                return(default(ReturnType));
            };

            Delegate d = dele as Delegate;

            return(Delegate.CreateDelegate(this.typeBridge, d.Target, d.Method));
        }
        public Delegate CreateDelegate(ICQ_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)
                {
                    CQ_Content content = new CQ_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);

                        CQ_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));
        }
Ejemplo n.º 8
0
        public override Delegate CreateDelegate(DeleFunction delefunc)
        {
            DeleFunction _func = delefunc;
            Delegate     _dele = delefunc.cacheFunction(this._type, null);

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

                        CQ_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";
                        DebugUtil.Log(errinfo + content.Dump());
                        throw err;
                    }
                }
                return(default(ReturnType));
            };

            _dele = Delegate.CreateDelegate(this.typeBridge, dele.Target, dele.Method);
            return(delefunc.cacheFunction(this._type, _dele));
        }
Ejemplo n.º 9
0
        public Delegate CreateDelegate(ICQ_Environment env, DeleLambda lambda)
        {
            CQ_Content content = lambda.content.Clone();
            var        pnames  = lambda.paramNames;
            var        expr    = lambda.expr_func;

            NonVoidDelegate dele = delegate(T param0, T1 param1)
            {
                if (expr != null)
                {
                    try
                    {
                        content.DepthAdd();

                        content.DefineAndSet(pnames[0], typeof(T), param0);
                        content.DefineAndSet(pnames[1], typeof(T1), param1);

                        CQ_Content.Value retValue = expr.ComputeValue(content);

                        content.DepthRemove();

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

            Delegate d = dele as Delegate;

            return(Delegate.CreateDelegate(this.type, d.Target, d.Method));
        }
Ejemplo n.º 10
0
        public override Delegate CreateDelegate(DeleLambda lambda)
        {
            CQ_Content content = lambda.content.Clone();
            //var pnames = lambda.paramNames;
            var expr = lambda.expr_func;

            NonVoidDelegate dele = delegate()
            {
                if (expr != null)
                {
                    try
                    {
                        content.DepthAdd();
                        CQ_Value retValue = expr.ComputeValue(content);
                        content.DepthRemove();
                        return((ReturnType)retValue.GetObject());
                    }
                    catch (Exception err)
                    {
                        string errinfo = "Dump Call lambda in:";
                        if (content.CallType != null)
                        {
                            errinfo += content.CallType.Name + "::";
                        }
                                                #if CQUARK_DEBUG
                        if (content.function != null)
                        {
                            errinfo += content.function;
                        }
                                                #endif

                        errinfo += "\n";
                        DebugUtil.Log(errinfo + content.Dump());
                        throw err;
                    }
                }
                return(default(ReturnType));
            };

            Delegate d = dele;

            return(Delegate.CreateDelegate(this.typeBridge, d.Target, d.Method));
        }
Ejemplo n.º 11
0
        public Delegate CreateDelegate(ICLS_Environment env, DeleLambda lambda)
        {
            var pnames = lambda.paramNames;
            var expr   = lambda.expr_func;

            NonVoidDelegate dele = delegate() {
                if (expr != null)
                {
                    CLS_Content content = lambda.content.Clone();

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

            Delegate d = dele;

            return(Delegate.CreateDelegate(this.type, d.Target, d.Method));
        }
        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));
        }