Example #1
0
    void OnGUI()
    {
        if (GUI.Button(new Rect(0, 0, 200, 50), "Eval use String"))
        {
            string callExpr = "ScriptClass4 sc =new ScriptClass4();\n" +
                              "sc.defHP1=100;\n" +
                              "sc.defHP2=200;\n" +
                              "return sc.GetHP();";
            object i = block.Execute(callExpr);
            result = "result=" + i;
        }

        if (GUI.Button(new Rect(200, 0, 200, 50), "Eval use Code"))
        {
            //得到脚本类型
            var typeOfScript = CQuark.AppDomain.GetTypeByKeyword("ScriptClass4");

            CQuark.CQ_Content content = new CQuark.CQ_Content();
            //调用脚本类构造创造一个实例
            var thisOfScript = typeOfScript._class.New(content, null).value;
            //调用脚本类成员变量赋值
            //Debug.LogWarning(thisOfScript+","+ typeOfScript+","+ typeOfScript.function);
            typeOfScript._class.MemberValueSet(content, thisOfScript, "defHP1", 200);
            typeOfScript._class.MemberValueSet(content, thisOfScript, "defHP2", 300);
            //调用脚本类成员函数
            var    returnvalue = typeOfScript._class.MemberCall(content, thisOfScript, "GetHP", null);
            object i           = returnvalue.value;
            result = "result=" + i;
        }

        GUI.Label(new Rect(0, 50, 200, 50), result);
    }
Example #2
0
 public CQ_Value IndexGet(CQ_Content content, object object_this, object key)
 {
     //var m = type.GetMembers();
     if (indexGetCache == null)
     {
         indexGetCache = type.GetMethod("get_Item");
         if (indexGetCache != null)
         {
             indexGetCacheType = indexGetCache.ReturnType;
         }
         if (indexGetCache == null)
         {
             indexGetCache = type.GetMethod("GetValue", new Type[] { typeof(int) });
             if (indexGetCache != null)
             {
                 indexGetCacheType = type.GetElementType();
             }
         }
         indexGetCachetypeindex = indexGetCache.GetParameters()[0].ParameterType;
     }
     //else
     {
         CQ_Value v = new CQ_Value();
         if (key != null && key.GetType() != indexGetCachetypeindex)
         {
             key = CQuark.AppDomain.ConvertTo(key, (CQuark.TypeBridge)indexGetCachetypeindex);
         }
         v.SetObject(indexGetCacheType, indexGetCache.Invoke(object_this, new object[] { key }));
         return(v);
     }
     //throw new NotImplementedException();
 }
        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    value = listParam[1].ComputeValue(content);
            object setv  = value.value;
            //if(value.type!=parent.type)
            //{
            //    var vtype = content.environment.GetType(value.type);
            //    setv = vtype.ConvertTo(content.environment, setv, parent.type);
            //}
            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;
                }
            }
            typefunction.MemberValueSet(content, parent.value, membername, setv);
            //做数学计算
            //从上下文取值
            //_value = null;
            content.OutStack(this);
            return(null);
        }
Example #4
0
        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_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 type = content.environment.GetType(parent.type);
            //string membername=null;


            var getvalue = type.function.MemberValueGet(content, parent.value, membername);

            CQ_Content.Value vright = CQ_Content.Value.One;
            if (listParam.Count > 1)
            {
                vright = listParam[1].ComputeValue(content);
            }
            CQ_Content.Value vout = new CQ_Content.Value();
            var mtype             = content.environment.GetType(getvalue.type);

            vout.value = mtype.Math2Value(content, mathop, getvalue.value, vright, out vout.type);

            type.function.MemberValueSet(content, parent.value, membername, vout.value);
            //CQ_Content.Value v = new CQ_Content.Value();

            content.OutStack(this);
            return(vout);
            //做数学计算
            //从上下文取值
            //_value = null;
            //return null;
        }
Example #6
0
        public CQ_Value ComputeValue(CQ_Content content)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif

            CQ_Value v      = _expressions[0].ComputeValue(content);
            CQ_Value oldVal = CQ_Value.Null;

            if (content.values != null && content.values.ContainsKey(value_name))
            {
                oldVal = content.values[value_name];
            }
            else if (content.CallType != null && content.CallType.members.ContainsKey(value_name))
            {
                if (content.CallType.members[value_name].bStatic)
                {
                    oldVal = content.CallType.staticMemberInstance[value_name];
                }
                else
                {
                    oldVal = content.CallThis.member[value_name];
                }
            }

            oldVal.UsingValue(v);
            content.Set(value_name, oldVal);

