예제 #1
0
        public CQ_Content.Value ComputeValue(CQ_Content content)
        {
            content.InStack(this);
            List <string> depth__;

            content.Record(out depth__);
            try
            {
                ICQ_Expression expr = listParam[0];
                if (expr is CQ_Expression_Block)
                {
                    expr.ComputeValue(content);
                }
                else
                {
                    content.DepthAdd();
                    expr.ComputeValue(content);
                    content.DepthRemove();
                }
            }
            catch (Exception err)
            {
                bool bParse = false;
                int  i      = 1;
                while (i < listParam.Count)
                {
                    CQ_Expression_Define def = listParam[i] as CQ_Expression_Define;
                    if (err.GetType() == (Type)def.value_type || err.GetType().IsSubclassOf((Type)def.value_type))
                    {
                        content.DepthAdd();
                        content.DefineAndSet(def.value_name, def.value_type, err);

                        listParam[i + 1].ComputeValue(content);
                        content.DepthRemove();
                        bParse = true;
                        break;
                    }
                    i += 2;
                }
                if (!bParse)
                {
                    throw err;
                }
            }
            content.Restore(depth__, this);
            //while((bool)expr_continue.value);

            //for 逻辑
            //做数学计算
            //从上下文取值
            //_value = null;
            content.OutStack(this);
            return(null);
        }
예제 #2
0
        public CQ_Value ComputeValue(CQ_Content content)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif
            int oldDepthCount = content.Record();
            try {
                ICQ_Expression expr = _expressions[0];
                if (expr is CQ_Expression_Block)
                {
                    expr.ComputeValue(content);
                }
                else
                {
                    content.DepthAdd();
                    expr.ComputeValue(content);
                    content.DepthRemove();
                }
            }
            catch (Exception err) {
                bool bParse = false;
                int  i      = 1;
                while (i < _expressions.Count)
                {
                    CQ_Expression_Define def = _expressions[i] as CQ_Expression_Define;
                    if (err.GetType() == (Type)def.value_type || err.GetType().IsSubclassOf((Type)def.value_type))
                    {
                        content.DepthAdd();
                        CQ_Value errVal = new CQ_Value();
                        errVal.SetObject(def.value_type, err);
                        content.DefineAndSet(def.value_name, def.value_type, errVal);

                        _expressions[i + 1].ComputeValue(content);
                        content.DepthRemove();
                        bParse = true;
                        break;
                    }
                    i += 2;
                }
                if (!bParse)
                {
                    throw err;
                }
            }
            content.Restore(oldDepthCount, this);
            //while((bool)expr_continue.value);

#if CQUARK_DEBUG
            content.OutStack(this);
#endif
            return(CQ_Value.Null);
        }
예제 #3
0
        public CQ_Content.Value ComputeValue(CQ_Content content)
        {
            content.InStack(this);
            ICQ_Expression expr_if = listParam[0];
            bool           bif     = (bool)expr_if.ComputeValue(content).value;
            //if (expr_init != null) expr_init.ComputeValue(content);
            ICQ_Expression expr_go1 = listParam[1];
            ICQ_Expression expr_go2 = null;

            if (listParam.Count > 2)
            {
                expr_go2 = listParam[2];
            }
            CQ_Content.Value value = null;
            if (bif && expr_go1 != null)
            {
                if (expr_go1 is CQ_Expression_Block)
                {
                    value = expr_go1.ComputeValue(content);
                }
                else
                {
                    content.DepthAdd();
                    value = expr_go1.ComputeValue(content);
                    content.DepthRemove();
                }
            }
            else if (!bif && expr_go2 != null)
            {
                if (expr_go2 is CQ_Expression_Block)
                {
                    value = expr_go2.ComputeValue(content);
                }
                else
                {
                    content.DepthAdd();
                    value = expr_go2.ComputeValue(content);
                    content.DepthRemove();
                }
            }

            //while((bool)expr_continue.value);

            //for 逻辑
            //做数学计算
            //从上下文取值
            //_value = null;
            content.OutStack(this);
            return(value);
        }
