Пример #1
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);
        }
Пример #2
0
        public IEnumerator CoroutineCompute(CQ_Content content, ICoroutine coroutine)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif

            if (_expressions[0].hasCoroutine)
            {
                yield return(coroutine.StartNewCoroutine(_expressions[0].CoroutineCompute(content, coroutine)));
            }
            else
            {
                CQ_Value v = _expressions[0].ComputeValue(content);

                {
                    object  val        = v.value;
                    CQ_Type value_type = null;
                    if (content.values != null && content.values.ContainsKey(value_name))
                    {
                        value_type = content.values[value_name].type;
                    }
                    else
                    {
                        if (content.CallType != null)
                        {
                            if (content.CallType.members.ContainsKey(value_name))
                            {
                                if (content.CallType.members[value_name].bStatic)
                                {
                                    value_type = content.CallType.staticMemberInstance[value_name].type;
                                }
                                else
                                {
                                    value_type = content.CallThis.member[value_name].type;
                                }
                            }
                        }
                    }
                    //val = v.value;
                    if ((Type)value_type != typeof(Type_Var.var) && value_type != v.type)
                    {
                        val = v.ConvertTo(value_type);
                    }


                    content.Set(value_name, val);
                }
            }
#if CQUARK_DEBUG
            content.OutStack(this);
#endif
        }
Пример #3
0
        public IEnumerator CoroutineCompute(CQ_Content content, ICoroutine coroutine)
        {
            content.InStack(this);
            {
                if (listParam[0].hasCoroutine)
                {
                    yield return(coroutine.StartNewCoroutine(listParam[0].CoroutineCompute(content, coroutine)));
                }
                else
                {
                    CQ_Content.Value v = listParam[0].ComputeValue(content);

                    {
                        object val        = v.value;
                        CQType value_type = null;
                        if (content.values.ContainsKey(value_name))
                        {
                            value_type = content.values[value_name].type;
                        }
                        else
                        {
                            if (content.CallType != null)
                            {
                                if (content.CallType.members.ContainsKey(value_name))
                                {
                                    if (content.CallType.members[value_name].bStatic)
                                    {
                                        value_type = content.CallType.staticMemberInstance[value_name].type;
                                    }
                                    else
                                    {
                                        value_type = content.CallThis.member[value_name].type;
                                    }
                                }
                            }
                        }
                        //val = v.value;
                        if ((Type)value_type != typeof(CQ_Type_Var.var) && value_type != v.type)
                        {
                            val = content.environment.GetType(v.type).ConvertTo(content, v.value, value_type);
                        }


                        content.Set(value_name, val);
                    }
                }
            }
            content.OutStack(this);
        }
Пример #4
0
        public CQ_Value ComputeValue(CQ_Content content)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif
            CQ_Value v      = content.Get(value_name);
            IType    type   = CQuark.AppDomain.GetITypeByCQValue(v);
            CQ_Value retVal = type.Math2Value(mathop, v, CQ_Value.One);
            v.UsingValue(retVal);
            content.Set(value_name, v);

#if CQUARK_DEBUG
            content.OutStack(this);
#endif
            return(v);
        }
Пример #5
0
        public CQ_Value ComputeValue(CQ_Content content)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif
            {
                CQ_Value v = _expressions[0].ComputeValue(content);

                {
                    object  val        = v.value;
                    CQ_Type value_type = null;
                    if (content.values != null && content.values.ContainsKey(value_name))
                    {
                        value_type = content.values[value_name].type;
                    }
                    else
                    {
                        if (content.CallType != null)
                        {
                            if (content.CallType.members.ContainsKey(value_name))
                            {
                                if (content.CallType.members[value_name].bStatic)
                                {
                                    value_type = content.CallType.staticMemberInstance[value_name].type;
                                }
                                else
                                {
                                    value_type = content.CallThis.member[value_name].type;
                                }
                            }
                        }
                    }
                    //val = v.value;
                    if ((Type)value_type != typeof(Type_Var.var) && value_type != v.type)
                    {
                        val = v.ConvertTo(value_type);
                    }


                    content.Set(value_name, val);
                }
            }
#if CQUARK_DEBUG
            content.OutStack(this);
#endif
            return(null);
        }
Пример #6
0
        public CQ_Content.Value ComputeValue(CQ_Content content)
        {
            content.InStack(this);

            var      v    = content.Get(value_name);
            ICQ_Type type = content.environment.GetType(v.type);
            CQType   returntype;
            object   value = type.Math2Value(content, mathop, v.value, CQ_Content.Value.One, out returntype);

            value = type.ConvertTo(content, value, v.type);
            content.Set(value_name, value);

            //操作变量之
            //做数学计算
            //从上下文取值
            //_value = null;
            content.OutStack(this);

            return(content.Get(value_name));
        }