#if CQUARK_DEBUG
            content.OutStack(this);
#endif
            return(CQ_Value.Null);
        }
Example #7
0
        public CQ_Value ComputeValue(CQ_Content content)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif
            if (__expressions != null && __expressions.Count > 0)
            {
                CQ_Value v = __expressions[0].ComputeValue(content);
                //object val = v.GetValue();
                //if((Type)value_type == typeof(Type_Var.var)) {
                //    if(!v.TypeIsEmpty)
                //        value_type = v.typeBridge;

                //}
                //else if(v.typeBridge != value_type) {
                //    val = v.ConvertTo(value_type);

                //}

                content.DefineAndSet(value_name, value_type, v);
            }
            else
            {
                content.Define(value_name, value_type);
            }
#if CQUARK_DEBUG
            content.OutStack(this);
#endif
            return(CQ_Value.Null);
        }
Example #8
0
        public CQ_Value ComputeValue(CQ_Content content)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif
            if (__expressions != null && __expressions.Count > 0)
            {
                CQ_Value v   = __expressions[0].ComputeValue(content);
                object   val = v.value;
                if ((Type)value_type == typeof(Type_Var.var))
                {
                    if (v.type != null)
                    {
                        value_type = v.type;
                    }
                }
                else if (v.type != value_type)
                {
                    val = v.ConvertTo(value_type);
                }

                content.DefineAndSet(value_name, value_type, val);
            }
            else
            {
                content.Define(value_name, value_type);
            }
#if CQUARK_DEBUG
            content.OutStack(this);
#endif
            return(null);
        }
        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);
        }
Example #10
0
        public CQ_Value StaticCallCache(CQ_Content content, IList <CQ_Value> _params, MethodCache cache)
        {
            List <object> _oparams = new List <object>();

            foreach (var p in _params)
            {
                _oparams.Add(p.value);
            }
            System.Reflection.MethodInfo methodInfo = cache.info;
            if (cache.needConvert)
            {
                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);
                        }
                    }
                }
            }
            CQ_Value v = new CQ_Value();

            v.value = methodInfo.Invoke(null, _oparams.ToArray());
            v.type  = methodInfo.ReturnType;
            return(v);
        }
        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.New(type.typeBridge.type, parameters, out value))
            {
                value = type._class.New(content, parameters);
            }

#if CQUARK_DEBUG
            content.OutStack(this);
#endif
            CQ_ObjPool.PushArray(parameters);
            return(value);
        }
Example #12
0
        public object ConvertTo(CQ_Content env, object src, CQType targetType)
        {
            ICQ_Type_Dele dele = env.environment.GetType(targetType) as ICQ_Type_Dele;

            return(dele.CreateDelegate(env.environment, src as DeleFunction));
            //throw new NotImplementedException();
        }
        public CQ_Value ComputeValue(CQ_Content content)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif

            CQ_Value getvalue = null;

            //这几行是为了快速获取Unity的静态变量,而不需要反射
            if (!Wrap.StaticValueGet(type.typeBridge.type, staticmembername, out getvalue))
            {
                getvalue = type._class.StaticValueGet(content, staticmembername);
            }

            CQ_Value vright = CQ_Value.One;
            if (_expressions.Count > 0)
            {
                vright = _expressions[0].ComputeValue(content);
            }
            CQ_Value vout  = new CQ_Value();
            var      mtype = CQuark.AppDomain.GetType(getvalue.type);
            vout.value = mtype.Math2Value(mathop, getvalue.value, vright, out vout.type);

            //这几行是为了快速获取Unity的静态变量,而不需要反射
            if (!Wrap.StaticValueSet(type.typeBridge.type, staticmembername, vout))
            {
                type._class.StaticValueSet(content, staticmembername, vout.value);
            }


#if CQUARK_DEBUG
            content.OutStack(this);
#endif
            return(vout);
        }
        public CQ_Value ComputeValue(CQ_Content content)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif
            CQ_Value result = null;


            {
                result = new CQ_Value();
                var value = _expressions[0].ComputeValue(content);
                if ((Type)value.type != typeof(bool))
                {
                    throw new Exception("三元表达式要求条件为bool型");
                }
                bool bv = (bool)value.value;
                if (bv)
                {
                    result = _expressions[1].ComputeValue(content);
                }
                else
                {
                    result = _expressions[2].ComputeValue(content);
                }
            }