예제 #4
0
        public CQ_Value ComputeValue(CQ_Content content)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif
            ICQ_Expression expr_if = _expressions[0];
            CQ_Value       v       = expr_if.ComputeValue(content);
            bool           bif     = v.GetBool();
            //if (expr_init != null) expr_init.ComputeValue(content);
            ICQ_Expression expr_go1 = _expressions[1];
            ICQ_Expression expr_go2 = null;
            if (_expressions.Count > 2)
            {
                expr_go2 = _expressions[2];                       //else
            }
            CQ_Value value = CQ_Value.Null;
            if (bif && expr_go1 != null)
            {
                if (expr_go1 is CQ_Expression_Block)
                {
                    value = expr_go1.ComputeValue(content);
                }
                else
                {
                    content.DepthAdd();
                    value = expr_go1.ComputeValue(content);
                    content.DepthRemove();
                }
            }
            else if (!bif && expr_go2 != null)
            {
                if (expr_go2 is CQ_Expression_Block)
                {
                    value = expr_go2.ComputeValue(content);
                }
                else
                {
                    content.DepthAdd();
                    value = expr_go2.ComputeValue(content);
                    content.DepthRemove();
                }
            }

#if CQUARK_DEBUG
            content.OutStack(this);
#endif
            return(value);
        }
예제 #5
0
        public CQ_Value ComputeValue(CQ_Content content)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif
            content.DepthAdd();
            CQ_Value value = null;
            foreach (ICQ_Expression i in _expressions)
            {
                ICQ_Expression e = i as ICQ_Expression;
                if (e != null)
                {
                    value = e.ComputeValue(content);
                }

                if (value != null && value.breakBlock != 0)
                {
                    break;
                }
            }
            content.DepthRemove();
#if CQUARK_DEBUG
            content.OutStack(this);
#endif
            return(value);
        }
예제 #6
0
        public IEnumerator CoroutineCompute(CQ_Content content, ICoroutine coroutine)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif
            content.DepthAdd();
            CQ_Value value = null;
            foreach (ICQ_Expression i in _expressions)
            {
                ICQ_Expression e = i as ICQ_Expression;
                if (e != null)
                {
                    if (e.hasCoroutine)
                    {
                        yield return(coroutine.StartNewCoroutine(e.CoroutineCompute(content, coroutine)));
                    }
                    else
                    {
                        value = e.ComputeValue(content);
                        if (value != null && value.breakBlock != 0)
                        {
                            break;
                        }
                    }
                }
            }
            content.DepthRemove();
#if CQUARK_DEBUG
            content.OutStack(this);
#endif
            yield break;
        }
예제 #7
0
 void FixedUpdate()
 {
     if (m_fixedpdate != null)
     {
         m_fixedpdate.ComputeValue(_updateContent);
     }
 }
예제 #8
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);
        }
예제 #10
0
    void FixedUpdate()
    {
        CQ_Content updatecontent = CQ_ObjPool.PopContent();

        updatecontent.CallType = cclass;
        updatecontent.CallThis = inst;
        if (m_fixedpdate != null)
        {
            m_fixedpdate.ComputeValue(updatecontent);
        }
        CQ_ObjPool.PushContent(updatecontent);
    }
예제 #11
0
        public CQ_Value ComputeValue(CQ_Content content)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif
            content.DepthAdd();
            ICQ_Expression expr_switch = _expressions[0] as ICQ_Expression;
            CQ_Value       switchVal   = CQ_Value.Null;
            //			CQ_Content.Value vrt = null;
            if (expr_switch != null)
            {
                switchVal = expr_switch.ComputeValue(content);//switch//
            }
            for (int i = 1; i < _expressions.Count - 1; i += 2)
            {
                if (_expressions[i] != null)
                {
                    //case xxx://
                    if (switchVal == _expressions[i].ComputeValue(content))
                    {
                        while (_expressions[i + 1] == null)
                        {
                            i += 2;
                        }
                        //						content.InStack(_expressions[i+1]);
                        content.DepthAdd();
                        _expressions[i + 1].ComputeValue(content);
                        break;
                    }
                    else
                    {
                        continue;
                    }
                }
                else
                {
                    //default:
                    //					content.InStack(_expressions[i+1]);
                    content.DepthAdd();
                    _expressions[i + 1].ComputeValue(content);
                    break;
                }
            }

            content.DepthRemove();