Пример #7
0
        public CQ_Value ComputeValue(CQ_Content content)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif
            var     v    = content.Get(value_name);
            IType   type = CQuark.AppDomain.GetType(v.type);
            CQ_Type returntype;
            object  value = type.Math2Value(mathop, v.value, CQ_Value.One, out returntype);
            value = type.ConvertTo(value, v.type);
            content.Set(value_name, value);

            //操作变量之
            //做数学计算
            //从上下文取值
            //_value = null;
#if CQUARK_DEBUG
            content.OutStack(this);
#endif
            return(content.Get(value_name));
        }
Пример #8
0
        public IEnumerator CoroutineCompute(CQ_Content content, UnityEngine.MonoBehaviour coroutine)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif

            if (_expressions[0].hasCoroutine)
            {
                yield return(coroutine.StartCoroutine(_expressions[0].CoroutineCompute(content, coroutine)));
            }
            else
            {
                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
        }
Пример #9
0
        public CQ_Value ComputeValue(CQ_Content content)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif
            CQ_Value parent = _expressions[0].ComputeValue(content);
            object   obj    = parent.GetObject();
            if (parent == CQ_Value.Null)
            {
                throw new Exception("调用空对象的方法:" + _expressions[0].ToString() + ":" + ToString());
            }
            CQ_Value key   = _expressions[1].ComputeValue(content);
            CQ_Value 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.m_type, obj, key, value))
            {
                var type = CQuark.AppDomain.GetITypeByCQValue(parent);
                type._class.IndexSet(content, parent.GetObject(), obj, value.GetObject());
            }

            CQ_Expression_GetValue f = _expressions[0] as CQ_Expression_GetValue;
            content.Set(f.value_name, parent);


#if CQUARK_DEBUG
            content.OutStack(this);
#endif
            return(CQ_Value.Null);
        }
Пример #10
0
        public CQ_Value ComputeValue(CQ_Content content)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif
            content.DepthAdd();
            CQ_Expression_Define define = _expressions[0] as CQ_Expression_Define;
            define.ComputeValue(content);

            System.Collections.IEnumerable emu = _expressions[1].ComputeValue(content).GetObject() as System.Collections.IEnumerable;

            ICQ_Expression expr_block = _expressions[2] as ICQ_Expression;

            var      it  = emu.GetEnumerator();
            CQ_Value vrt = CQ_Value.Null;
            while (it.MoveNext())
            {
                //content.Set(define.value_name, it.Current);
                CQ_Value val = new CQ_Value();
                val.SetObject(define.value_type, it.Current);
                content.Set(define.value_name, val);


                if (expr_block != null)
                {
                    if (expr_block is CQ_Expression_Block)
                    {
                        CQ_Value v = expr_block.ComputeValue(content);

                        if (v.m_breakBlock == BreakType.Return)
                        {
                            vrt = v;
                        }
                        if (v.m_breakBlock == BreakType.Return || v.m_breakBlock == BreakType.Break)
                        {
                            break;
                        }
                    }
                    else
                    {
                        content.DepthAdd();
                        bool     bbreak = false;
                        CQ_Value v      = expr_block.ComputeValue(content);

                        if (v.m_breakBlock == BreakType.Return)
                        {
                            vrt = v;
                        }
                        if (v.m_breakBlock == BreakType.Break || v.m_breakBlock == BreakType.Return)
                        {
                            bbreak = true;
                        }

                        content.DepthRemove();
                        if (bbreak)
                        {
                            break;
                        }
                    }
                }
            }

            content.DepthRemove();
#if CQUARK_DEBUG
            content.OutStack(this);
#endif
            return(vrt);
        }