#if CQUARK_DEBUG
            content.OutStack(this);
#endif
            return(result);
        }
Example #15
0
        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());
            }
            var key   = _expressions[1].ComputeValue(content);
            var value = _expressions[2].ComputeValue(content);
            //object setv=value.value;
            //if(value.type!=parent.type)
            //{
            //    var vtype = CQuark.AppDomain.GetType(value.type);
            //    setv = vtype.ConvertTo(CQuark.AppDomain, setv, parent.type);
            //}

            //这几行是为了快速获取Unity的静态变量,而不需要反射
            if (!Wrap.IndexSet(parent.type.type, parent.value, key, value))
            {
                var type = CQuark.AppDomain.GetType(parent.type);
                type._class.IndexSet(content, parent.value, key.value, value.value);
            }

#if CQUARK_DEBUG
            content.OutStack(this);
#endif
            return(null);
        }
        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 key   = listParam[1].ComputeValue(content);
            var value = listParam[2].ComputeValue(content);
            //object setv=value.value;
            //if(value.type!=parent.type)
            //{
            //    var vtype = content.environment.GetType(value.type);
            //    setv = vtype.ConvertTo(content.environment, setv, parent.type);
            //}
            var type = content.environment.GetType(parent.type);

            type.function.IndexSet(content, parent.value, key.value, value.value);
            //做数学计算
            //从上下文取值
            //_value = null;
            content.OutStack(this);
            return(null);
        }
Example #17
0
        public CQ_Value ComputeValue(CQ_Content content)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif
            var parent = _expressions[0].ComputeValue(content);
            if (parent == CQ_Value.Null)
            {
                throw new Exception("调用空对象的方法:" + _expressions[0].ToString() + ":" + ToString());
            }
            var value = _expressions[1].ComputeValue(content);

            //这几行是为了快速获取Unity的静态变量,而不需要反射
            object obj = parent.GetObject();
            if (!Wrap.MemberValueSet(parent.m_type, obj, membername, value))
            {
                IClass iclass = CQuark.AppDomain.GetITypeByCQValue(parent)._class;

                CQ_ClassInstance s = obj as CQ_ClassInstance;
                if (s != null)
                {
                    iclass = s.type;
                }
                iclass.MemberValueSet(content, obj, membername, value);
            }
#if CQUARK_DEBUG
            content.OutStack(this);
#endif
            return(CQ_Value.Null);
        }
Example #18
0
        public Delegate CreateDelegate(ICQ_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)
                {
                    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);

                        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 override Delegate CreateDelegate(DeleLambda lambda)
        {
            CQ_Content         content = lambda.content.Clone();
            var                pnames  = lambda.paramNames;
            var                expr    = lambda.expr_func;
            Action <T, T1, T2> dele    = (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);

                        expr.ComputeValue(content);

                        content.DepthRemove();
                    }
                    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;
                    }
                }
            };
            Delegate d = dele as Delegate;

            if ((Type)this.typeBridge != typeof(Action <T, T1, T2>))
            {
                return(Delegate.CreateDelegate(this.typeBridge, d.Target, d.Method));
            }
            else
            {
                return(dele);
            }
        }
Example #20
0
 public CQ_Content.Value GetValue(string name)
 {
     if (content == null)
     {
         content = env.CreateContent();
     }
     return(content.Get(name));
 }
Example #21
0
 public void SetValue(string name, object v)
 {
     if (content == null)
     {
         content = env.CreateContent();
     }
     content.DefineAndSet(name, v.GetType(), v);
 }
Example #22
0
        public CQ_Content.Value ComputeValue(CQ_Content content)
        {
            content.InStack(this);
            var value = type.function.StaticValueGet(content, staticmembername);

            content.OutStack(this);
            return(value);
        }
Example #23
0
        public void InStack(CQ_Content expr)
        {
//            if (stackContent.Count > 0 && stackContent.Peek() == expr)
//            {
//                throw new Exception("InStackContent error");
//            }
//            stackContent.Push(expr);
        }
Example #24
0
        public void OutStack(CQ_Content expr)
        {
//            if (stackContent.Peek() != expr)
//            {
//                throw new Exception("OutStackContent error:" + expr.ToString() + " err:" + stackContent.Peek().ToString());
//            }
//            stackContent.Pop();
        }