#if CQUARK_DEBUG
            content.OutStack(this);
#endif
            return(CQ_Value.Null);
        }
예제 #12
0
 ICQ_Expression OptimizeSingle(ICQ_Expression expr, CQ_Content content)
 {
     if (expr is CQ_Expression_Math2Value || expr is CQ_Expression_Math2ValueAndOr || expr is CQ_Expression_Math2ValueLogic)
     {
         if (expr.listParam[0] is ICQ_Value &&
             expr.listParam[1] is ICQ_Value)
         {
             CQ_Content.Value result = expr.ComputeValue(content);
             if ((Type)result.type == typeof(bool))
             {
                 CQ_Value_Value <bool> value = new CQ_Value_Value <bool>();
                 value.value_value = (bool)result.value;
                 value.tokenBegin  = expr.listParam[0].tokenBegin;
                 value.tokenEnd    = expr.listParam[1].tokenEnd;
                 value.lineBegin   = expr.listParam[0].lineBegin;
                 value.lineEnd     = expr.listParam[1].lineEnd;
                 return(value);
             }
             else
             {
                 ICQ_Type  v     = content.environment.GetType(result.type);
                 ICQ_Value value = v.MakeValue(result.value);
                 value.tokenBegin = expr.listParam[0].tokenBegin;
                 value.tokenEnd   = expr.listParam[1].tokenEnd;
                 value.lineBegin  = expr.listParam[0].lineBegin;
                 value.lineEnd    = expr.listParam[1].lineEnd;
                 return(value);
             }
         }
     }
     if (expr is CQ_Expression_Math3Value)
     {
         CQ_Content.Value result = expr.listParam[0].ComputeValue(content);
         if ((Type)result.type == typeof(bool))
         {
             bool bv = (bool)result.value;
             if (bv)
             {
                 return(expr.listParam[1]);
             }
             else
             {
                 return(expr.listParam[2]);
             }
         }
     }
     return(expr);
 }
예제 #13
0
        public CQ_Content.Value ComputeValue(CQ_Content content)
        {
            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.InStack(listParam[i+1]);
                        content.DepthAdd();
                        listParam[i + 1].ComputeValue(content);
                        break;
                    }
                    else
                    {
                        continue;
                    }
                }
                else
                {
                    //default:
//					content.InStack(listParam[i+1]);
                    content.DepthAdd();
                    listParam[i + 1].ComputeValue(content);
                    break;
                }
            }

            content.DepthRemove();
            content.OutStack(this);
            return(null);
        }
예제 #14
0
        public CQ_Content.Value ComputeValue(CQ_Content content)
        {
            content.InStack(this);
            content.DepthAdd();
            CQ_Content.Value value = null;
            foreach (ICQ_Expression i in listParam)
            {
                ICQ_Expression e = i  as ICQ_Expression;
                if (e != null)
                {
                    value = e.ComputeValue(content);
                }

                if (value != null && value.breakBlock != 0)
                {
                    break;
                }
            }
            content.DepthRemove();
            content.OutStack(this);
            return(value);
        }