Пример #11
0
        public CQ_Content.Value ComputeValue(CQ_Content content)
        {
            content.InStack(this);
            content.DepthAdd();
            CQ_Expression_Define define = listParam[0] as CQ_Expression_Define;

            if (define == null)
            {
            }
            define.ComputeValue(content);

            System.Collections.IEnumerable emu = listParam[1].ComputeValue(content).value as System.Collections.IEnumerable;

            ICQ_Expression expr_block = listParam[2] as ICQ_Expression;

            var it = emu.GetEnumerator();

            CQ_Content.Value vrt = null;
            while (it.MoveNext())
            {
                content.Set(define.value_name, it.Current);
                if (expr_block != null)
                {
                    if (expr_block is CQ_Expression_Block)
                    {
                        var v = expr_block.ComputeValue(content);
                        if (v != null)
                        {
                            if (v.breakBlock > 2)
                            {
                                vrt = v;
                            }
                            if (v.breakBlock > 1)
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        content.DepthAdd();
                        bool bbreak = false;
                        var  v      = expr_block.ComputeValue(content);
                        if (v != null)
                        {
                            if (v.breakBlock > 2)
                            {
                                vrt = v;
                            }
                            if (v.breakBlock > 1)
                            {
                                bbreak = true;
                            }
                        }
                        content.DepthRemove();
                        if (bbreak)
                        {
                            break;
                        }
                    }
                }
            }
            //ICQ_Expression expr_continue = listParam[1] as ICQ_Expression;
            //ICQ_Expression expr_step = listParam[2] as ICQ_Expression;

            //ICQ_Expression expr_block = listParam[3] as ICQ_Expression;

            //for (;(bool)expr_continue.ComputeValue(content).value; expr_step.ComputeValue(content))
            //{
            //    if(expr_block!=null)
            //    {
            //        var v = expr_block.ComputeValue(content);
            //        if (v != null && v.breakBlock > 1) break; ;
            //        //if (v.breakBlock == 1) continue;
            //        //if (v.breakBlock == 2) break;
            //        //if (v.breakBlock == 10) return v;
            //    }
            //}
            content.DepthRemove();
            content.OutStack(this);
            return(vrt);
            //for 逻辑
            //做数学计算
            //从上下文取值
            //_value = null;
        }
Пример #12
0
        public CQ_Value ComputeValue(CQ_Content content)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif

            CQ_Value left  = _expressions[0].ComputeValue(content);
            CQ_Value right = _expressions[1].ComputeValue(content);
            IType    type  = CQuark.AppDomain.GetITypeByCQValue(left);

            CQ_Value val = type.Math2Value(mathop, left, right);
            //val.SetValue(left.typeBridge, type.ConvertTo(val.GetValue(), left.typeBridge));
            left.UsingValue(val);

            if (_expressions[0] is CQ_Expression_MemberValueGet)
            {
                CQ_Expression_MemberValueGet f = _expressions[0] as CQ_Expression_MemberValueGet;

                CQ_Value parent = f._expressions[0].ComputeValue(content);
                if (parent == CQ_Value.Null)
                {
                    throw new Exception("调用空对象的方法:" + f._expressions[0].ToString() + ":" + ToString());
                }

                //这几行是为了快速获取Unity的静态变量,而不需要反射
                object obj = parent.GetObject();
                if (!Wrap.MemberValueSet(parent.m_type, obj, f.membername, val))
                {
                    IType ptype = CQuark.AppDomain.GetITypeByCQValue(parent);
                    ptype._class.MemberValueSet(content, obj, f.membername, val);
                }
            }
            else if (_expressions[0] is CQ_Expression_StaticValueGet)
            {
                CQ_Expression_StaticValueGet f = _expressions[0] as CQ_Expression_StaticValueGet;

                //这几行是为了快速获取Unity的静态变量,而不需要反射
                if (!Wrap.StaticValueSet(type.typeBridge.type, f.staticmembername, val))
                {
                    f.type._class.StaticValueSet(content, f.staticmembername, val);
                }
            }
            else if (_expressions[0] is CQ_Expression_GetValue)
            {
                CQ_Expression_GetValue f = _expressions[0] as CQ_Expression_GetValue;
                content.Set(f.value_name, left);
            }
            else if (_expressions[0] is CQ_Expression_IndexGet)
            {
                CQ_Expression_IndexGet f = _expressions[0] as CQ_Expression_IndexGet;
                CQ_Value parent          = f._expressions[0].ComputeValue(content);
                object   obj             = parent.GetObject();
                CQ_Value key             = f._expressions[1].ComputeValue(content);

                IType parenttype = CQuark.AppDomain.GetITypeByCQValue(parent);
                parenttype._class.IndexSet(content, obj, key.GetObject(), left.GetObject());

                CQ_Expression_GetValue g = f._expressions[0] as CQ_Expression_GetValue;
                content.Set(g.value_name, parent);
            }



#if CQUARK_DEBUG
            content.OutStack(this);
#endif

            return(CQ_Value.Null);
        }
        public CQ_Value ComputeValue(CQ_Content content)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif
            content.DepthAdd();
            CQ_Expression_Define define = _expressions[0] as CQ_Expression_Define;
            if (define == null)
            {
            }
            define.ComputeValue(content);

            System.Collections.IEnumerable emu = _expressions[1].ComputeValue(content).value as System.Collections.IEnumerable;

            ICQ_Expression expr_block = _expressions[2] as ICQ_Expression;

            var      it  = emu.GetEnumerator();
            CQ_Value vrt = null;
            while (it.MoveNext())
            {
                content.Set(define.value_name, it.Current);
                if (expr_block != null)
                {
                    if (expr_block is CQ_Expression_Block)
                    {
                        var v = expr_block.ComputeValue(content);
                        if (v != null)
                        {
                            if (v.breakBlock > 2)
                            {
                                vrt = v;
                            }
                            if (v.breakBlock > 1)
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        content.DepthAdd();
                        bool bbreak = false;
                        var  v      = expr_block.ComputeValue(content);
                        if (v != null)
                        {
                            if (v.breakBlock > 2)
                            {
                                vrt = v;
                            }
                            if (v.breakBlock > 1)
                            {
                                bbreak = true;
                            }
                        }
                        content.DepthRemove();
                        if (bbreak)
                        {
                            break;
                        }
                    }
                }
            }

            content.DepthRemove();
#if CQUARK_DEBUG
            content.OutStack(this);
#endif
            return(vrt);
        }