Example #25
0
 public IEnumerator Expr_Coroutine(ICQ_Expression expr, CQ_Content content, ICoroutine coroutine)
 {
     if (content == null)
     {
         content = CreateContent();
     }
     yield return(coroutine.StartNewCoroutine(expr.CoroutineCompute(content, coroutine)));
 }
Example #26
0
 public CQ_Content.Value Expr_Execute(ICQ_Expression expr, CQ_Content content)
 {
     if (content == null)
     {
         content = CreateContent();
     }
     return(expr.ComputeValue(content));
 }
        public IEnumerator CoroutineCompute(CQ_Content content, ICoroutine coroutine)
        {
            content.InStack(this);
            content.DepthAdd();
            ICQ_Expression expr_switch = listParam[0] as ICQ_Expression;

            CQ_Content.Value switchVal = null;
            //			CQ_Content.Value vrt = null;
            if (expr_switch != null)
            {
                switchVal = expr_switch.ComputeValue(content);                //switch//
            }
            for (int i = 1; i < listParam.Count - 1; i += 2)
            {
                if (listParam[i] != null)
                {
                    //case xxx://
                    if (switchVal.value.Equals(listParam[i].ComputeValue(content).value))
                    {
                        while (listParam[i + 1] == null)
                        {
                            i += 2;
                        }
                        content.DepthAdd();
                        if (listParam[i + 1].hasCoroutine)
                        {
                            yield return(coroutine.StartNewCoroutine(listParam[i + 1].CoroutineCompute(content, coroutine)));
                        }
                        else
                        {
                            listParam[i + 1].ComputeValue(content);
                        }
                        break;
                    }
                    else
                    {
                        continue;
                    }
                }
                else
                {
                    //default:
                    content.DepthAdd();
                    if (listParam[i + 1].hasCoroutine)
                    {
                        yield return(coroutine.StartNewCoroutine(listParam[i + 1].CoroutineCompute(content, coroutine)));
                    }
                    else
                    {
                        listParam[i + 1].ComputeValue(content);
                    }
                    break;
                }
            }

            content.DepthRemove();
            content.OutStack(this);
        }
        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));
        }
Example #29
0
        public CQ_Value MemberValueGet(CQ_Content content, object object_this, string valuename)
        {
            MemberValueCache c = null;

            if (!memberValueGetCaches.TryGetValue(valuename, out c))
            {
                c = new MemberValueCache();
                memberValueGetCaches[valuename] = c;
                c.finfo = type.GetField(valuename);
                if (c.finfo == null)
                {
                    c.minfo = type.GetMethod("get_" + valuename);
                    if (c.minfo == null)
                    {
                        c.einfo = type.GetEvent(valuename);
                        if (c.einfo == null)
                        {
                            c.type = -1;
                            return(CQ_Value.Null);
                        }
                        else
                        {
                            c.type = 3;
                        }
                    }
                    else
                    {
                        c.type = 2;
                    }
                }
                else
                {
                    c.type = 1;
                }
            }

            if (c.type < 0)
            {
                return(CQ_Value.Null);
            }
            CQ_Value v = new CQ_Value();

            switch (c.type)
            {
            case 1:
                v.SetObject(c.finfo.FieldType, c.finfo.GetValue(object_this));
                break;

            case 2:
                v.SetObject(c.minfo.ReturnType, c.minfo.Invoke(object_this, null));
                break;

            case 3:
                v.SetObject(c.einfo.EventHandlerType, new DeleEvent(object_this, c.einfo));
                break;
            }
            return(v);
        }
Example #30
0
        public override Delegate CreateDelegate(DeleFunction delefunc)
        {
            DeleFunction _func = delefunc;
            Delegate     _dele = delefunc.cacheFunction(this._type, null);

            if (_dele != null)
            {
                return(_dele);
            }
            Action dele = () =>
            {
                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

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

                        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";
                        DebugUtil.Log(errinfo + content.Dump());
                        throw err;
                    }
                }
            };
            Delegate d = dele as Delegate;

            if ((Type)this.typeBridge != typeof(Action))
            {
                _dele = Delegate.CreateDelegate(this.typeBridge, d.Target, d.Method);
            }
            else
            {
                _dele = dele;
            }
            return(delefunc.cacheFunction(this._type, _dele));
        }