예제 #15
0
        public IEnumerator CoroutineCompute(CQ_Content content, ICoroutine coroutine)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif
            content.DepthAdd();
            ICQ_Expression expr_while = _expressions[0] as ICQ_Expression;
            ICQ_Expression expr_block = _expressions[1] as ICQ_Expression;
            //			CQ_Content.Value vrt = null;
            while ((bool)expr_while.ComputeValue(content).value)
            {
                if (expr_block != null)
                {
                    if (expr_block is CQ_Expression_Block)
                    {
                        if (expr_block.hasCoroutine)
                        {
                            yield return(coroutine.StartNewCoroutine(expr_block.CoroutineCompute(content, coroutine)));
                        }
                        else
                        {
                            var v = expr_block.ComputeValue(content);
                            if (v != null)
                            {
                                //								if (v.breakBlock > 2) vrt = v;
                                if (v.breakBlock > 1)
                                {
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        content.DepthAdd();
                        if (expr_block.hasCoroutine)
                        {
                            yield return(coroutine.StartNewCoroutine(expr_block.CoroutineCompute(content, coroutine)));
                        }
                        else
                        {
                            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;
                            }
                        }
                    }
                    //if (v.breakBlock == 1) continue;
                    //if (v.breakBlock == 2) break;
                    //if (v.breakBlock == 10) return v;
                }
            }
            content.DepthRemove();
#if CQUARK_DEBUG
            content.OutStack(this);
#endif
            //for 逻辑
            //做数学计算
            //从上下文取值
            //_value = null;
        }
예제 #16
0
        public CQ_Content.Value Expr_Execute(ICQ_Expression expr)
        {
            CQ_Content content = CreateContent();

            return(expr.ComputeValue(content));
        }
예제 #17
0
        public IEnumerator CoroutineCompute(CQ_Content content, UnityEngine.MonoBehaviour coroutine)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif
            content.DepthAdd();
            ICQ_Expression expr_while = _expressions[1] as ICQ_Expression;
            ICQ_Expression expr_block = _expressions[0] as ICQ_Expression;

            //			CQ_Content.Value vrt = null;
            do
            {
                if (expr_block != null)
                {
                    if (expr_block is CQ_Expression_Block)
                    {
                        if (expr_block.hasCoroutine)
                        {
                            yield return(coroutine.StartCoroutine(expr_block.CoroutineCompute(content, coroutine)));
                        }
                        else
                        {
                            var v = expr_block.ComputeValue(content);
                            if (v != CQ_Value.Null)
                            {
                                //								if (v.breakBlock > 2) vrt = v;
                                if (v.m_breakBlock == BreakType.Break || v.m_breakBlock == BreakType.Return)
                                {
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        content.DepthAdd();
                        bool bbreak = false;
                        if (expr_block.hasCoroutine)
                        {
                            yield return(coroutine.StartCoroutine(expr_block.CoroutineCompute(content, coroutine)));
                        }
                        else
                        {
                            var v = expr_block.ComputeValue(content);
                            if (v != CQ_Value.Null)
                            {
                                //								if (v.breakBlock > 2) vrt = v;
                                if (v.m_breakBlock == BreakType.Return || v.m_breakBlock == BreakType.Break)
                                {
                                    bbreak = true;
                                }
                            }
                            content.DepthRemove();
                            if (bbreak)
                            {
                                break;
                            }
                        }
                    }
                    //if (v.breakBlock == 1) continue;
                    //if (v.breakBlock == 2) break;
                    //if (v.breakBlock == 10) return v;
                }
            }           while(expr_while.ComputeValue(content).GetBool());
            //while ((bool)expr_while.ComputeValue(content).value);
            content.DepthRemove();
#if CQUARK_DEBUG
            content.OutStack(this);
#endif
            ;
            //for 逻辑
            //做数学计算
            //从上下文取值
            //_value = null;
        }
예제 #18
0
        public CQ_Value ComputeValue(CQ_Content content)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif
            content.DepthAdd();
            ICQ_Expression expr_while = _expressions[1] as ICQ_Expression;
            ICQ_Expression expr_block = _expressions[0] as ICQ_Expression;

            CQ_Value vrt = CQ_Value.Null;
            do
            {
                if (expr_block != null)
                {
                    if (expr_block is CQ_Expression_Block)
                    {
                        var v = expr_block.ComputeValue(content);
                        if (v != CQ_Value.Null)
                        {
                            if (v.m_breakBlock == BreakType.Return)
                            {
                                vrt = v;
                            }
                            if (v.m_breakBlock == BreakType.Break || v.m_breakBlock == BreakType.Return)
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        content.DepthAdd();
                        bool bbreak = false;
                        var  v      = expr_block.ComputeValue(content);
                        if (v != CQ_Value.Null)
                        {
                            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;
                        }
                    }
                    //if (v.breakBlock == 1) continue;
                    //if (v.breakBlock == 2) break;
                    //if (v.breakBlock == 10) return v;
                }
            } while(expr_while.ComputeValue(content).GetBool());
            content.DepthRemove();
#if CQUARK_DEBUG
            content.OutStack(this);
#endif
            return(vrt);
        }
예제 #19
0
        public IEnumerator CoroutineCompute(CQ_Content content, UnityEngine.MonoBehaviour coroutine)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif
            content.DepthAdd();
            ICQ_Expression expr_init = _expressions[0] as ICQ_Expression;
            if (expr_init != null)
            {
                expr_init.ComputeValue(content);                  //expr1
            }
            ICQ_Expression expr_continue = _expressions[1] as ICQ_Expression;
            ICQ_Expression expr_step     = _expressions[2] as ICQ_Expression;

            ICQ_Expression expr_block = _expressions[3] as ICQ_Expression;

            for (; ;)
            {
                if (expr_continue != null && !expr_continue.ComputeValue(content).GetBool())               //expr2
                {
                    break;
                }

                if (expr_block != null)
                {
                    if (expr_block is CQ_Expression_Block)
                    {
                        if (expr_block.hasCoroutine)
                        {
                            yield return(coroutine.StartCoroutine(expr_block.CoroutineCompute(content, coroutine)));
                        }
                        else
                        {
                            CQ_Value v = expr_block.ComputeValue(content);

                            if (v.m_breakBlock == BreakType.Break || v.m_breakBlock == BreakType.Return)
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        content.DepthAdd();
                        bool bbreak = false;
                        if (expr_block.hasCoroutine)
                        {
                            yield return(coroutine.StartCoroutine(expr_block.CoroutineCompute(content, coroutine)));
                        }
                        else
                        {
                            CQ_Value v = expr_block.ComputeValue(content);

                            if (v.m_breakBlock == BreakType.Return || v.m_breakBlock == BreakType.Break)
                            {
                                bbreak = true;
                            }
                        }
                        content.DepthRemove();
                        if (bbreak)
                        {
                            break;
                        }
                    }
                    //if (v.breakBlock == 1) continue;
                    //if (v.breakBlock == 2) break;
                    //if (v.breakBlock == 10) return v;
                }

                if (expr_step != null)
                {
                    expr_step.ComputeValue(content);//expr3
                }
            }
            content.DepthRemove();
#if CQUARK_DEBUG
            content.OutStack(this);
#endif
            //for 逻辑
            //做数学计算
            //从上下文取值
            //_value = null;
        }
예제 #20
0
        public CQ_Value ComputeValue(CQ_Content content)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif
            content.DepthAdd();
            ICQ_Expression expr_init = _expressions[0] as ICQ_Expression;
            if (expr_init != null)
            {
                expr_init.ComputeValue(content);                //expr1
            }
            ICQ_Expression expr_continue = _expressions[1] as ICQ_Expression;
            ICQ_Expression expr_step     = _expressions[2] as ICQ_Expression;

            ICQ_Expression expr_block = _expressions[3] as ICQ_Expression;
            CQ_Value       vrt        = CQ_Value.Null;
            for (; ;)
            {
                if (expr_continue != null && !expr_continue.ComputeValue(content).GetBool())
                {
                    break;//expr2
                }
                if (expr_block != null)
                {
                    if (expr_block is CQ_Expression_Block)
                    {
                        var v = expr_block.ComputeValue(content);
                        if (v != CQ_Value.Null)
                        {
                            if (v.m_breakBlock == BreakType.Return)
                            {
                                vrt = v;
                            }
                            if (v.m_breakBlock == BreakType.Break || v.m_breakBlock == BreakType.Return)
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        content.DepthAdd();
                        bool bbreak = false;
                        var  v      = expr_block.ComputeValue(content);
                        if (v != CQ_Value.Null)
                        {
                            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;
                        }
                    }
                    //if (v.breakBlock == 1) continue;
                    //if (v.breakBlock == 2) break;
                    //if (v.breakBlock == 10) return v;
                }

                if (expr_step != null)
                {
                    expr_step.ComputeValue(content);//expr3
                }
            }
            content.DepthRemove();
#if CQUARK_DEBUG
            content.OutStack(this);
#endif
            return(vrt);
            //for 逻辑
            //做数学计算
            //从上下文取值
            //_value = null;
        }
예제 #21
0
        public IEnumerator CoroutineCompute(CQ_Content content, ICoroutine coroutine)
        {
            content.InStack(this);
            ICQ_Expression expr_if = listParam[0];
            bool           bif     = (bool)expr_if.ComputeValue(content).value;
            //if (expr_init != null) expr_init.ComputeValue(content);
            ICQ_Expression expr_go1 = listParam[1];
            ICQ_Expression expr_go2 = null;

            if (listParam.Count > 2)
            {
                expr_go2 = listParam[2];
            }
//			CQ_Content.Value value = null;
            if (bif && expr_go1 != null)
            {
                if (expr_go1 is CQ_Expression_Block)
                {
                    if (expr_go1.hasCoroutine)
                    {
                        yield return(coroutine.StartNewCoroutine(expr_go1.CoroutineCompute(content, coroutine)));
                    }
                    else
                    {
                        expr_go1.ComputeValue(content);
                    }
                }
                else
                {
                    content.DepthAdd();
                    if (expr_go1.hasCoroutine)
                    {
                        yield return(coroutine.StartNewCoroutine(expr_go1.CoroutineCompute(content, coroutine)));
                    }
                    else
                    {
                        expr_go1.ComputeValue(content);
                    }
                    content.DepthRemove();
                }
            }
            else if (!bif && expr_go2 != null)
            {
                if (expr_go2 is CQ_Expression_Block)
                {
                    if (expr_go2.hasCoroutine)
                    {
                        yield return(coroutine.StartNewCoroutine(expr_go2.CoroutineCompute(content, coroutine)));
                    }
                    else
                    {
                        expr_go2.ComputeValue(content);
                    }
                }
                else
                {
                    content.DepthAdd();
                    if (expr_go2.hasCoroutine)
                    {
                        yield return(coroutine.StartNewCoroutine(expr_go2.CoroutineCompute(content, coroutine)));
                    }
                    else
                    {
                        expr_go2.ComputeValue(content);
                    }
                    content.DepthRemove();
                }
            }

            //while((bool)expr_continue.value);

            //for 逻辑
            //做数学计算
            //从上下文取值
            //_value = null;
            content.OutStack(this);
        }
예제 #22
0
        public IEnumerator CoroutineCompute(CQ_Content content, UnityEngine.MonoBehaviour coroutine)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif
            content.DepthAdd();
            ICQ_Expression expr_switch = _expressions[0] as ICQ_Expression;
            CQ_Value       switchVal   = CQ_Value.Null;
            //			CQ_Content.Value vrt = null;
            if (expr_switch != null)
            {
                switchVal = expr_switch.ComputeValue(content);//switch//
            }
            for (int i = 1; i < _expressions.Count - 1; i += 2)
            {
                if (_expressions[i] != null)
                {
                    //case xxx://
                    if (switchVal == _expressions[i].ComputeValue(content))
                    {
                        while (_expressions[i + 1] == null)
                        {
                            i += 2;
                        }
                        content.DepthAdd();
                        if (_expressions[i + 1].hasCoroutine)
                        {
                            yield return(coroutine.StartCoroutine(_expressions[i + 1].CoroutineCompute(content, coroutine)));
                        }
                        else
                        {
                            _expressions[i + 1].ComputeValue(content);
                        }
                        break;
                    }
                    else
                    {
                        continue;
                    }
                }
                else
                {
                    //default:
                    content.DepthAdd();
                    if (_expressions[i + 1].hasCoroutine)
                    {
                        yield return(coroutine.StartCoroutine(_expressions[i + 1].CoroutineCompute(content, coroutine)));
                    }
                    else
                    {
                        _expressions[i + 1].ComputeValue(content);
                    }
                    break;
                }
            }

            content.DepthRemove();
#if CQUARK_DEBUG
            content.OutStack(this);
#endif
        }
예제 #23
0
        public IEnumerator CoroutineCompute(CQ_Content content, UnityEngine.MonoBehaviour coroutine)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif
            ICQ_Expression expr_if = _expressions[0];
            bool           bif     = expr_if.ComputeValue(content).GetBool();
            //if (expr_init != null) expr_init.ComputeValue(content);
            ICQ_Expression expr_go1 = _expressions[1];
            ICQ_Expression expr_go2 = null;
            if (_expressions.Count > 2)
            {
                expr_go2 = _expressions[2];
            }
            //			CQ_Content.Value value = null;
            if (bif && expr_go1 != null)
            {
                if (expr_go1 is CQ_Expression_Block)
                {
                    if (expr_go1.hasCoroutine)
                    {
                        yield return(coroutine.StartCoroutine(expr_go1.CoroutineCompute(content, coroutine)));
                    }
                    else
                    {
                        expr_go1.ComputeValue(content);
                    }
                }
                else
                {
                    content.DepthAdd();
                    if (expr_go1.hasCoroutine)
                    {
                        yield return(coroutine.StartCoroutine(expr_go1.CoroutineCompute(content, coroutine)));
                    }
                    else
                    {
                        expr_go1.ComputeValue(content);
                    }
                    content.DepthRemove();
                }
            }
            else if (!bif && expr_go2 != null)
            {
                if (expr_go2 is CQ_Expression_Block)
                {
                    if (expr_go2.hasCoroutine)
                    {
                        yield return(coroutine.StartCoroutine(expr_go2.CoroutineCompute(content, coroutine)));
                    }
                    else
                    {
                        expr_go2.ComputeValue(content);
                    }
                }
                else
                {
                    content.DepthAdd();
                    if (expr_go2.hasCoroutine)
                    {
                        yield return(coroutine.StartCoroutine(expr_go2.CoroutineCompute(content, coroutine)));
                    }
                    else
                    {
                        expr_go2.ComputeValue(content);
                    }
                    content.DepthRemove();
                }
            }

#if CQUARK_DEBUG
            content.OutStack(this);
#endif
        }
예제 #24
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);
        }
예제 #25
0
        public CQ_Content.Value ComputeValue(CQ_Content content)
        {
            content.InStack(this);
            content.DepthAdd();
            ICQ_Expression expr_init = listParam[0] as ICQ_Expression;

            if (expr_init != null)
            {
                expr_init.ComputeValue(content);                   //expr1
            }
            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;

            CQ_Content.Value vrt = null;
            for (; ;)
            {
                if (expr_continue != null && !(bool)expr_continue.ComputeValue(content).value)
                {
                    break;                                                                           //expr2
                }
                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;
                        }
                    }
                    //if (v.breakBlock == 1) continue;
                    //if (v.breakBlock == 2) break;
                    //if (v.breakBlock == 10) return v;
                }

                if (expr_step != null)
                {
                    expr_step.ComputeValue(content);//expr3
                }
            }
            content.DepthRemove();
            content.OutStack(this);
            return(vrt);
            //for 逻辑
            //做数学计算
            //从上下文取值
            //_value = null;
        }
예제 #26
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;
        }
예제 #27
0
        public CQ_Value ComputeValue(CQ_Content content)
        {
#if CQUARK_DEBUG
            content.InStack(this);
#endif
            content.DepthAdd();
            ICQ_Expression expr_while = _expressions[0] as ICQ_Expression;
            ICQ_Expression expr_block = _expressions[1] as ICQ_Expression;
            CQ_Value       vrt        = null;
            while ((bool)expr_while.ComputeValue(content).value)
            {
                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;
                        }
                    }
                    //if (v.breakBlock == 1) continue;
                    //if (v.breakBlock == 2) break;
                    //if (v.breakBlock == 10) return v;
                }
            }
            content.DepthRemove();
#if CQUARK_DEBUG
            content.OutStack(this);
#endif
            return(vrt);
            //for 逻辑
            //做数学计算
            //从上下文取值
            //_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);
        }